hash: Ensure verification hex pairs are terminated
This function seems to assume that the chr[] variable contains zeros at
the start, which is not always true. Use strlcpy() to be safe.
Signed-off-by: Simon Glass <sjg@chromium.org>
diff --git a/common/hash.c b/common/hash.c
index 90cf46b..059d381 100644
--- a/common/hash.c
+++ b/common/hash.c
@@ -396,7 +396,7 @@
for (i = 0; i < algo->digest_size; i++) {
char chr[3];
- strncpy(chr, &str[i * 2], 2);
+ strlcpy(chr, &str[i * 2], 3);
result[i] = simple_strtoul(chr, NULL, 16);
}