aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSimon Glass <sjg@chromium.org>2021-07-24 09:03:28 -0600
committerTom Rini <trini@konsulko.com>2021-08-02 13:31:32 -0400
commit031725f8cdf33e836d19f35d3fe82c5baa5a2976 (patch)
tree011d6f7d748bdc87fd5efcac5c8df758505cbc37
parent73994c452fc5a960114360a651201ac48b135e81 (diff)
downloadu-boot-031725f8cdf33e836d19f35d3fe82c5baa5a2976.zip
u-boot-031725f8cdf33e836d19f35d3fe82c5baa5a2976.tar.gz
u-boot-031725f8cdf33e836d19f35d3fe82c5baa5a2976.tar.bz2
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>
-rw-r--r--common/hash.c2
1 files changed, 1 insertions, 1 deletions
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 @@ 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);
}