]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
Fix coverity 1516093 tainted scalar
authorTodd Short <tshort@akamai.com>
Wed, 19 Oct 2022 14:12:57 +0000 (10:12 -0400)
committerPauli <pauli@openssl.org>
Thu, 20 Oct 2022 23:33:40 +0000 (10:33 +1100)
Reviewed-by: Tomas Mraz <tomas@openssl.org>
Reviewed-by: Paul Dale <pauli@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/19440)

ssl/t1_trce.c

index 1a032b3137e92ae6be27456d6b4fdcd5a5562a8d..4725185e79d0f40d862690ba00ab9e8bad56534c 100644 (file)
@@ -1334,7 +1334,10 @@ static int ssl_print_compressed_certificates(BIO *bio, const SSL_CONNECTION *sc,
     BIO_indent(bio, indent, 80);
     BIO_printf(bio, "Uncompressed length=%d\n", (int)uclen);
     BIO_indent(bio, indent, 80);
-    BIO_printf(bio, "Compressed length=%d, Ratio=%f:1\n", (int)clen, (float)uclen / (float)clen);
+    if (clen > 0)
+        BIO_printf(bio, "Compressed length=%d, Ratio=%f:1\n", (int)clen, (float)uclen / (float)clen);
+    else
+        BIO_printf(bio, "Compressed length=%d, Ratio=unknown\n", (int)clen);
 
     BIO_dump_indent(bio, (const char *)msg, clen, indent);
 
@@ -1342,7 +1345,7 @@ static int ssl_print_compressed_certificates(BIO *bio, const SSL_CONNECTION *sc,
     if (!ossl_comp_has_alg(alg))
         return 0;
 
-    if ((ucdata = OPENSSL_malloc(uclen)) == NULL)
+    if (uclen == 0 || (ucdata = OPENSSL_malloc(uclen)) == NULL)
         return 0;
 
     switch (alg) {