From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/6203 Path: news.gmane.org!not-for-mail From: Rich Felker Newsgroups: gmane.linux.lib.musl.general Subject: Re: fdopen/fflush problem Date: Fri, 26 Sep 2014 03:05:48 -0400 Message-ID: <20140926070548.GR23797@brightrain.aerifal.cx> References: <54250245.2070108@i-soft.com.cn> <20140926061810.GQ23797@brightrain.aerifal.cx> <20140926063939.GF21835@port70.net> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1411715211 8408 80.91.229.3 (26 Sep 2014 07:06:51 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 26 Sep 2014 07:06:51 +0000 (UTC) To: musl@lists.openwall.com, =?utf-8?B?6buE5bu65b+g?= Original-X-From: musl-return-6216-gllmg-musl=m.gmane.org@lists.openwall.com Fri Sep 26 09:06:45 2014 Return-path: Envelope-to: gllmg-musl@plane.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by plane.gmane.org with smtp (Exim 4.69) (envelope-from ) id 1XXPc5-0000Pj-Fx for gllmg-musl@plane.gmane.org; Fri, 26 Sep 2014 09:06:45 +0200 Original-Received: (qmail 5333 invoked by uid 550); 26 Sep 2014 07:06:43 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: Original-Received: (qmail 4035 invoked from network); 26 Sep 2014 07:06:02 -0000 Content-Disposition: inline In-Reply-To: <20140926063939.GF21835@port70.net> User-Agent: Mutt/1.5.21 (2010-09-15) Original-Sender: Rich Felker Xref: news.gmane.org gmane.linux.lib.musl.general:6203 Archived-At: On Fri, Sep 26, 2014 at 08:39:39AM +0200, Szabolcs Nagy wrote: > * Rich Felker [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 ) 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