Skip to content
/ src Public

Commit b529354

Browse files
committed
validate encrypted queue buffer sizes before processing auth tag and IV data:
current callers already treat malformed input as a decrypt failure but rejecting truncated buffers earlier makes boundary conditions more explicit. diff by Stuart Thomas <stuart.thomas@triageforge.co.uk>
1 parent afc0fdd commit b529354

1 file changed

Lines changed: 5 additions & 3 deletions

File tree

usr.sbin/smtpd/crypto.c

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* $OpenBSD: crypto.c,v 1.10 2021/06/14 17:58:15 eric Exp $ */
1+
/* $OpenBSD: crypto.c,v 1.11 2026/05/26 22:39:33 gilles Exp $ */
22

33
/*
44
* Copyright (c) 2013 Gilles Chehade <gilles@openbsd.org>
@@ -274,8 +274,10 @@ crypto_decrypt_buffer(const char *in, size_t inlen, char *out, size_t outlen)
274274
int len = 0;
275275
int ret = 0;
276276

277-
/* out does not have enough room */
278-
if (outlen < inlen - sizeof tag + sizeof iv)
277+
/* input buffer too small or out does not have enough room */
278+
if (inlen < sizeof(tag) + sizeof(iv) + 1)
279+
return 0;
280+
if (outlen < inlen - sizeof(tag) - sizeof(iv) - 1)
279281
return 0;
280282

281283
/* extract tag */

0 commit comments

Comments
 (0)