[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: 0.17: open-with-O_CREAT needs third argument
From: |
Bruno Haible |
Subject: |
Re: 0.17: open-with-O_CREAT needs third argument |
Date: |
Wed, 7 Nov 2007 12:44:14 +0100 |
User-agent: |
KMail/1.5.4 |
Jim Meyering wrote:
> Compiling on fedora rawhide, I got a warning about open-with-O_CREAT
> but no 3rd (mode) argument. Here's the fix:
Thanks! You are the first bug reporter for gettext 0.17.
> --- gettext-tools/src/write-catalog.c.~1~ 2007-11-07 08:57:35.000000000
> +0100
> +++ gettext-tools/src/write-catalog.c 2007-11-07 08:57:42.000000000 +0100
> @@ -220,7 +220,7 @@
> /* Open the output file. */
> if (!to_stdout)
> {
> - fd = open (filename, O_WRONLY | O_CREAT);
> + fd = open (filename, O_WRONLY | O_CREAT, 0600);
> if (fd < 0)
> {
> const char *errno_description = strerror (errno);
0666 is more appropriate here, IMO: It's not a temporary file, but a file
whose name the user has specified on the command line. And I also forgot
O_TRUNC.
2007-11-07 Jim Meyering <address@hidden>
Bruno Haible <address@hidden>
* write-catalog.c (msgdomain_list_print): Fix open() call.
--- gettext-tools/src/write-catalog.c 7 Oct 2007 19:35:31 -0000 1.4
+++ gettext-tools/src/write-catalog.c 7 Nov 2007 11:43:15 -0000
@@ -1,5 +1,5 @@
/* GNU gettext - internationalization aids
- Copyright (C) 1995-1998, 2000-2006 Free Software Foundation, Inc.
+ Copyright (C) 1995-1998, 2000-2007 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -220,7 +220,9 @@
/* Open the output file. */
if (!to_stdout)
{
- fd = open (filename, O_WRONLY | O_CREAT);
+ fd = open (filename, O_WRONLY | O_CREAT | O_TRUNC,
+ /* 0666 in portable POSIX notation: */
+ S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH);
if (fd < 0)
{
const char *errno_description = strerror (errno);