diff options
author | Michael Forney <mforney@mforney.org> | 2022-10-29 23:06:58 +0000 |
---|---|---|
committer | Michael Forney <mforney@mforney.org> | 2022-10-29 23:06:58 +0000 |
commit | 82435c350a1d3530c87ea88ada68e984fc6b9b80 (patch) | |
tree | 7e56744cac60dd6fadb5b26e24a63aaed44f5966 /sys/src/cmd/upas | |
parent | 7d108832528eb1ee85a445a562c00b5a8344d882 (diff) |
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.
Diffstat (limited to 'sys/src/cmd/upas')
-rw-r--r-- | sys/src/cmd/upas/fs/plan9.c | 11 |
1 files changed, 7 insertions, 4 deletions
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); |