From: Jo-Philipp Wich Date: Sat, 25 Jan 2020 12:57:01 +0000 (+0100) Subject: libopkg: fix skipping of leading whitespace when parsing checksums X-Git-Url: https://git.librecmc.org/?a=commitdiff_plain;h=c09fe2098718807ddbca13ee36e3e38801822946;p=oweals%2Fopkg-lede.git libopkg: fix skipping of leading whitespace when parsing checksums Signed-off-by: Jo-Philipp Wich --- diff --git a/libopkg/file_util.c b/libopkg/file_util.c index 61ff736..7e955ed 100644 --- a/libopkg/file_util.c +++ b/libopkg/file_util.c @@ -235,7 +235,7 @@ char *checksum_hex2bin(const char *src, size_t *len) { size_t slen; unsigned char *p; - const unsigned char *s = (unsigned char *)src; + const unsigned char *s; static unsigned char buf[32]; if (!src) { @@ -253,7 +253,7 @@ char *checksum_hex2bin(const char *src, size_t *len) return NULL; } - for (p = buf, *len = 0; + for (s = (unsigned char *)src, p = buf, *len = 0; slen > 0 && isxdigit(s[0]) && isxdigit(s[1]); slen--, s += 2, (*len)++) *p++ = hex2bin(s[0]) * 16 + hex2bin(s[1]);