From: Michael Forney <mforney@mforney.org>
To: 9front@9front.org
Subject: [9front] upas/vf: exclude mime boundary from temporary attachment files
Date: Sun, 07 Feb 2021 22:51:05 +0000 [thread overview]
Message-ID: <27181C9019661A8C2B9EF7451B7E1CA7@arrow.hsd1.ca.comcast.net> (raw)
validateattachment has no business with the mime boundary; it is not
part of the attachment itself.
Also, it causes the boundary to be dropped in the message output from
upas/vf, effectively dropping the following attachment (though the
content is still present after the last boundary of the wrapped first
attachment part).
Consider the following sequence of events:
1. upas/vf is run on a message containing two attachments.
2. The first attachment does not have a known extension, so is saved
to a temporary file *including* the following mime boundary.
3. This file is opened as p->tmpbuf, which is used for subsequent
reads until switching back to stdin.
4. The attachment fails validateattachment, so upas/vf wraps it in a
multipart with a warning message.
5. problemchild() calls passbody(p, 0), which copies from p->tmpbuf
until it hits the outer boundary line, which it excludes, seeks
back one line, then returns the outer multipart.
6. problemchild() then writes its own boundary, and then copies one
line from *stdin* to stdout, expecting the outer boundary.
However, this boundary was already read from stdin in 2, so it ends
up reading the first line of the subsequent part instead.
To fix this, pass 0 to passbody() in save() to exclude it from the
attachment file and make it available in stdin when expected.
diff 776cb37fd6894d9e73b252d60f386d3cfb7c876c 7316cf014f78ae5b777152f50c3ebbb7da5b82e8
--- a/sys/src/cmd/upas/vf/vf.c Sun Feb 7 01:22:23 2021
+++ b/sys/src/cmd/upas/vf/vf.c Sun Feb 7 14:51:05 2021
@@ -387,7 +387,7 @@
Bprint(&out, "From virusfilter %τ\n", thedate(&tm));
writeheader(p, 0);
bodyoff = Boffset(&out);
- passbody(p, 1);
+ passbody(p, 0);
Bprint(&out, "\n");
Bterm(&out);
close(fd);
reply other threads:[~2021-02-08 5:40 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=27181C9019661A8C2B9EF7451B7E1CA7@arrow.hsd1.ca.comcast.net \
--to=mforney@mforney.org \
--cc=9front@9front.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).