]> The Tcpdump Group git mirrors - tcpdump/blobdiff - tcpdump.c
CVE-2017-12986/IPv6 R.H.: Update to reflect the actual IPv6 RFC.
[tcpdump] / tcpdump.c
index 86ccc50c9c27139aa2bb03a09159e1a782d52215..053dd5401999ffbc9c6364a4636aa2b9d92c410b 100644 (file)
--- a/tcpdump.c
+++ b/tcpdump.c
@@ -185,17 +185,17 @@ cap_channel_t *capdns;
 #endif
 
 /* Forwards */
-static void error(FORMAT_STRING(const char *), ...) NORETURN PRINTFLIKE(1, 2);
+static NORETURN void error(FORMAT_STRING(const char *), ...) PRINTFLIKE(1, 2);
 static void warning(FORMAT_STRING(const char *), ...) PRINTFLIKE(1, 2);
-static void exit_tcpdump(int) NORETURN;
+static NORETURN void exit_tcpdump(int);
 static RETSIGTYPE cleanup(int);
 static RETSIGTYPE child_cleanup(int);
 static void print_version(void);
 static void print_usage(void);
-static void show_tstamp_types_and_exit(pcap_t *, const char *device) NORETURN;
-static void show_dlts_and_exit(pcap_t *, const char *device) NORETURN;
+static NORETURN void show_tstamp_types_and_exit(pcap_t *, const char *device);
+static NORETURN void show_dlts_and_exit(pcap_t *, const char *device);
 #ifdef HAVE_PCAP_FINDALLDEVS
-static void show_devices_and_exit (void) NORETURN;
+static NORETURN void show_devices_and_exit(void);
 #endif
 
 static void print_packet(u_char *, const struct pcap_pkthdr *, const u_char *);
@@ -1724,20 +1724,21 @@ main(int argc, char **argv)
                         * Find the list of interfaces, and pick
                         * the first interface.
                         */
-                       if (pcap_findalldevs(&devlist, ebuf) >= 0 &&
-                           devlist != NULL) {
-                               device = strdup(devlist->name);
-                               pcap_freealldevs(devlist);
-                       }
+                       if (pcap_findalldevs(&devlist, ebuf) == -1)
+                               error("%s", ebuf);
+                       if (devlist == NULL)
+                               error("no interfaces available for capture");
+                       device = strdup(devlist->name);
+                       pcap_freealldevs(devlist);
 #else /* HAVE_PCAP_FINDALLDEVS */
                        /*
                         * Use whatever interface pcap_lookupdev()
                         * chooses.
                         */
                        device = pcap_lookupdev(ebuf);
-#endif
                        if (device == NULL)
                                error("%s", ebuf);
+#endif
                }
 
                /*