[rtems-libbsd commit] IFCONFIG(8): Fix write to const string

Sebastian Huber sebh at rtems.org
Mon May 13 07:33:18 UTC 2019


Module:    rtems-libbsd
Branch:    master
Commit:    60e753777a62f86db956368204c27e7d74ec99aa
Changeset: http://git.rtems.org/rtems-libbsd/commit/?id=60e753777a62f86db956368204c27e7d74ec99aa

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Mon May 13 09:19:44 2019 +0200

IFCONFIG(8): Fix write to const string

---

 freebsd/sbin/ifconfig/af_inet.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/freebsd/sbin/ifconfig/af_inet.c b/freebsd/sbin/ifconfig/af_inet.c
index 960b800..050ceb8 100644
--- a/freebsd/sbin/ifconfig/af_inet.c
+++ b/freebsd/sbin/ifconfig/af_inet.c
@@ -149,6 +149,12 @@ in_getaddr(const char *s, int which)
 	struct hostent *hp;
 	struct netent *np;
 
+#ifdef __rtems__
+	/* Memory is automatically freed */
+	s = strdup(s);
+	if (s == NULL)
+		errx(1, "no memory");
+#endif /* __rtems__ */
 	sin->sin_len = sizeof(*sin);
 	sin->sin_family = AF_INET;
 



More information about the vc mailing list