aboutsummaryrefslogtreecommitdiffstats
path: root/fad-win32.c
diff options
context:
space:
mode:
authorrisso <risso>2005-09-01 22:14:32 +0000
committerrisso <risso>2005-09-01 22:14:32 +0000
commita8302b7a2baa8e973fdb8fe55b4338725d1925b8 (patch)
tree1ec8c870ffa8a5adbd780ce0ebcc13ed365addfd /fad-win32.c
parent3410839c5db27f96f22e0cc896f24847de5d7584 (diff)
Added a missing check on the return value of PacketGetAdapterNames()
Diffstat (limited to 'fad-win32.c')
-rw-r--r--fad-win32.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/fad-win32.c b/fad-win32.c
index a02b57c..50552b9 100644
--- a/fad-win32.c
+++ b/fad-win32.c
@@ -32,7 +32,7 @@
#ifndef lint
static const char rcsid[] _U_ =
- "@(#) $Header: /tcpdump/master/libpcap/fad-win32.c,v 1.11 2005-01-29 00:52:22 guy Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/libpcap/fad-win32.c,v 1.12 2005-09-01 22:14:32 risso Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@@ -224,12 +224,22 @@ pcap_findalldevs(pcap_if_t **alldevsp, char *errbuf)
ULONG NameLength;
char *name;
- PacketGetAdapterNames(NULL, &NameLength);
+ if(!PacketGetAdapterNames(NULL, &NameLength) && NameLength == 0)
+ {
+ /*
+ * If PacketGetAdapterNames *and* sets the lenght of the buffer to zero,
+ * it means there was an error.
+ */
+ snprintf(errbuf, PCAP_ERRBUF_SIZE, "PacketGetAdapterNames failed: %s", pcap_win32strerror());
+ *alldevsp = NULL;
+ return -1;
+ }
if (NameLength > 0)
AdaptersName = (char*) malloc(NameLength);
else
{
+ snprintf(errbuf, PCAP_ERRBUF_SIZE, "no adapters found.");
*alldevsp = NULL;
return 0;
}