diff options
author | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2014-09-18 13:01:25 +0200 |
---|---|---|
committer | Sebastian Huber <sebastian.huber@embedded-brains.de> | 2014-09-18 13:02:36 +0200 |
commit | 705d1bf8d2d9db0a4ded8b37526e34542eec813c (patch) | |
tree | f4ae515a8740b73cfc668224f35abcf2b40a204f | |
parent | Fix cr_cansee*() to see everything (diff) | |
download | rtems-libbsd-705d1bf8d2d9db0a4ded8b37526e34542eec813c.tar.bz2 |
netstat: Fix invalid free()
-rw-r--r-- | freebsd/usr.bin/netstat/bpf.c | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/freebsd/usr.bin/netstat/bpf.c b/freebsd/usr.bin/netstat/bpf.c index 50e12fac..824319cb 100644 --- a/freebsd/usr.bin/netstat/bpf.c +++ b/freebsd/usr.bin/netstat/bpf.c @@ -55,12 +55,10 @@ __FBSDID("$FreeBSD$"); /* print bpf stats */ +#ifndef __rtems__ static char * bpf_pidname(pid_t pid) { -#ifdef __rtems__ - return "rtems"; -#else /* __rtems__ */ struct kinfo_proc newkp; int error, mib[4]; size_t size; @@ -76,8 +74,8 @@ bpf_pidname(pid_t pid) return (strdup("??????")); } return (strdup(newkp.ki_comm)); -#endif /* __rtems__ */ } +#endif /* __rtems__ */ static void bpf_flags(struct xbpf_d *bd, char *flagbuf) @@ -139,12 +137,18 @@ bpf_stats(char *ifname) if (ifname && strcmp(ifname, d->bd_ifname) != 0) continue; bpf_flags(d, flagbuf); +#ifndef __rtems__ pname = bpf_pidname(d->bd_pid); +#else /* __rtems__ */ + pname = "??????"; +#endif /* __rtems__ */ (void) printf("%5d %6s %7s %9ju %9ju %9ju %5d %5d %s\n", d->bd_pid, d->bd_ifname, flagbuf, d->bd_rcount, d->bd_dcount, d->bd_fcount, d->bd_slen, d->bd_hlen, pname); +#ifndef __rtems__ free(pname); +#endif /* __rtems__ */ } free(bd); } |