[U-Boot] [PATCH] tools/env: fix allocation of the lock file name in fw_printenv

sgerwk sgerwk at aol.com
Wed Jul 5 18:39:59 UTC 2017


sizeof(env_opts.lockname) is the size of the pointer, not of
the string; this patch changes it to strlen(...)

---
 tools/env/fw_env_main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/tools/env/fw_env_main.c b/tools/env/fw_env_main.c
index b8bff264eb..499953dd69 100644
--- a/tools/env/fw_env_main.c
+++ b/tools/env/fw_env_main.c
@@ -245,7 +245,7 @@ int main(int argc, char *argv[])
 	argv += optind;
 
 	if (env_opts.lockname) {
-		lockname = malloc(sizeof(env_opts.lockname) +
+		lockname = malloc(strlen(env_opts.lockname) +
 				sizeof(CMD_PRINTENV) + 10);
 		if (!lockname) {
 			fprintf(stderr, "Unable allocate memory");
-- 
2.11.0



More information about the U-Boot mailing list