--- imap/src/c-client/mail.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) Index: alpine-2.11/imap/src/c-client/mail.c =================================================================== --- alpine-2.11.orig/imap/src/c-client/mail.c +++ alpine-2.11/imap/src/c-client/mail.c @@ -3361,13 +3361,13 @@ unsigned long mail_filter (char *text,un long flags) { STRINGLIST *hdrs; - int notfound; + int notfound, fix = text[len - 1] == '\0'; unsigned long i; char c,*s,*e,*t,tmp[MAILTMPLEN]; char *src = text; char *dst = src; char *end = text + len; - text[len] = '\012'; /* guard against running off buffer */ + text[fix ? len - 1 : len] = '\012'; /* guard against running off buffer */ while (src < end) { /* process header */ /* slurp header line name */ for (s = src,e = s + MAILTMPLEN - 1,e = (e < end ? e : end),t = tmp; @@ -3406,6 +3406,10 @@ unsigned long mail_filter (char *text,un } } *dst = '\0'; /* tie off destination */ + if(fix){ + text[len] = '\012'; + text[len-1] = '\0'; + } return dst - text; }