mirror of
https://git.codelinaro.org/clo/qsdk/oss/boot/u-boot-2016.git
synced 2026-03-14 21:10:27 +01:00
libfdt: Fix segfault when calling fit_check_format() on corrupt FIT images
It has been observed that fit_check_format() will fail when passed a corrupt FIT image. This was tracked down to _fdt_string_eq(): return (strlen(p) == len) && (memcmp(p, s, len) == 0); In the case of a corrupt FIT image one can't depend on 'p' being NULL terminated. I changed it to use strnlen() to fix the issue. Signed-off-by: Tom Rini <trini@ti.com>
This commit is contained in:
parent
f1329c9003
commit
af67b25250
1 changed files with 1 additions and 1 deletions
|
|
@ -44,7 +44,7 @@ static int _fdt_string_eq(const void *fdt, int stroffset,
|
|||
{
|
||||
const char *p = fdt_string(fdt, stroffset);
|
||||
|
||||
return (strlen(p) == len) && (memcmp(p, s, len) == 0);
|
||||
return (strnlen(p, len + 1) == len) && (memcmp(p, s, len) == 0);
|
||||
}
|
||||
|
||||
int fdt_get_mem_rsv(const void *fdt, int n, uint64_t *address, uint64_t *size)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue