]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
Fix coverity-993406
authorNeil Horman <nhorman@openssl.org>
Wed, 24 Jul 2024 20:10:53 +0000 (16:10 -0400)
committerNeil Horman <nhorman@openssl.org>
Fri, 26 Jul 2024 17:16:10 +0000 (13:16 -0400)
Coverity flagged an overflow warning in the cmsapitest.

Its pretty insignificant, but if a huge file is passed in via BIO, its
possible for the length variable returned to overflow.

Just check it as we read to silence coverity on it.

Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Tom Cosgrove <tom.cosgrove@arm.com>
(Merged from https://github.com/openssl/openssl/pull/24995)

test/cmsapitest.c

index 5839eb74310aad1d89659eadb7701dec59bd0cf6..0684afd10e6a7db2dcb9184b04ae138507022329 100644 (file)
@@ -332,6 +332,9 @@ static unsigned char *read_all(BIO *bio, long *p_len)
         if (ret < 0)
             break;
 
+        if (LONG_MAX - ret < *p_len)
+            break;
+
         *p_len += ret;
 
         if (ret < step)