dect
/
libpcap
Archived
13
0
Fork 0

fix to problem with buf being referenced after it is freed.

This commit is contained in:
mcr 2000-01-14 23:55:31 +00:00
parent f1456fa8f9
commit dba6e9e734
1 changed files with 3 additions and 2 deletions

5
inet.c
View File

@ -33,7 +33,7 @@
#ifndef lint
static const char rcsid[] =
"@(#) $Header: /tcpdump/master/libpcap/inet.c,v 1.25 2000-01-13 17:08:59 itojun Exp $ (LBL)";
"@(#) $Header: /tcpdump/master/libpcap/inet.c,v 1.26 2000-01-14 23:55:31 mcr Exp $ (LBL)";
#endif
#include <sys/param.h>
@ -173,15 +173,16 @@ pcap_lookupdev(errbuf)
mp = ifrp;
}
}
free(buf);
(void)close(fd);
if (mp == NULL) {
(void)strcpy(errbuf, "no suitable device found");
free(buf);
return (NULL);
}
(void)strncpy(device, mp->ifr_name, sizeof(device) - 1);
device[sizeof(device) - 1] = '\0';
free(buf);
return (device);
}