]> git.ipfire.org Git - thirdparty/openssl.git/blobdiff - crypto/x509v3/v3_utl.c
Use OPENSSL_hexchar2int
[thirdparty/openssl.git] / crypto / x509v3 / v3_utl.c
index ae9645d6873a483e972eb9b2a11183c48bda737b..a5016bad766a8e03612a8cf1823fa77320012a6e 100644 (file)
@@ -1177,19 +1177,17 @@ static int ipv6_hex(unsigned char *out, const char *in, int inlen)
 {
     unsigned char c;
     unsigned int num = 0;
+    int x;
+
     if (inlen > 4)
         return 0;
     while (inlen--) {
         c = *in++;
         num <<= 4;
-        if ((c >= '0') && (c <= '9'))
-            num |= c - '0';
-        else if ((c >= 'A') && (c <= 'F'))
-            num |= c - 'A' + 10;
-        else if ((c >= 'a') && (c <= 'f'))
-            num |= c - 'a' + 10;
-        else
+        x = OPENSSL_hexchar2int(c);
+        if (x < 0)
             return 0;
+        num |= (char)x;
     }
     out[0] = num >> 8;
     out[1] = num & 0xff;