From a7555791cd729c0eb4edbfafa78c56a5c2b2a5f3 Mon Sep 17 00:00:00 2001 From: Tony Tung Date: Tue, 2 Aug 2016 15:35:49 -0700 Subject: [PATCH] [fastmanifest] fix unhexlify Summary: Strictly speaking, it doesn't care if it's the length is SHA1_BYTES * 2. It just has to be even. Also, size_t comes from stddef.h. Test Plan: make local Reviewers: durham, lcharignon Subscribers: mitrandir, mjpieters Differential Revision: https://phabricator.intern.facebook.com/D3626828 --- cfastmanifest/convert.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/cfastmanifest/convert.h b/cfastmanifest/convert.h index 109b2efe54..00b69b6eda 100644 --- a/cfastmanifest/convert.h +++ b/cfastmanifest/convert.h @@ -8,10 +8,9 @@ #define __FASTMANIFEST_CONVERT_H__ #include +#include #include -#include "node.h" - static int8_t hextable[256] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, @@ -40,7 +39,7 @@ static char chartable[16] = { * Turn a hex-encoded string into binary. Returns false on failure. */ static inline bool unhexlify(const char *input, int len, uint8_t *dst) { - if (len != SHA1_BYTES * 2) { + if (len % 2 != 0) { // wtf. return false; }