PERFORCE change 137413 for review

Robert Watson rwatson at FreeBSD.org
Tue Mar 11 16:39:36 UTC 2008


http://perforce.freebsd.org/chv.cgi?CH=137413

Change 137413 by rwatson at rwatson_cinnamon on 2008/03/11 16:38:52

	Don't print BPF descriptor data if we have the wrong structure
	size/version, as it may be garbage.

Affected files ...

.. //depot/projects/zcopybpf/src/usr.sbin/netstat/bpf.c#8 edit

Differences ...

==== //depot/projects/zcopybpf/src/usr.sbin/netstat/bpf.c#8 (text+ko) ====

@@ -127,6 +127,10 @@
 	if (bpf_get_stats(&size, &bd) < 0)
 		return;
 	for (d = &bd[0]; d < &bd[size / sizeof(*d)]; d++) {
+		if (d->bd_structsize != sizeof(*d)) {
+			warnx("bpf_stats_extended: version mismatch");
+			return;
+		}
 		if (ifname && strcmp(ifname, d->bd_ifname) != 0)
 			continue;
 		pname = bpf_pidname(d->bd_pid);
@@ -169,6 +173,10 @@
 	    "Pid", "Netif", "Flags", "Recv", "Drop", "Match", "Sblen",
 	    "Hblen", "Command");
 	for (d = &bd[0]; d < &bd[size / sizeof(*d)]; d++) {
+		if (d->bd_structsize != sizeof(*d)) {
+			warnx("bpf_stats_extended: version mismatch");
+			return;
+		}
 		if (ifname && strcmp(ifname, d->bd_ifname) != 0)
 			continue;
 		bpf_flags(d, flagbuf);


More information about the p4-projects mailing list