]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
BIO_dump_indent_cb(): Check for negative return from BIO_snprintf()
authorTomas Mraz <tomas@openssl.org>
Fri, 25 Apr 2025 08:04:37 +0000 (10:04 +0200)
committerTomas Mraz <tomas@openssl.org>
Mon, 28 Apr 2025 15:29:17 +0000 (17:29 +0200)
In practice this cannot happen but Coverity complains.

Fixes Coverity 1646683

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Saša Nedvědický <sashan@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/27493)

crypto/bio/bio_dump.c

index 40c18410e4cf073f7f65530a8967eb5600e655ce..a566a9efe48f7c2c5b102fa0041d3dd90d5f968c 100644 (file)
@@ -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) {