]> git.ipfire.org Git - thirdparty/openssl.git/commitdiff
Update IPAddressOrRange_cmp function to handle switch case
authorVikas Verma <131862931+vikasverma4795@users.noreply.github.com>
Mon, 18 Dec 2023 13:28:25 +0000 (18:58 +0530)
committerTomas Mraz <tomas@openssl.org>
Tue, 19 Dec 2023 17:24:21 +0000 (18:24 +0100)
As there is no default case for a->type or b->type in the switch()
statements, if the type does not fall into any defined cases
then memcmp() will be done on garbage data.

Adding default cases in both switches.

CLA: trivial

Reviewed-by: Tom Cosgrove <tom.cosgrove@arm.com>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/23082)

crypto/x509/v3_addr.c

index b990d54048e6b387a88076d91d710c87f008a784..da9604cf963a3f138a9c4190681ce6f24b4d4c8d 100644 (file)
@@ -300,6 +300,8 @@ static int IPAddressOrRange_cmp(const IPAddressOrRange *a,
             return -1;
         prefixlen_a = length * 8;
         break;
+    default:
+        return -1;
     }
 
     switch (b->type) {
@@ -313,6 +315,8 @@ static int IPAddressOrRange_cmp(const IPAddressOrRange *a,
             return -1;
         prefixlen_b = length * 8;
         break;
+    default:
+        return -1;
     }
 
     if ((r = memcmp(addr_a, addr_b, length)) != 0)