[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
This commit is contained in:
Tony Tung 2016-08-02 15:35:49 -07:00
parent c0e7082b92
commit a7555791cd

View File

@ -8,10 +8,9 @@
#define __FASTMANIFEST_CONVERT_H__
#include <stdbool.h>
#include <stddef.h>
#include <stdint.h>
#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;
}