Skip to content
/ src Public

Commit 2c717ae

Browse files
committed
Zero the temporary envelope parsing buffers before use.
While current parsing paths do not expose uninitialized data, keeping stack residue in these transient buffers unnecessarily weakens compartmentalization and may aid lateral movement inside the privsep environment after another bug. The diff also fixes a theoretical double close race bug which can't really happen in smtpd due to requiring concurrency in our single threaded event loop, and which would have very limited reliability impact if it was triggered (forcing a mail to fail on a schedule tick and be retried at next tick). This is still incorrect so let's avoid a copy of this code in more problematic places. diff by Stuart Thomas <stuart.thomas@triageforge.co.uk>
1 parent c2e63d9 commit 2c717ae

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

usr.sbin/smtpd/queue_backend.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $OpenBSD: queue_backend.c,v 1.69 2023/05/31 16:51:46 op Exp $ */
1+
/* $OpenBSD: queue_backend.c,v 1.70 2026/05/26 22:44:17 gilles Exp $ */
22

33
/*
44
* Copyright (c) 2011 Gilles Chehade <gilles@poolp.org>
@@ -309,6 +309,7 @@ queue_message_fd_r(uint32_t msgid)
309309
fd = -1;
310310
if ((ofp = fdopen(fdout, "w+")) == NULL)
311311
goto err;
312+
fdout = -1;
312313

313314
if (!crypto_decrypt_file(ifp, ofp))
314315
goto err;
@@ -331,6 +332,7 @@ queue_message_fd_r(uint32_t msgid)
331332
fd = -1;
332333
if ((ofp = fdopen(fdout, "w+")) == NULL)
333334
goto err;
335+
fdout = -1;
334336

335337
if (!uncompress_file(ifp, ofp))
336338
goto err;
@@ -414,6 +416,8 @@ queue_envelope_load_buffer(struct envelope *ep, char *evpbuf, size_t evpbufsize)
414416
char encbuf[sizeof(struct envelope)];
415417
size_t enclen;
416418

419+
memset(compbuf, 0, sizeof compbuf);
420+
memset(encbuf, 0, sizeof encbuf);
417421
evp = evpbuf;
418422
evplen = evpbufsize;
419423

0 commit comments

Comments
 (0)