The length included the name length, and then it was subtracted back out on each use. Now we don't include it in the first place.
Signed-off-by: Joe Hershberger <joe.hershber...@ni.com> --- tools/env/fw_env.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/tools/env/fw_env.c b/tools/env/fw_env.c index e46791d..a461dbd 100644 --- a/tools/env/fw_env.c +++ b/tools/env/fw_env.c @@ -484,22 +484,23 @@ int fw_setenv(int argc, char *argv[]) name = argv[1]; - len = strlen(name) + 2; + len = 0; for (i = 2; i < argc; ++i) len += strlen(argv[i]) + 1; /* Allocate enough place to the data string */ for (i = 2; i < argc; ++i) { char *val = argv[i]; + if (!value) { - value = (char *)malloc(len - strlen(name)); + value = (char *)malloc(len); if (!value) { fprintf(stderr, "Cannot malloc %zu bytes: %s\n", - len - strlen(name), strerror(errno)); + len, strerror(errno)); return -1; } - memset(value, 0, len - strlen(name)); + memset(value, 0, len); tmpval = value; } if (i != 2) -- 1.7.11.5 _______________________________________________ U-Boot mailing list U-Boot@lists.denx.de http://lists.denx.de/mailman/listinfo/u-boot