From: Mike Frysinger Date: Sat, 10 Nov 2012 19:47:46 +0000 (+0000) Subject: fw_env: fix incorrect usage of open(O_CREAT) X-Git-Tag: v2013.01-rc3~20 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=7a546db2ffc6a713fb8009d8246c29da5420f6a7;p=u-boot fw_env: fix incorrect usage of open(O_CREAT) When using open(), the O_CREAT flag must be given a mode, otherwise it uses random garbage from the stack. Also, it can fail to build: In file included from /usr/include/fcntl.h:290:0, from fw_env_main.c:42: In function 'open', inlined from 'main' at fw_env_main.c:97:9: /usr/include/bits/fcntl2.h:50:24: error: call to '__open_missing_mode' declared with attribute error: open with O_CREAT in second argument needs 3 arguments Signed-off-by: Mike Frysinger Acked-by: Joe Hershberger --- diff --git a/tools/env/fw_env_main.c b/tools/env/fw_env_main.c index c855f4c17e..40ea3f62a2 100644 --- a/tools/env/fw_env_main.c +++ b/tools/env/fw_env_main.c @@ -94,7 +94,7 @@ int main(int argc, char *argv[]) int lockfd = -1; int retval = EXIT_SUCCESS; - lockfd = open(lockname, O_WRONLY | O_CREAT | O_TRUNC); + lockfd = open(lockname, O_WRONLY | O_CREAT | O_TRUNC, 0666); if (-1 == lockfd) { fprintf(stderr, "Error opening lock file %s\n", lockname); return EXIT_FAILURE;