upstream: Fix bounds checking when signing messages of length

greater than will fit in a size_t. In OpenSSH, messages sizes are bounded by
SSHBUF_SIZE_MAX so this was unreachable. From Swival scanner.

OpenBSD-Commit-ID: 31ab874abe21a528fa995d78023c5ad9444a31e1
This commit is contained in:
2026-06-29 12:19:49 +10:00
committed by Damien Miller
parent c58b363e4f
commit 1cfbed8a13
+5 -1
View File
@@ -1,4 +1,4 @@
/* $OpenBSD: ed25519-openssl.c,v 1.2 2026/06/14 03:59:34 djm Exp $ */
/* $OpenBSD: ed25519-openssl.c,v 1.3 2026/06/29 02:08:55 djm Exp $ */
/*
* Copyright (c) 2025 OpenSSH
*
@@ -194,6 +194,10 @@ crypto_sign_ed25519_open(unsigned char *m, unsigned long long *mlen,
debug3_f("signed message bad length: %llu", smlen);
return -1;
}
if (smlen - crypto_sign_ed25519_BYTES > SIZE_MAX) {
debug3_f("signed message too long: %llu", smlen);
return -1;
}
/* Signature is first crypto_sign_ed25519_BYTES, message follows */
msg = sm + crypto_sign_ed25519_BYTES;
msglen = smlen - crypto_sign_ed25519_BYTES;