Update IPAddressOrRange_cmp function to handle switch case

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)
This commit is contained in:
Vikas Verma 2023-12-18 18:58:25 +05:30 committed by Tomas Mraz
parent b46de72c26
commit a8df565115

View 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)