Don't supply a fallback error message for pcap_open() unless it actually
authorGuy Harris <guy@alum.mit.edu>
Wed, 27 Jun 2012 05:13:06 +0000 (05:13 -0000)
committerGuy Harris <guy@alum.mit.edu>
Wed, 27 Jun 2012 05:13:06 +0000 (05:13 -0000)
fails.

This may clear up the problem most recently reported in bug 7021 after
the crash was fixed, where the capture starts successfully but an error
dialog pops up.

svn path=/trunk/; revision=43501

dumpcap.c

index e0be8a18fc98a4947ec0f575a7701f4f1f4be655..74f8811c13b1906ebc171583a6798c2ed49a8fee 100644 (file)
--- a/dumpcap.c
+++ b/dumpcap.c
@@ -652,12 +652,15 @@ open_capture_device(interface_options *interface_opts,
                            (interface_opts->datatx_udp ? PCAP_OPENFLAG_DATATX_UDP : 0) |
                            (interface_opts->nocap_rpcap ? PCAP_OPENFLAG_NOCAPTURE_RPCAP : 0),
                            CAP_READ_TIMEOUT, &auth, *open_err_str);
-        if ((*open_err_str)[0] == '\0') {
-            /* Work around known WinPcap bug wherein no error message is
-               filled in on a failure to open an rpcap: URL. */
-            g_strlcpy(*open_err_str,
-                      "Unknown error (pcap bug; actual error cause not reported)",
-                      sizeof *open_err_str);
+        if (pcap_h == NULL) {
+            /* Error - did pcap actually supply an error message? */
+            if ((*open_err_str)[0] == '\0') {
+                /* Work around known WinPcap bug wherein no error message is
+                   filled in on a failure to open an rpcap: URL. */
+                g_strlcpy(*open_err_str,
+                          "Unknown error (pcap bug; actual error cause not reported)",
+                          sizeof *open_err_str);
+            }
         }
         g_log(LOG_DOMAIN_CAPTURE_CHILD, G_LOG_LEVEL_DEBUG,
               "pcap_open() returned %p.", (void *)pcap_h);