Check for INVALID_HANDLE_VALUE instead of NULL on Windows. This keeps
authorgerald <gerald@f5534014-38df-0310-8fa8-9805f1628bb7>
Thu, 27 Aug 2009 15:46:53 +0000 (15:46 +0000)
committergerald <gerald@f5534014-38df-0310-8fa8-9805f1628bb7>
Thu, 27 Aug 2009 15:46:53 +0000 (15:46 +0000)
us from feeding a NULL pointer to pcap_compile if we can't open our
pipe. Fix up a couple of error messages.

git-svn-id: http://anonsvn.wireshark.org/wireshark/trunk@29587 f5534014-38df-0310-8fa8-9805f1628bb7

dumpcap.c

index 8d4881f250a7236a566563e74e5fb1ff83c7b884..cc7e83314989435fe8a03ea57eb2c65899eca38e 100644 (file)
--- a/dumpcap.c
+++ b/dumpcap.c
@@ -829,7 +829,7 @@ cap_pipe_open_live(char *pipename, struct pcap_hdr *hdr, loop_data *ld,
 #ifndef _WIN32
   ld->cap_pipe_fd = -1;
 #else
-  ld->cap_pipe_h = NULL;
+  ld->cap_pipe_h = INVALID_HANDLE_VALUE;
 #endif
   g_log(LOG_DOMAIN_CAPTURE_CHILD, G_LOG_LEVEL_DEBUG, "cap_pipe_open_live: %s", pipename);
 
@@ -913,8 +913,8 @@ cap_pipe_open_live(char *pipename, struct pcap_hdr *hdr, loop_data *ld,
         FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_ALLOCATE_BUFFER,
           NULL, GetLastError(), 0, (LPTSTR) &err_str, 0, NULL);
         g_snprintf(errmsg, errmsgl,
-            "The capture session on \"%s\" could not be initiated "
-            "due to error on pipe open: pipe busy: %s (error %d)",
+            "The capture session on \"%s\" could not be started "
+            "due to error on pipe open: %s (error %d)",
             pipename, utf_16to8(err_str), GetLastError());
         LocalFree(err_str);
         ld->cap_pipe_err = PIPERR;
@@ -925,9 +925,9 @@ cap_pipe_open_live(char *pipename, struct pcap_hdr *hdr, loop_data *ld,
         FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_ALLOCATE_BUFFER,
           NULL, GetLastError(), 0, (LPTSTR) &err_str, 0, NULL);
         g_snprintf(errmsg, errmsgl,
-            "The capture session could not be initiated "
-            "due to error on named pipe open: %s (error %d)",
-            utf_16to8(err_str), GetLastError());
+            "The capture session on \"%s\" timed out during "
+            "pipe open: %s (error %d)",
+            pipename, utf_16to8(err_str), GetLastError());
         LocalFree(err_str);
         ld->cap_pipe_err = PIPERR;
         return;
@@ -1454,7 +1454,7 @@ capture_loop_open_input(capture_options *capture_opts, loop_data *ld,
 #ifndef _WIN32
     if (ld->cap_pipe_fd == -1) {
 #else
-    if (ld->cap_pipe_h == NULL) {
+    if (ld->cap_pipe_h == INVALID_HANDLE_VALUE) {
 #endif
 
       if (ld->cap_pipe_err == PIPNEXIST) {
@@ -1545,10 +1545,9 @@ static void capture_loop_close_input(loop_data *ld) {
     ld->cap_pipe_fd = 0;
   }
 #else
-  if (ld->cap_pipe_h) {
-    g_assert(ld->from_cap_pipe);
+  if (ld->cap_pipe_h != INVALID_HANDLE_VALUE) {
     CloseHandle(ld->cap_pipe_h);
-    ld->cap_pipe_h = NULL;
+    ld->cap_pipe_h = INVALID_HANDLE_VALUE;
   }
 #endif
 
@@ -2037,7 +2036,7 @@ capture_loop_start(capture_options *capture_opts, gboolean *stats_known, struct
 #ifndef _WIN32
   global_ld.cap_pipe_fd        = -1;
 #else
-  global_ld.cap_pipe_h         = NULL;
+  global_ld.cap_pipe_h         = INVALID_HANDLE_VALUE;
 #endif
 #ifdef MUST_DO_SELECT
   global_ld.pcap_fd            = 0;