talons

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

commit 45c1dc4e6e39f9d5ac83816302d043b5dee565e6
parent e121fc4767e57fd6018997b75d636264049c9ce8
Author: wwp <subscript@free.fr>
Date:   Fri,  3 Sep 2021 09:32:46 +0200

CID1440023: use the number of bytes read() from bogofilter's stdout.

Diffstat:
Msrc/plugins/bogofilter/bogofilter.c | 7++++---
1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/src/plugins/bogofilter/bogofilter.c b/src/plugins/bogofilter/bogofilter.c @@ -208,6 +208,7 @@ static void bogofilter_do_filter(BogoFilterData *data) for (cur = data->msglist; cur; cur = cur->next) { gboolean whitelisted = FALSE; msginfo = (MsgInfo *)cur->data; + ssize_t n_read; debug_print("Filtering message %d (%d/%d)\n", msginfo->msgnum, curnum, total); if (message_callback != NULL) @@ -229,7 +230,7 @@ static void bogofilter_do_filter(BogoFilterData *data) g_free(tmp); memset(buf, 0, sizeof(buf)); /* get the result */ - if (read(bogo_stdout, buf, sizeof(buf)-1) < 0) { + if (n_read = read(bogo_stdout, buf, sizeof(buf)-1) < 0) { g_warning("bogofilter short read"); debug_print("message %d is ham\n", msginfo->msgnum); data->mail_filtering_data->unfiltered = g_slist_prepend( @@ -238,14 +239,14 @@ static void bogofilter_do_filter(BogoFilterData *data) } else { gchar **parts = NULL; - buf[sizeof(buf) - 1] = '\0'; + buf[n_read] = '\0'; if (strchr(buf, '/')) { tmp = strrchr(buf, '/')+1; } else { tmp = buf; } parts = g_strsplit(tmp, " ", 0); - debug_print("read %s\n", buf); + debug_print("read '%s' (%ld bytes)\n", buf, n_read); /* note the result if the header if needed */ if (parts && parts[0] && parts[1] && parts[2] &&