From: David Levine Date: Thu, 2 May 2013 01:40:55 +0000 (-0500) Subject: Fixed problem with m_getfld() with long headers reported by X-Git-Url: https://diplodocus.org/git/nmh/commitdiff_plain/0c7ac5073c24f01663fadc78b5112c86d52e4452?ds=inline;hp=-c Fixed problem with m_getfld() with long headers reported by Paul Fox. The problem occurred with the 512th byte of the header was a newline: it then skipped the next character. --- 0c7ac5073c24f01663fadc78b5112c86d52e4452 diff --git a/sbr/m_getfld.c b/sbr/m_getfld.c index f84d2933..f19f7f11 100644 --- a/sbr/m_getfld.c +++ b/sbr/m_getfld.c @@ -635,7 +635,13 @@ m_getfld (m_getfld_state_t *gstate, char name[NAMESZ], char *buf, int *bufsz, if (c != EOF) c = Peek (s); if (max < n) { - /* the dest buffer is full */ + /* The dest buffer is full. Need to back the read + pointer up by one because when m_getfld() is + reentered, it will read a character. Then + we'll jump right to the FLDPLUS handling code, + which will not store that character, but + instead move on to the next one. */ + if (s->readpos > s->msg_buf) --s->readpos; s->state = FLDPLUS; finished = 1; } else if (c != ' ' && c != '\t') { diff --git a/test/inc/test-inc-scanout b/test/inc/test-inc-scanout index 87335d52..491a520f 100755 --- a/test/inc/test-inc-scanout +++ b/test/inc/test-inc-scanout @@ -297,6 +297,42 @@ run_test 'scan -width 80 -file '"$MH_TEST_DIR"'/mess' \ ' 1 01/16 No Such User FLDPLUS test' rm -f "$MH_TEST_DIR/mess" +# check inc of message with header field body with more than 511 characters +cat >"$expected" < +To: Some Other User +Subject: FLDPLUS test +Date: Wed, 16 Jan 2013 20:33:58 -0600 +EOF + +cat >"$MH_TEST_DIR/mess" < +To: Some Other User +Subject: FLDPLUS test +Date: Wed, 16 Jan 2013 20:33:58 -0600 + +EOF +inc -file "$MH_TEST_DIR/mess" >/dev/null +check "$expected" `mhpath last` || rmm last +rm -f "$MH_TEST_DIR/mess" + # check scan and inc of mbox with multiple messages echo y | packf -file "$MH_TEST_DIR/msgbox" run_test "scan -width 80 -file $MH_TEST_DIR/msgbox" \