X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?a=blobdiff_plain;f=lib%2Fsha1.c;h=3b16622df8069821d985a9e455dc76783be33f47;hb=f9ef1c31cfcd2d9ded66588a11c59e29e5aaa2ca;hp=205b82fe0f5f5c83d78c429d551ed10864e296dc;hpb=a0bc29a541fc7dc6e20137d5558e2094d614e6ab;p=openvswitch diff --git a/lib/sha1.c b/lib/sha1.c index 205b82fe..3b16622d 100644 --- a/lib/sha1.c +++ b/lib/sha1.c @@ -1,7 +1,7 @@ /* * This file is from the Apache Portable Runtime Library. * The full upstream copyright and license statement is included below. - * Modifications copyright (c) 2009 Nicira Networks. + * Modifications copyright (c) 2009, 2010 Nicira Networks. */ /* Licensed to the Apache Software Foundation (ASF) under one or more @@ -301,10 +301,12 @@ sha1_from_hex(uint8_t digest[SHA1_DIGEST_SIZE], const char *hex) int i; for (i = 0; i < SHA1_DIGEST_SIZE; i++) { - if (!isxdigit(hex[0]) || !isxdigit(hex[1])) { + bool ok; + + digest[i] = hexits_value(hex, 2, &ok); + if (!ok) { return false; } - digest[i] = (hexit_value(hex[0]) << 4) | hexit_value(hex[1]); hex += 2; } return true;