file_util.c: refactor and fix checksum_hex2bin()
authorJo-Philipp Wich <jo@mein.io>
Wed, 1 Apr 2020 11:41:37 +0000 (13:41 +0200)
committerJo-Philipp Wich <jo@mein.io>
Wed, 1 Apr 2020 11:41:37 +0000 (13:41 +0200)
commit60b9af29ae864d5af034b31058cb40d2c3271549
treebcd7409713e398a0154c21dab1532c0ac2904987
parent206ebaea2cd547fbc180d61279bfd2e80a0dc3dd
file_util.c: refactor and fix checksum_hex2bin()

 - Simplify function body by reducing the amount of intermediate vars
 - Derive length checks from the size of the buf
 - Replace complex for(;;) by a simple while() advancing the src string
 - Handle edge case of a zero length input not returning NULL

Fixes: c09fe20 ("libopkg: fix skipping of leading whitespace when parsing checksums")
Signed-off-by: Jo-Philipp Wich <jo@mein.io>
libopkg/file_util.c