capture_sync: use ws_strtou function.
authorDario Lombardo <lomato@gmail.com>
Tue, 6 Sep 2016 07:58:48 +0000 (09:58 +0200)
committerPeter Wu <peter@lekensteyn.nl>
Wed, 21 Sep 2016 16:41:36 +0000 (16:41 +0000)
Change-Id: Ic128a7f1afd85f6b737392ff76b40d54cbdd8971
Reviewed-on: https://code.wireshark.org/review/17523
Petri-Dish: Dario Lombardo <lomato@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Peter Wu <peter@lekensteyn.nl>
capchild/capture_sync.c

index 5c62e2c437e09fc9ce428fc08a7b5365f329606f..eb3a1e05312f2b3bf7a3cd19828d8ba2fae37bd1 100644 (file)
@@ -31,6 +31,8 @@
 
 #include <signal.h>
 
+#include <wsutil/strtoi.h>
+
 #ifdef _WIN32
 #include <wsutil/unicode-utils.h>
 #include <wsutil/win32-utils.h>
@@ -1687,7 +1689,7 @@ sync_pipe_input_cb(gint source, gpointer user_data)
     int  secondary_len;
     char *secondary_msg;
     char *wait_msg, *combined_msg;
-    int npackets;
+    guint32 npackets = 0;
 
     nread = pipe_read_block(source, &indicator, SP_MAX_MSG_LEN, buffer,
                             &primary_msg);
@@ -1768,7 +1770,9 @@ sync_pipe_input_cb(gint source, gpointer user_data)
         }
         break;
     case SP_PACKET_COUNT:
-        npackets = atoi(buffer);
+        if (!ws_strtou32(buffer, NULL, &npackets)) {
+            g_log(LOG_DOMAIN_CAPTURE, G_LOG_LEVEL_WARNING, "Invalid packets number: %s", buffer);
+        }
         g_log(LOG_DOMAIN_CAPTURE, G_LOG_LEVEL_DEBUG, "sync_pipe_input_cb: new packets %u", npackets);
         cap_session->count += npackets;
         capture_input_new_packets(cap_session, npackets);