Commit 031725f8 authored by Simon Glass's avatar Simon Glass Committed by Tom Rini
Browse files

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's avatarSimon Glass <>
parent 73994c45
......@@ -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);
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment