[rtems-libbsd commit] NETSTAT(1): Avoid use of uninitialized memory

Sebastian Huber sebh at rtems.org
Wed Nov 18 08:51:16 UTC 2015


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

Author:    Sebastian Huber <sebastian.huber at embedded-brains.de>
Date:      Wed Nov 18 09:47:10 2015 +0100

NETSTAT(1): Avoid use of uninitialized memory

---

 freebsd/usr.bin/netstat/main.c    |  3 +++
 freebsd/usr.bin/netstat/mbuf.c    |  3 ++-
 freebsd/usr.bin/netstat/mroute.c  | 19 +++++++++++++++++++
 freebsd/usr.bin/netstat/mroute6.c | 21 +++++++++++++++++++++
 4 files changed, 45 insertions(+), 1 deletion(-)

diff --git a/freebsd/usr.bin/netstat/main.c b/freebsd/usr.bin/netstat/main.c
index 1caecbe..7d26216 100644
--- a/freebsd/usr.bin/netstat/main.c
+++ b/freebsd/usr.bin/netstat/main.c
@@ -387,6 +387,9 @@ int rtems_bsd_command_netstat(int argc, char *argv[])
 
 	rtems_bsd_program_lock();
 
+	nlistf = NULL;
+	memf = NULL;
+
 	Aflag = 0;
 	aflag = 0;
 	Bflag = 0;
diff --git a/freebsd/usr.bin/netstat/mbuf.c b/freebsd/usr.bin/netstat/mbuf.c
index ac123b2..a005d16 100644
--- a/freebsd/usr.bin/netstat/mbuf.c
+++ b/freebsd/usr.bin/netstat/mbuf.c
@@ -116,7 +116,8 @@ mbpr(void *kvmd, u_long mbaddr)
 			goto out;
 		}
 #else /* __rtems__ */
-		;
+		warnx("mbpr: not implemented");
+		goto out;
 #endif /* __rtems__ */
 	}
 
diff --git a/freebsd/usr.bin/netstat/mroute.c b/freebsd/usr.bin/netstat/mroute.c
index 07bc95e..21ba22f 100644
--- a/freebsd/usr.bin/netstat/mroute.c
+++ b/freebsd/usr.bin/netstat/mroute.c
@@ -231,7 +231,14 @@ mroutepr(u_long pmfchashtbl, u_long pmfctablesize, u_long pviftbl)
 			return;
 		}
 	} else
+#ifndef __rtems__
 		kread(pviftbl, (char *)viftable, sizeof(viftable));
+#else /* __rtems__ */
+	{
+		warnx("mroutepr: not implemented");
+		return;
+	}
+#endif /* __rtems__ */
 
 	banner_printed = 0;
 	for (vifi = 0, v = viftable; vifi < MAXVIFS; ++vifi, ++v) {
@@ -302,6 +309,7 @@ mroutepr(u_long pmfchashtbl, u_long pmfctablesize, u_long pviftbl)
 
 		free(mfctable);
 	} else {
+#ifndef __rtems__
 		LIST_HEAD(, mfc) *mfchashtbl;
 		u_long i, mfctablesize;
 		struct mfc mfc;
@@ -330,6 +338,10 @@ mroutepr(u_long pmfchashtbl, u_long pmfctablesize, u_long pviftbl)
 		}
 
 		free(mfchashtbl);
+#else /* __rtems__ */
+		warnx("mroutepr: not implemented");
+		return;
+#endif /* __rtems__ */
 	}
 
 	if (!banner_printed)
@@ -352,7 +364,14 @@ mrt_stats(u_long mstaddr)
 			return;
 		}
 	} else
+#ifndef __rtems__
 		kread(mstaddr, (char *)&mrtstat, sizeof(mrtstat));
+#else /* __rtems__ */
+	{
+		warnx("mrt_stats: not implemented");
+		return;
+	}
+#endif /* __rtems__ */
 
 	printf("IPv4 multicast forwarding:\n");
 
diff --git a/freebsd/usr.bin/netstat/mroute6.c b/freebsd/usr.bin/netstat/mroute6.c
index 59a7b6c..20a9d08 100644
--- a/freebsd/usr.bin/netstat/mroute6.c
+++ b/freebsd/usr.bin/netstat/mroute6.c
@@ -124,7 +124,14 @@ mroute6pr(u_long mfcaddr, u_long mifaddr)
 			return;
 		}
 	} else
+#ifndef __rtems__
 		kread(mifaddr, (char *)mif6table, sizeof(mif6table));
+#else /* __rtems__ */
+	{
+		warnx("mroute6pr: not implemented");
+		return;
+	}
+#endif /* __rtems__ */
 
 	saved_numeric_addr = numeric_addr;
 	numeric_addr = 1;
@@ -167,7 +174,14 @@ mroute6pr(u_long mfcaddr, u_long mifaddr)
 			return;
 		}
 	} else
+#ifndef __rtems__
 		kread(mfcaddr, (char *)mf6ctable, sizeof(mf6ctable));
+#else /* __rtems__ */
+	{
+		warnx("mroute6pr: not implemented");
+		return;
+	}
+#endif /* __rtems__ */
 
 	banner_printed = 0;
 
@@ -231,7 +245,14 @@ mrt6_stats(u_long mstaddr)
 			return;
 		}
 	} else
+#ifndef __rtems__
 		kread(mstaddr, (char *)&mrtstat, sizeof(mrtstat));
+#else /* __rtems__ */
+	{
+		warnx("mrt6_stats: not implemented");
+		return;
+	}
+#endif /* __rtems__ */
 
 	printf("IPv6 multicast forwarding:\n");
 




More information about the vc mailing list