On 2015/02/12 12:36, Stuart Henderson wrote:
> On 2015/02/12 12:32, Zé Loff wrote:
> >
> > Apologies in advance if this has already been spotted and/or fixed, but
> > I'm getting:
> >
> > $ netstat -w 1
> > netstat(20903) in realloc(): error: bogus pointer (double free?)
> > 0x71b14123800
>
> Are your kernel and userland in-sync?
>
Oh, yes it does happen with them in-sync, it only happens when there are
more interfaces than fit in the buffer from the original sysctl estimate.
buf was not initialized so pointing to random memory.
Index: if.c
===================================================================
RCS file: /cvs/src/usr.bin/netstat/if.c,v
retrieving revision 1.72
diff -u -p -r1.72 if.c
--- if.c 9 Feb 2015 12:25:03 -0000 1.72
+++ if.c 12 Feb 2015 12:49:05 -0000
@@ -503,7 +503,7 @@ fetchifs(void)
struct if_data *ifd;
struct sockaddr *sa, *rti_info[RTAX_MAX];
struct sockaddr_dl *sdl;
- char *buf, *next, *lim;
+ char *buf = NULL, *next, *lim;
char name[IFNAMSIZ];
size_t len;
int takeit = 0;
Index: mroute6.c
===================================================================
RCS file: /cvs/src/usr.bin/netstat/mroute6.c,v
retrieving revision 1.17
diff -u -p -r1.17 mroute6.c
--- mroute6.c 9 Feb 2015 12:25:03 -0000 1.17
+++ mroute6.c 12 Feb 2015 12:49:05 -0000
@@ -84,7 +84,7 @@
void
mroute6pr(void)
{
- char *buf;
+ char *buf = NULL;
char fmtbuf[FMT_SCALED_STRSIZE];
struct mf6cinfo *mfc;
struct mif6info *mif;