Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20140926070548.GR23797@brightrain.aerifal.cx>
Date: Fri, 26 Sep 2014 03:05:48 -0400
From: Rich Felker <dalias@...c.org>
To: musl@...ts.openwall.com,
	黄建忠 <jianzhong.huang@...oft.com.cn>
Subject: Re: fdopen/fflush problem

On Fri, Sep 26, 2014 at 08:39:39AM +0200, Szabolcs Nagy wrote:
> * Rich Felker <dalias@...c.org> [2014-09-26 02:18:10 -0400]:
> > See the following text from the man page:
> > 
> >     The mkostemp() function is like mkstemp(), with the difference
> >     that the following bits???with the same meaning as for open(2)???may
> >     be specified in flags: O_APPEND, O_CLOEXEC, and O_SYNC. Note that
> >     when creating the file, mkostemp() includes the values O_RDWR,
> >     O_CREAT, and O_EXCL in the flags argument given to open(2);
> >     including these values in the flags argument given to mkostemp()
> >     is unnecessary, and produces errors on some systems.
> 
> ah i didnt see this, so it's not a musl bug

I forgot that this function was accepted for inclusion in POSIX, so we
need to check that too. The accepted text is in
http://austingroupbugs.net/view.php?id=411

    "The mkostemp( ) function shall be equivalent to the mkstemp( )
    function, except that the flag argument may contain additional
    flags (from <fcntl.h>) to be used as if by open( ). Behavior is
    unspecified if the flag argument contains more than the following
    flags:"

The list that follows includes just O_APPEND, O_CLOEXEC, and O_*SYNC,
so including O_WRONLY has unspecified behavior. However, since this is
just unspecified, not undefined, it seems bad for something "horribly
wrong" to happen, like a file with no access like we're getting now.
Indeed, POSIX will define an optional error:

    "The mkostemp( ) function may fail if:

    [EINVAL] The value of the flag argument is invalid."

So I think we should either make this error be detected, or silently
mask off the bad access mode. My leaning would be towards reporting it
as an error. Opinions?

Rich

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.