Fix possibly not null-terminated string
authorColin Leroy <colin@colino.net>
Thu, 8 Oct 2015 17:08:23 +0000 (19:08 +0200)
committerColin Leroy <colin@colino.net>
Thu, 8 Oct 2015 17:08:23 +0000 (19:08 +0200)
src/plugins/clamd/libclamd/clamd-plugin.c

index b50fb90..5f58cfa 100644 (file)
@@ -389,7 +389,7 @@ Clamd_Stat clamd_init(Clamd_Socket* config) {
        }
        memset(buf, '\0', sizeof(buf));
         while ((n_read = read(sock, buf, sizeof(buf))) > 0) {
-           buf[sizeof(buf) - 1] = '\0';
+           buf[n_read] = '\0';
            if (buf[strlen(buf) - 1] == '\n')
                buf[strlen(buf) - 1] = '\0';
            debug_print("Version: %s\n", buf);
@@ -526,7 +526,7 @@ Clamd_Stat clamd_verify_email(const gchar* path, response* result) {
                g_free(command);
                memset(buf, '\0', sizeof(buf));
                while ((n_read = read(sock, buf, BUFSIZ)) > 0) {
-                       buf[sizeof(buf) - 1] = '\0';
+                       buf[n_read] = '\0';
                        if (buf[strlen(buf) - 1] == '\n')
                                buf[strlen(buf) - 1] = '\0';
                }