mirror of
https://github.com/dgibson/dtc.git
synced 2025-12-09 13:15:18 -05:00
libfdt: Fix bounds-checking bug in fdt_get_property()
The libfdt functions are supposed to behave tolerably well when practical, even if given a corrupted device tree as input. A silly mistake in fdt_get_property() means we're bounds checking against the size of a pointer instead of the size of a property header, meaning we can get bogus behaviour in a corrupted device tree where the structure block ends in what's supposed to be the middle of a property. This patch corrects the problem (fdt_get_property() will now return BADSTRUCTURE in this case), and also adds a testcase to catch the bug.
This commit is contained in:
parent
6ae4de5c81
commit
9825f823eb
6 changed files with 72 additions and 2 deletions
2
fdt_ro.c
2
fdt_ro.c
|
|
@ -193,7 +193,7 @@ struct fdt_property *fdt_get_property(const struct fdt_header *fdt,
|
|||
/* Found it! */
|
||||
int len = fdt32_to_cpu(prop->len);
|
||||
prop = fdt_offset_ptr(fdt, offset,
|
||||
sizeof(prop)+len);
|
||||
sizeof(*prop)+len);
|
||||
if (! prop)
|
||||
return PTR_ERROR(FDT_ERR_BADSTRUCTURE);
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue