Commit 56c269eab4 for openssl.org
commit 56c269eab4e16b36b03e60ad8bdaad279a41de61
Author: Bob Beck <beck@openssl.org>
Date: Wed Jun 17 19:36:14 2026 -0600
Convert BIO_snprintf() in BIO_dump_indent_cb() to snprintf() and guard the offset.
Reviewed-by: Neil Horman <nhorman@openssl.org>
Reviewed-by: Andrew Dinh <andrewd@openssl.org>
MergeDate: Wed Aug 26 16:20:21 2026
(Merged from https://github.com/openssl/openssl/pull/31640)
diff --git a/crypto/bio/bio_dump.c b/crypto/bio/bio_dump.c
index 1c08c49e6b..28fc0c7400 100644
--- a/crypto/bio/bio_dump.c
+++ b/crypto/bio/bio_dump.c
@@ -45,9 +45,9 @@ int BIO_dump_indent_cb(int (*cb)(const void *data, size_t len, void *u),
if ((rows * dump_width) < len)
rows++;
for (i = 0; i < rows; i++) {
- n = BIO_snprintf(buf, sizeof(buf), "%*s%04x - ", indent, "",
+ n = snprintf(buf, sizeof(buf), "%*s%04x - ", indent, "",
i * dump_width);
- if (n < 0)
+ if (n < 0 || (size_t)n >= sizeof(buf))
return -1;
for (j = 0; j < dump_width; j++) {
if (SPACE(buf, n, 3)) {