From: Dmitry Bogatov Date: Fri, 26 Aug 2016 23:03:28 +0000 (+0300) Subject: Fix out-of-bounds error when incorporating email from stdin X-Git-Tag: mmh-0.4~74 X-Git-Url: http://git.marmaro.de/?a=commitdiff_plain;h=88b2142594d5ea1e8385dae5eca81eed1018c555;p=mmh Fix out-of-bounds error when incorporating email from stdin Before this patch, if +inbox is empty, following error happened: $ inc -file - < /dev/null Incorporating new mail into inbox... inc: no messages incorporated, continuing... inc: Bug: message out of bounds This happened due improper call to `seq_setunseen', which implicitly assumed that there is at least one message (it does not handle case where both mp->hghmsg and mh->lowmsg are 0). Bug does not happens with command `inc -file empty', since file is checked for being empty before any read attempts. Signed-off-by: Dmitry Bogatov --- diff --git a/sbr/seq_setunseen.c b/sbr/seq_setunseen.c index d833650..bd57a2c 100644 --- a/sbr/seq_setunseen.c +++ b/sbr/seq_setunseen.c @@ -23,6 +23,10 @@ seq_setunseen(struct msgs *mp, int doadd) int n; char **ap, *cp, *dp; + if (mp->lowmsg == 0) { + return; + } + /* ** Get the list of sequences for Unseen-Sequence ** and split them. diff --git a/test/tests/inc/test-read-stdin b/test/tests/inc/test-read-stdin index d771d32..96c4e4a 100644 --- a/test/tests/inc/test-read-stdin +++ b/test/tests/inc/test-read-stdin @@ -64,3 +64,13 @@ Incorporating new mail into inbox... ! rm "$f" unset f + +runandcheck "folder +inc-testfolder" <