talons

Fork of Claws Mail https://www.claws-mail
Log | Files | Refs | README | LICENSE

commit 53b36de8db2ed7d8b60d37afc544393e9cb603cd
parent 8eadc80ce1e3ca3b0168f86f8c4f7bc29165d585
Author: Colin Leroy <colin@colino.net>
Date:   Fri, 13 Nov 2015 09:46:16 +0100

Better fix for buffer overrun

Diffstat:
Msrc/plugins/clamd/libclamd/clamd-plugin.c | 6++----
1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/src/plugins/clamd/libclamd/clamd-plugin.c b/src/plugins/clamd/libclamd/clamd-plugin.c @@ -368,8 +368,7 @@ Clamd_Stat clamd_init(Clamd_Socket* config) { return NO_CONNECTION; } memset(buf, '\0', sizeof(buf)); - while ((n_read = read(sock, buf, BUFSIZ)) > 0) { - n_read = n_read < BUFSIZ ? n_read : BUFSIZ - 1; + while ((n_read = read(sock, buf, BUFSIZ - 1)) > 0) { buf[n_read] = '\0'; if (buf[strlen(buf) - 1] == '\n') buf[strlen(buf) - 1] = '\0'; @@ -526,8 +525,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) { - n_read = n_read < BUFSIZ ? n_read : BUFSIZ - 1; + while ((n_read = read(sock, buf, BUFSIZ - 1)) > 0) { buf[n_read] = '\0'; if (buf[strlen(buf) - 1] == '\n') buf[strlen(buf) - 1] = '\0';