summaryrefslogtreecommitdiffstats
path: root/commands/of_property.c
diff options
context:
space:
mode:
authorSascha Hauer <s.hauer@pengutronix.de>2013-02-26 19:54:10 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2013-03-06 11:41:29 +0100
commit5d6c8ac4b41b66cc2785d4e4e82397a5c7e66336 (patch)
treecd3fa9b01678554c426d9a7d9f36fabe8e2708d2 /commands/of_property.c
parentc932896af9f5e393966d41cf027a2a205a593960 (diff)
downloadbarebox-5d6c8ac4b41b66cc2785d4e4e82397a5c7e66336.tar.gz
of_property command: Fix crash with empty property value
the of_property command crashes when an empty property value was given. This is because xrealloc is called with a length argument of 0. Fix this. Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
Diffstat (limited to 'commands/of_property.c')
-rw-r--r--commands/of_property.c10
1 files changed, 8 insertions, 2 deletions
diff --git a/commands/of_property.c b/commands/of_property.c
index bd9ff72..1567a0f 100644
--- a/commands/of_property.c
+++ b/commands/of_property.c
@@ -255,9 +255,15 @@ static int do_of_property(int argc, char *argv[])
if (pp) {
free(pp->value);
+
/* limit property data to the actual size */
- data = xrealloc(data, len);
- pp->value = data;
+ if (len) {
+ pp->value = xrealloc(data, len);
+ } else {
+ pp->value = NULL;
+ free(data);
+ }
+
pp->length = len;
} else {
pp = of_new_property(node, propname, data, len);