Fix chkmail loop break condition
PATCH 1/1 Fix chkmail loop break condition
padvance_magic() returns -1 when there are no more paths left, not zero.
--- src/mail.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
src/mail.c +1 -1
@@ -80,7 +80,7 @@ chkmail(void)int len; len =padvance_magic (&mpath, nullstr,2 ); -if (!len) +if (len ==-1 )break ; p =stackblock ();if (*p =='\0' )
Signature · 1 line
2.33.0
For some more context which you may want to add to the commit
message: I noticed dash would always print “you have mail” three times, and this fixes that. On further investigation, this loop was taking the last path in MAILPATH (or the only string in MAIL) and continuing to chop off the last character, so for MAIL=/var/mail/june, it would stat:
/var/mail/june/var/mail/jun/var/mail/ju/var/mail/j/var/mail//var/mail/var/mai/var/ma/var/m/var/
And then stop because MAXMBOXES is 10. The three “you have mail” messages were from /var/mail/june, /var/mail/ and /var/mail.
Quoted 5 lines · C. McEnroe
padvance_magic()returns -1 when there are no more paths left, not zero.--- src/mail.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
Patch applied with a change to check len < 0 instead. Thanks.
Signature · 3 lines
Email: Herbert Xu <[email protected]> Home Page: http://gondor.apana.org.au/~herbert/ PGP Key: http://gondor.apana.org.au/~herbert/pubkey.txt