From: Simon Glass Date: Sat, 24 Jul 2021 15:03:28 +0000 (-0600) Subject: hash: Ensure verification hex pairs are terminated X-Git-Tag: baikal/mips/sdk5.9~15^2^2~173^2~10 X-Git-Url: https://git.baikalelectronics.ru/?a=commitdiff_plain;h=c386241a967cc738df0a26c2331280600a4f1cca;p=uboot.git 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 --- diff --git a/common/hash.c b/common/hash.c index 90cf46bcba..059d381e23 100644 --- a/common/hash.c +++ b/common/hash.c @@ -396,7 +396,7 @@ int hash_parse_string(const char *algo_name, const char *str, uint8_t *result) 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); }