aboutsummaryrefslogtreecommitdiff
path: root/tools
diff options
context:
space:
mode:
authorJoe Hershberger <joe.hershberger@ni.com>2012-10-15 15:29:24 +0000
committerTom Rini <trini@ti.com>2012-10-16 08:47:27 -0700
commitce2f5800177c36451da44345f7ab408df240ff82 (patch)
tree0ef10bd798796dd3396da50c904c808366700f89 /tools
parentbd23b22badadcdc414a900828253961fc5ec6c39 (diff)
downloadu-boot-linaro-stable-ce2f5800177c36451da44345f7ab408df240ff82.tar.gz
tools/env: Fix variable delete operation
Fix crash introduced by a073d63a36524453a817ab029fad5b188f46127e when attempting to delete a variable. Signed-off-by: Joe Hershberger <joe.hershberger@ni.com>
Diffstat (limited to 'tools')
-rw-r--r--tools/env/fw_env.c5
1 files changed, 3 insertions, 2 deletions
diff --git a/tools/env/fw_env.c b/tools/env/fw_env.c
index ab8c15d30..97328bb3a 100644
--- a/tools/env/fw_env.c
+++ b/tools/env/fw_env.c
@@ -494,6 +494,8 @@ int fw_setenv(int argc, char *argv[])
char *val = argv[i];
size_t val_len = strlen(val);
+ if (value)
+ value[len - 1] = ' ';
value = realloc(value, len + val_len + 1);
if (!value) {
fprintf(stderr,
@@ -504,9 +506,8 @@ int fw_setenv(int argc, char *argv[])
memcpy(value + len, val, val_len);
len += val_len;
- value[len++] = ' ';
+ value[len++] = '\0';
}
- value[len - 1] = '\0';
fw_env_write(name, value);