Avoid possible divide by zero
authorTomas Mraz <tomas@openssl.org>
Tue, 27 Dec 2022 10:22:05 +0000 (11:22 +0100)
committerTomas Mraz <tomas@openssl.org>
Wed, 4 Jan 2023 15:52:00 +0000 (16:52 +0100)
Backport of commit 624efd2

Reviewed-by: Hugo Landau <hlandau@openssl.org>
Reviewed-by: Richard Levitte <levitte@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/19967)

(cherry picked from commit 8c29e5ebfd5f19442422ba43fea4c95816417e34)

ssl/record/ssl3_record.c

index dcaaeef951aa912e4bbf3b17e833a00991f28bfb..368aaea5e9fe1df4d412f8a5273843c51c924eef 100644 (file)
@@ -1314,7 +1314,7 @@ int n_ssl3_mac(SSL *ssl, SSL3_RECORD *rec, unsigned char *md, int sending)
     }
 
     t = EVP_MD_CTX_get_size(hash);
-    if (t < 0)
+    if (t <= 0)
         return 0;
     md_size = t;
     npad = (48 / md_size) * md_size;