From 56c739816f3dacbb024ceae29c546abe677ee02c Mon Sep 17 00:00:00 2001 From: Tomas Mraz Date: Fri, 25 Apr 2025 10:04:37 +0200 Subject: [PATCH] BIO_dump_indent_cb(): Check for negative return from BIO_snprintf() MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit In practice this cannot happen but Coverity complains. Fixes Coverity 1646683 Reviewed-by: Matt Caswell Reviewed-by: Saša Nedvědický (Merged from https://github.com/openssl/openssl/pull/27493) --- crypto/bio/bio_dump.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/crypto/bio/bio_dump.c b/crypto/bio/bio_dump.c index 40c18410e4c..a566a9efe48 100644 --- a/crypto/bio/bio_dump.c +++ b/crypto/bio/bio_dump.c @@ -47,6 +47,8 @@ int BIO_dump_indent_cb(int (*cb) (const void *data, size_t len, void *u), for (i = 0; i < rows; i++) { n = BIO_snprintf(buf, sizeof(buf), "%*s%04x - ", indent, "", i * dump_width); + if (n < 0) + return -1; for (j = 0; j < dump_width; j++) { if (SPACE(buf, n, 3)) { if (((i * dump_width) + j) >= len) { -- 2.47.2