From 82435c350a1d3530c87ea88ada68e984fc6b9b80 Mon Sep 17 00:00:00 2001 From: Michael Forney Date: Sat, 29 Oct 2022 23:06:58 +0000 Subject: upas/fs: clear errstr after chkunix The readmessage loop clears errstr at start and expects it not to change unless there is a read error. However, strtotm may use multiple calls to tmparse while trying to determine the date format, which may leave errstr non-empty on success. Clear it after chkunix so that this doesn't get treated as a message read error. This also fixes handling of naked From lines, which were previously just warned about, but since the conversion to tmparse they accidentally triggered a message read failure. --- sys/src/cmd/upas/fs/plan9.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) (limited to 'sys/src') diff --git a/sys/src/cmd/upas/fs/plan9.c b/sys/src/cmd/upas/fs/plan9.c index 11fe1223a..dd56e0dcf 100644 --- a/sys/src/cmd/upas/fs/plan9.c +++ b/sys/src/cmd/upas/fs/plan9.c @@ -129,6 +129,7 @@ readmessage(Mailbox *mb, Message *m, Inbuf *b) { char *s, *n; long l, state; + int r; werrstr(""); state = 0; @@ -138,10 +139,12 @@ readmessage(Mailbox *mb, Message *m, Inbuf *b) break; n = s + (l = Blinelen(b->in)) - 1; if(l >= 28 + 7 && n[0] == '\n') - if(strncmp(s, "From ", 5) == 0) - if(!chkunix(s + 5, l - 5)) - if(++state == 2) - break; + if(strncmp(s, "From ", 5) == 0){ + r = chkunix(s + 5, l - 5); + werrstr(""); + if(r == 0 && ++state == 2) + break; + } if(state == 0) return -1; addtomessage(m, s, l); -- cgit v1.2.3