From: Colin Leroy Date: Thu, 8 Oct 2015 17:08:23 +0000 (+0200) Subject: Fix possibly not null-terminated string X-Git-Tag: 3.13.0~16 X-Git-Url: http://git.claws-mail.org/?p=claws.git;a=commitdiff_plain;h=47d362fb39527b0f100cdc8c247a472767b6554e Fix possibly not null-terminated string --- diff --git a/src/plugins/clamd/libclamd/clamd-plugin.c b/src/plugins/clamd/libclamd/clamd-plugin.c index b50fb9050..5f58cfad9 100644 --- a/src/plugins/clamd/libclamd/clamd-plugin.c +++ b/src/plugins/clamd/libclamd/clamd-plugin.c @@ -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'; }