diff mbox

[U-Boot,2/3] fw_env: fix incorrect usage of open(O_CREAT)

Message ID 1352612867-32354-2-git-send-email-vapier@gentoo.org
State Accepted
Delegated to: Tom Rini
Headers show

Commit Message

Mike Frysinger Nov. 11, 2012, 5:47 a.m. UTC
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(-)

Comments

Christian Riesch Dec. 14, 2012, 8:25 a.m. UTC | #1
Hi,

On Sun, Nov 11, 2012 at 6:47 AM, Mike Frysinger <vapier@gentoo.org> wrote:
> 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

Could someone please pick up this patchset?

http://patchwork.ozlabs.org/patch/198241/
http://patchwork.ozlabs.org/patch/198243/
http://patchwork.ozlabs.org/patch/198242/

make env is currently broken for me.
Thank you!
Regards, Christian

>
> 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
>
> _______________________________________________
> U-Boot mailing list
> U-Boot@lists.denx.de
> http://lists.denx.de/mailman/listinfo/u-boot
Joe Hershberger Dec. 15, 2012, 5:57 p.m. UTC | #2
Hi Mike,

On Sat, Nov 10, 2012 at 11:47 PM, Mike Frysinger <vapier@gentoo.org> wrote:
> 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>

Acked-by: Joe Hershberger <joe.hershberger@ni.com>
diff mbox

Patch

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;