aboutsummaryrefslogtreecommitdiffstats
path: root/fad-win32.c
diff options
context:
space:
mode:
authorgianluca <gianluca>2006-01-22 18:29:00 +0000
committergianluca <gianluca>2006-01-22 18:29:00 +0000
commit4526fd6dee8111e58a38f2766f2780099566359f (patch)
tree93083084ef453f5c51424db19fd773996484b140 /fad-win32.c
parent54693a0c07f250cdf6f800db8e6a8698d3bfad0b (diff)
Added some code to properly distinguish a failure in PacketGetAdapterNames()
from a "buffer too small" error.
Diffstat (limited to 'fad-win32.c')
-rw-r--r--fad-win32.c21
1 files changed, 11 insertions, 10 deletions
diff --git a/fad-win32.c b/fad-win32.c
index 50552b9..04f5c3c 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.12 2005-09-01 22:14:32 risso Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/libpcap/fad-win32.c,v 1.13 2006-01-22 18:29:00 gianluca Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@@ -224,22 +224,23 @@ pcap_findalldevs(pcap_if_t **alldevsp, char *errbuf)
ULONG NameLength;
char *name;
- if(!PacketGetAdapterNames(NULL, &NameLength) && NameLength == 0)
+ if (!PacketGetAdapterNames(NULL, &NameLength))
{
- /*
- * 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;
+ DWORD last_error = GetLastError();
+
+ if (last_error != ERROR_INSUFFICIENT_BUFFER)
+ {
+ snprintf(errbuf, PCAP_ERRBUF_SIZE,
+ "PacketGetAdapterNames: %s",
+ pcap_win32strerror());
+ return (-1);
+ }
}
if (NameLength > 0)
AdaptersName = (char*) malloc(NameLength);
else
{
- snprintf(errbuf, PCAP_ERRBUF_SIZE, "no adapters found.");
*alldevsp = NULL;
return 0;
}