Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Wed, 26 Nov 2014 11:04:38 -0500
From: Daniel Kahn Gillmor <>
Subject: Re: AW: O_CREAT|O_DIRECTORY on nonexisting
 file expected behaviour?

On 11/26/2014 10:28 AM, Fiedler Roman wrote:
>> Von: Eric Blake []
>> But if it succeeds, and did NOT create a directory, then it is in
>> violation of POSIX.
> Thanks for the pointer to the POSIX documentation. So it seems to be a 
> POSIX-violation, at least on "Linux version 3.2.0-69-generic".
> My test program was:
> #include <fcntl.h>
> #include <stdio.h>
> #include <sys/stat.h>
> int main(int argc, char **argv) {
>   int fd;
>   struct stat statBuf;
>   int result;
>   fd=open("xxx", O_RDWR|O_CREAT|O_DIRECTORY, 0600);
>   result=fstat(fd, &statBuf);
>   if(result) {
>     fprintf(stderr, "Stat failed\n");
>     return(1);
>   }
>   fprintf(stderr, "New element type is %d\n", S_ISDIR(fd));
>   return(0);
> }

I just tried the above on debian's 3.17-1-amd64 (3.17-1~exp1, and it

New element type is 0

So if it's a violation, it hasn't been fixed between 3.2 and 3.17.


Download attachment "signature.asc" of type "application/pgp-signature" (950 bytes)

Powered by blists - more mailing lists

Please check out the Open Source Software Security Wiki, which is counterpart to this mailing list.

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