From: Vikas Verma <131862931+vikasverma4795@users.noreply.github.com> Date: Mon, 18 Dec 2023 13:28:25 +0000 (+0530) Subject: Update IPAddressOrRange_cmp function to handle switch case X-Git-Tag: openssl-3.3.0-alpha1~453 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=a8df5651153e8e81fbaa8408dd1137232168997d;p=thirdparty%2Fopenssl.git 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 Reviewed-by: Tomas Mraz (Merged from https://github.com/openssl/openssl/pull/23082) --- diff --git a/crypto/x509/v3_addr.c b/crypto/x509/v3_addr.c index b990d54048e..da9604cf963 100644 --- a/crypto/x509/v3_addr.c +++ b/crypto/x509/v3_addr.c @@ -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)