[PATCH 29/29] of_property command: Fix crash with empty property value
Sascha Hauer
s.hauer at pengutronix.de
Tue Feb 26 15:18:56 EST 2013
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 at pengutronix.de>
---
commands/of_property.c | 10 ++++++++--
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/commands/of_property.c b/commands/of_property.c
index 5d35bb4..6311b70 100644
--- a/commands/of_property.c
+++ b/commands/of_property.c
@@ -254,9 +254,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);
--
1.7.10.4
More information about the barebox
mailing list