aboutsummaryrefslogtreecommitdiffstats
path: root/pcap-util.c
diff options
context:
space:
mode:
authorGuy Harris <guy@alum.mit.edu>2003-06-10 08:01:42 +0000
committerGuy Harris <guy@alum.mit.edu>2003-06-10 08:01:42 +0000
commit32eb0448a89c7797b043f57f6caf03bf044112c7 (patch)
tree8576e1dcac036dfbba0365f2e669af3d5b35f290 /pcap-util.c
parent537710afee6a107753f5d6b0e552fc1e484d0913 (diff)
Handle the case of an empty interface list on Windows the same way we
handle it on UNIX. Check for an empty interface name (which indicates the end of the interface list) at the beginning of the loop, so that if the first interface name is empty (meaning an empty interface list) we don't put a bogus entry into the list with just a colon. svn path=/trunk/; revision=7828
Diffstat (limited to 'pcap-util.c')
-rw-r--r--pcap-util.c25
1 files changed, 14 insertions, 11 deletions
diff --git a/pcap-util.c b/pcap-util.c
index 655301d23b..cb6621f315 100644
--- a/pcap-util.c
+++ b/pcap-util.c
@@ -1,7 +1,7 @@
/* pcap-util.c
* Utility routines for packet capture
*
- * $Id: pcap-util.c,v 1.11 2003/03/25 06:04:51 guy Exp $
+ * $Id: pcap-util.c,v 1.12 2003/06/10 08:01:42 guy Exp $
*
* Ethereal - Network traffic analyzer
* By Gerald Combs <gerald@ethereal.com>
@@ -407,7 +407,7 @@ get_interface_list(int *err, char *err_str) {
wchar_t *names;
char *win95names;
char newname[MAX_WIN_IF_NAME_LEN + 1];
- int i, j, done;
+ int i, j;
/* On Windows pcap_lookupdev is implemented by calling
* PacketGetAdapterNames. According to the documentation I can find
@@ -433,7 +433,7 @@ get_interface_list(int *err, char *err_str) {
*/
names = (wchar_t *)pcap_lookupdev(err_str);
- i = done = 0;
+ i = 0;
if (names) {
char* desc = 0;
@@ -447,7 +447,7 @@ get_interface_list(int *err, char *err_str) {
desc_pos++; /* Step over the extra '\0' */
desc = (char*)(names + desc_pos); /* cast *after* addition */
- do
+ while (names[i] != 0)
{
j = 0;
while (*desc) {
@@ -464,11 +464,9 @@ get_interface_list(int *err, char *err_str) {
newname[j++] = names[i++];
}
i++;
- if (names[i] == 0)
- done = 1;
newname[j] = 0;
il = g_list_append(il, g_strdup(newname));
- } while (!done);
+ }
}
else {
/* Otherwise we are in Windows 95/98 and using ascii(8 bit)
@@ -479,7 +477,7 @@ get_interface_list(int *err, char *err_str) {
desc_pos++; /* Step over the extra '\0' */
desc = win95names + desc_pos;
- do
+ while (win95names[i] == 0)
{
j = 0;
while (*desc) {
@@ -496,13 +494,18 @@ get_interface_list(int *err, char *err_str) {
newname[j++] = win95names[i++];
}
i++;
- if (win95names[i] == 0)
- done = 1;
newname[j] = 0;
il = g_list_append(il, g_strdup(newname));
- } while (!done);
+ }
}
}
+
+ if (il == NULL) {
+ /*
+ * No interfaces found.
+ */
+ *err = NO_INTERFACES_FOUND;
+ }
return(il);
}
#endif