From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on inbox.vuxu.org X-Spam-Level: X-Spam-Status: No, score=0.2 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED autolearn=no autolearn_force=no version=3.4.4 Received: (qmail 10959 invoked from network); 8 Feb 2021 05:40:17 -0000 Received: from 1ess.inri.net (216.126.196.35) by inbox.vuxu.org with ESMTPUTF8; 8 Feb 2021 05:40:17 -0000 Received: from mail-pj1-f53.google.com ([209.85.216.53]) by 1ess; Sun Feb 7 17:59:38 -0500 2021 Received: by mail-pj1-f53.google.com with SMTP id q72so7193673pjq.2 for <9front@9front.org>; Sun, 07 Feb 2021 14:59:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mforney-org.20150623.gappssmtp.com; s=20150623; h=message-id:mime-version:content-transfer-encoding:to:from:date :subject; bh=DUt7fUZ6RgzW9FK6M5q832Fi+qNh0QmOC4ddxMcy+V4=; b=O5VZobr4WUzKwGmHmbIPLpdN+8yuF0zPfQrzQRKZ5BK8zyg3YJKLn3Heb0ZiXzKrdy pORGkD6SUGLtN6au78C7GuiletPocr1pbWI+6+3+tdal1cRRbhxxp7Au+1VATQo084me TW23sYx9ty2IUBoTzeqY0PJJkSu1L7csERTArjd5l2BmjnAEfLwDF7Di0lMDiDj9Vtq7 lqAt4WV4dQzxVZvp0qX2Rd0HC/4LDKUSHHx+teAEunWGbJxFFOBLnswQTgD/pp/WvkVn aHcfIivg5dPPdKbdnwFNpXMpEmM/7XWHewCAPdi6e+mylzui9kbcEkJL9G9Rr1U0lL9u MHUg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:mime-version :content-transfer-encoding:to:from:date:subject; bh=DUt7fUZ6RgzW9FK6M5q832Fi+qNh0QmOC4ddxMcy+V4=; b=mDCYE/m5Ay1hcyLEKsvc5PpjTEVRPINb4Z2LAhaP5JbDQsyrlK3p/yucNiDR+q0TCv xP35ayXNA37988b8qI8zI1PvmG0zl3XF1SYLF6gm5IKHprjDYivEB+kboRDmw8riTKbw R7QKO2c3iEjNG1Knhkdrtke9ASQCgrC6JFe6ee7whv1nAOwtQrXoTjjWDOm8NFBh1DVB 4qaZ4uLrGNLBjFaPyxSapfZqbJZjrVgW2inwuNsYp+7my8ad7uDP5IKj1kQwh6m7+7+Z wPKT48+xrQ7zQnCtlh8V3lwPwbyeyejpSfa5Le2hrSAmwPZDxZvdQvDNiBfCQ2aGrnUj 0JuQ== X-Gm-Message-State: AOAM531ncx9gsla6xIVT8kKVgMrimGZzbtk6CFVN39sJiKq+WMyBqs0n RFq9KbiR3a0hPs17pj9m7exuXzaLKm1snDm/seY= X-Google-Smtp-Source: ABdhPJynFfNLtXUotp7U7GLiTtV1keZFFpxukWghF7pv//Y1U5Z1exXE/ZdY6OfyEHuzdIsoUQHFHQ== X-Received: by 2002:a17:90a:8a8f:: with SMTP id x15mr13846653pjn.95.1612738764631; Sun, 07 Feb 2021 14:59:24 -0800 (PST) Return-Path: Received: from arrow.hsd1.ca.comcast.net (c-73-70-188-119.hsd1.ca.comcast.net. [73.70.188.119]) by smtp.gmail.com with ESMTPSA id z8sm16521819pfr.161.2021.02.07.14.59.24 for <9front@9front.org> (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Sun, 07 Feb 2021 14:59:24 -0800 (PST) Message-ID: <27181C9019661A8C2B9EF7451B7E1CA7@arrow.hsd1.ca.comcast.net> MIME-Version: 1.0 Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8bit To: 9front@9front.org From: Michael Forney Date: Sun, 07 Feb 2021 22:51:05 +0000 List-ID: <9front.9front.org> List-Help: X-Glyph: ➈ X-Bullshit: descriptor information NoSQL cloud locator Subject: [9front] upas/vf: exclude mime boundary from temporary attachment files Reply-To: 9front@9front.org Precedence: bulk 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);