]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
Replace unsigned with int
authorJiasheng Jiang <jiasheng@purdue.edu>
Thu, 21 Mar 2024 19:55:34 +0000 (19:55 +0000)
committerTomas Mraz <tomas@openssl.org>
Mon, 25 Mar 2024 16:45:33 +0000 (17:45 +0100)
Replace the type of "digest_length" with int to avoid implicit conversion when it is assigned by EVP_MD_get_size().
Otherwise, it may pass the following check and cause the integer overflow error when EVP_MD_get_size() returns negative numbers.
Signed-off-by: Jiasheng Jiang <jiasheng@purdue.edu>
Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Tom Cosgrove <tom.cosgrove@arm.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/23922)

demos/digest/EVP_MD_demo.c
demos/digest/EVP_MD_stdin.c

index 8cf3bd8e7b8663205f2c4528e9ef61c8c3527310..dd0800c70b9b4da7e441e2da5f2ed76076012c56 100644 (file)
@@ -83,7 +83,7 @@ int demonstrate_digest(void)
     const char *option_properties = NULL;
     EVP_MD *message_digest = NULL;
     EVP_MD_CTX *digest_context = NULL;
-    unsigned int digest_length;
+    int digest_length;
     unsigned char *digest_value = NULL;
     int j;
 
index 11bffb6bcca88f015cdf35b0a2780c78fe91a941..948f99718136aa70c4432af068f178e9e63131dc 100644 (file)
@@ -38,7 +38,7 @@ int demonstrate_digest(BIO *input)
     const char *option_properties = NULL;
     EVP_MD *message_digest = NULL;
     EVP_MD_CTX *digest_context = NULL;
-    unsigned int digest_length;
+    int digest_length;
     unsigned char *digest_value = NULL;
     unsigned char buffer[512];
     int ii;