From: Mike Frysinger <vapier@gentoo.org>
To: u-boot@lists.denx.de
Subject: [U-Boot] [PATCH 2/3] fw_env: fix incorrect usage of open(O_CREAT)
Date: Sun, 11 Nov 2012 00:47:46 -0500 [thread overview]
Message-ID: <1352612867-32354-2-git-send-email-vapier@gentoo.org> (raw)
In-Reply-To: <1352612867-32354-1-git-send-email-vapier@gentoo.org>
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 <vapier@gentoo.org>
---
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 c855f4c..40ea3f6 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;
--
1.7.12.4
next prev parent reply other threads:[~2012-11-11 5:47 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-11-11 5:47 [U-Boot] [PATCH 1/3] fw_env: fix type of len Mike Frysinger
2012-11-11 5:47 ` Mike Frysinger [this message]
2012-12-14 8:25 ` [U-Boot] [PATCH 2/3] fw_env: fix incorrect usage of open(O_CREAT) Christian Riesch
2012-12-15 17:57 ` Joe Hershberger
2012-11-11 5:47 ` [U-Boot] [PATCH 3/3] fw_env: fix building w/out a config.h Mike Frysinger
2012-11-12 12:14 ` Peter Korsgaard
2012-12-15 18:04 ` Joe Hershberger
2013-05-21 11:19 ` Stefan Roese
2012-12-15 17:58 ` [U-Boot] [PATCH 1/3] fw_env: fix type of len Joe Hershberger
2012-12-19 23:00 ` [U-Boot] [U-Boot,1/3] " Tom Rini
2012-12-20 5:47 ` Joe Hershberger
2012-12-20 14:25 ` Tom Rini
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1352612867-32354-2-git-send-email-vapier@gentoo.org \
--to=vapier@gentoo.org \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.