extcap: null terminate the string that will be used in strlen (CID 1364684).
authorDario Lombardo <lomato@gmail.com>
Fri, 22 Dec 2017 16:21:25 +0000 (17:21 +0100)
committerMichael Mann <mmann78@netscape.net>
Sat, 23 Dec 2017 01:31:31 +0000 (01:31 +0000)
Change-Id: Ie4c7eed2ac24327292af9a45ffc7e4630338a6b4
Reviewed-on: https://code.wireshark.org/review/24948
Petri-Dish: Dario Lombardo <lomato@gmail.com>
Tested-by: Petri Dish Buildbot
Reviewed-by: Michael Mann <mmann78@netscape.net>
extcap.c

index 179a2cd6a7c63d2893acabbc2defdee2d7479ffa..d0d527ffb1c28349e05075d5b8e198887a775d7e 100644 (file)
--- a/extcap.c
+++ b/extcap.c
@@ -1070,10 +1070,16 @@ void extcap_if_cleanup(capture_options *capture_opts, gchar **errormsg)
 #ifdef _WIN32
                 win32_readfrompipe((HANDLE)_get_osfhandle(userdata->extcap_stderr_rd), STDERR_BUFFER_SIZE, buffer);
 #else
-                if (read(userdata->extcap_stderr_rd, buffer, sizeof(gchar) * STDERR_BUFFER_SIZE) <= 0)
+                ssize_t buffer_len;
+                buffer_len = read(userdata->extcap_stderr_rd, buffer, sizeof(gchar) * STDERR_BUFFER_SIZE);
+                if (buffer_len <= 0)
                 {
                     buffer[0] = '\0';
                 }
+                else
+                {
+                    buffer[buffer_len] = '\0';
+                }
 #endif
                 if (strlen(buffer) > 0)
                 {