]> The Tcpdump Group git mirrors - libpcap/blobdiff - pcap.c
Handle pcap_open_live(), and other routines, using NULL to mean "any".
[libpcap] / pcap.c
diff --git a/pcap.c b/pcap.c
index c26b888be5cf2b0f3276a8be5a190512f0c84f10..36a118bc766ddbecc7bd3b2f857616ed1a60a42c 100644 (file)
--- a/pcap.c
+++ b/pcap.c
@@ -2079,7 +2079,7 @@ int
 pcap_parsesrcstr(const char *source, int *type, char *host, char *port,
     char *name, char *errbuf)
 {
-  return pcap_parsesrcstr_ex(source, type, host, port, name, NULL, errbuf);
+       return (pcap_parsesrcstr_ex(source, type, host, port, name, NULL, errbuf));
 }
 #endif
 
@@ -2589,6 +2589,16 @@ pcap_open_live(const char *device, int snaplen, int promisc, int to_ms, char *er
        char name[PCAP_BUF_SIZE + 1];
        int srctype;
 
+       /*
+        * A null device name is equivalent to the "any" device -
+        * which might not be supported on this platform, but
+        * this means that you'll get a "not supported" error
+        * rather than, say, a crash when we try to dereference
+        * the null pointer.
+        */
+       if (device == NULL)
+               device = "any";
+
        /*
         * Retrofit - we have to make older applications compatible with
         * remote capture.