X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=lib%2Fsha1.c;h=cdccab3bfa6e52e5c623e1dfa1ff8c04178dffc3;hb=d0040604727e1582abbc28fa62903a822453c99f;hp=205b82fe0f5f5c83d78c429d551ed10864e296dc;hpb=a4af00400a835eb87569ba40e21874c05e872c0f;p=sliver-openvswitch.git diff --git a/lib/sha1.c b/lib/sha1.c index 205b82fe0..cdccab3bf 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 @@ -33,6 +33,7 @@ #include "sha1.h" #include #include +#include "compiler.h" #include "util.h" /* a bit faster & bigger, if defined */ @@ -150,12 +151,12 @@ sha_transform(struct sha1_ctx *sha_info) /* 'count' is the number of bytes to do an endian flip. */ static void -maybe_byte_reverse(uint32_t *buffer, int count) +maybe_byte_reverse(uint32_t *buffer OVS_UNUSED, int count OVS_UNUSED) { +#if !WORDS_BIGENDIAN int i; uint8_t ct[4], *cp; -#if !WORDS_BIGENDIAN count /= sizeof(uint32_t); cp = (uint8_t *) buffer; for (i = 0; i < count; i++) { @@ -301,10 +302,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;