From: David Levine Date: Thu, 5 Dec 2013 02:30:04 +0000 (-0600) Subject: Fixed m_getfld() bug introduced in commit X-Git-Url: https://diplodocus.org/git/nmh/commitdiff_plain/86d3f54edebc4ed9f923b6b8ef175aebdc60989b?ds=sidebyside;hp=-c Fixed m_getfld() bug introduced in commit 0c7ac5073c24f01663fadc78b5112c86d52e4452. This bug caused parsing of messages with long (>= 8K) header field values to fail. The fix was easy: decrement the counter of bytes read when decrementing the current read position, in FLDPLUS state. --- 86d3f54edebc4ed9f923b6b8ef175aebdc60989b diff --git a/sbr/m_getfld.c b/sbr/m_getfld.c index f19f7f11..9884ba44 100644 --- a/sbr/m_getfld.c +++ b/sbr/m_getfld.c @@ -636,12 +636,15 @@ 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. 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; + 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->bytes_read; + } s->state = FLDPLUS; finished = 1; } else if (c != ' ' && c != '\t') { diff --git a/test/mhlist/test-mhlist b/test/mhlist/test-mhlist index ad0fb4bb..b1d59d10 100755 --- a/test/mhlist/test-mhlist +++ b/test/mhlist/test-mhlist @@ -210,4 +210,158 @@ mhlist -nochangecur 1 >/dev/null run_test 'mark -sequence cur -list' 'cur: 11' +# check MIME parser and m_getfld +cat > $expected < $msgfile < $actual 2>&1 +check $expected $actual + + exit $failed