From 49445f21da5ad436a117d0d4cc6220c4bbbbf8a7 Mon Sep 17 00:00:00 2001 From: Rich Salz Date: Thu, 12 May 2016 15:52:58 -0400 Subject: Use OPENSSL_hexchar2int Reviewed-by: Richard Levitte --- test/danetest.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) (limited to 'test/danetest.c') diff --git a/test/danetest.c b/test/danetest.c index 3bcc02e504..75bcb58f30 100644 --- a/test/danetest.c +++ b/test/danetest.c @@ -198,7 +198,7 @@ static STACK_OF(X509) *load_chain(BIO *fp, int nelem) fprintf(stderr, "error reading: malformed %s\n", errtype); goto err; } - + if (count == nelem) { ERR_clear_error(); return chain; @@ -252,19 +252,16 @@ static ossl_ssize_t hexdecode(const char *in, void *result) return -1; for (byte = 0; *in; ++in) { - char c; + int x; if (isspace(_UC(*in))) continue; - c = tolower(_UC(*in)); - if ('0' <= c && c <= '9') { - byte |= c - '0'; - } else if ('a' <= c && c <= 'f') { - byte |= c - 'a' + 10; - } else { + x = OPENSSL_hexchar2int(*in); + if (x < 0) { OPENSSL_free(ret); return 0; } + byte |= (char)x; if ((nibble ^= 1) == 0) { *cp++ = byte; byte = 0; -- cgit v1.2.3