summaryrefslogtreecommitdiff
path: root/commands/of_dump.c
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2021-06-24 10:52:08 +0200
committerSascha Hauer <s.hauer@pengutronix.de>2021-06-25 09:27:07 +0200
commit8d21690fa82bbc29cc34005103a2eda63eafabf3 (patch)
treed8ce8f5ed7cf851e1938b3cd96e0ae4860467f3b /commands/of_dump.c
parent3b93bcd8db01bbe49249b59b0581b3ba375cb96b (diff)
downloadbarebox-8d21690fa82bbc29cc34005103a2eda63eafabf3.tar.gz
fdt: Check blob size during unflattening
of_unflatten_dtb() doesn't check the size of the device tree blob passed to it. Add a size argument end add checks for the size. Some callers have no idea of the buffer size themselves, INT_MAX is passed in these cases. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de> Link: https://lore.barebox.org/20210624085223.14616-4-s.hauer@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'commands/of_dump.c')
-rw-r--r--commands/of_dump.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/commands/of_dump.c b/commands/of_dump.c
index 2089c07ef7..5223ba63ad 100644
--- a/commands/of_dump.c
+++ b/commands/of_dump.c
@@ -71,7 +71,7 @@ static int do_of_dump(int argc, char *argv[])
return -errno;
}
- root = of_unflatten_dtb(fdt);
+ root = of_unflatten_dtb(fdt, size);
free(fdt);
@@ -88,7 +88,7 @@ static int do_of_dump(int argc, char *argv[])
/* create a copy of internal devicetree */
void *fdt;
fdt = of_flatten_dtb(root);
- root = of_unflatten_dtb(fdt);
+ root = of_unflatten_dtb(fdt, fdt_totalsize(fdt));
free(fdt);