aboutsummaryrefslogtreecommitdiffstats
path: root/fad-win32.c
diff options
context:
space:
mode:
authorrisso <risso>2004-04-30 08:58:52 +0000
committerrisso <risso>2004-04-30 08:58:52 +0000
commit5f53d2308e89c07b00dd1b78e5956591185b6d66 (patch)
tree73fc7b584591270d36463456bc96e4694d02d976 /fad-win32.c
parent076135f7df2eb3d419142d3dcff37d2271cc24fd (diff)
Modified pcap_findalldevs on Win32, so that it is able to properly handle an
indefinite number of adapters. Before the buffer passed to PacketGetAdapterNames was limited to 8kB.
Diffstat (limited to 'fad-win32.c')
-rw-r--r--fad-win32.c22
1 files changed, 19 insertions, 3 deletions
diff --git a/fad-win32.c b/fad-win32.c
index c57ffe0..1d67c9b 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.8 2003-11-15 23:23:59 guy Exp $ (LBL)";
+ "@(#) $Header: /tcpdump/master/libpcap/fad-win32.c,v 1.9 2004-04-30 08:58:52 risso Exp $ (LBL)";
#endif
#ifdef HAVE_CONFIG_H
@@ -221,14 +221,29 @@ pcap_findalldevs(pcap_if_t **alldevsp, char *errbuf)
pcap_if_t *devlist = NULL;
int ret = 0;
const char *desc;
- char AdaptersName[8192];
- ULONG NameLength = 8192;
+ char *AdaptersName;
+ ULONG NameLength;
char *name;
+ PacketGetAdapterNames(NULL, &NameLength);
+
+ if (NameLength > 0)
+ AdaptersName = (char*) malloc(NameLength);
+ else
+ {
+ return (NULL);
+ }
+ if (AdaptersName == NULL)
+ {
+ snprintf(errbuf, PCAP_ERRBUF_SIZE, "Cannot allocate enough memory to list the adapters.");
+ return (-1);
+ }
+
if (!PacketGetAdapterNames(AdaptersName, &NameLength)) {
snprintf(errbuf, PCAP_ERRBUF_SIZE,
"PacketGetAdapterNames: %s",
pcap_win32strerror());
+ free(AdaptersName);
return (-1);
}
@@ -287,5 +302,6 @@ pcap_findalldevs(pcap_if_t **alldevsp, char *errbuf)
}
*alldevsp = devlist;
+ free(AdaptersName);
return (ret);
}