oss-sec mailing list archives
AW: Re: AW: O_CREAT|O_DIRECTORY on nonexisting file expected behaviour?
From: Fiedler Roman <Roman.Fiedler () ait ac at>
Date: Mon, 15 Dec 2014 18:33:12 +0000
Von: Andy Lutomirski [mailto:luto () amacapital net] On 11/26/2014 11:32 AM, Fiedler Roman wrote:Von: Matthew Daley [mailto:mattd-Lyx97FHGs0pBDgjK7y7TUQ () public gmane org]On Thu, Nov 27, 2014 at 4:28 AM, Fiedler Roman <Roman.Fiedler-c/U4JCCwIJZeoWH0uzbU5w () public gmane org>wrote:(...) 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));FWIW, this should probably be S_ISDIR(statBuf.st_mode).You are completely right, how stupid to miss that. I did not challenge the result, since it was the same as with "ls -al". Also with S_ISDIR(statBuf.st_mode), result is the same, at least on my side. #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(statBuf.st_mode)); return(0); } $ ./test New element type is 0Report it to linux-fsdevel () vger kernel org?
As not regarded as security problem, I just reported it as normal bug to devs, see http://marc.info/?l=linux-fsdevel&m=141866588432265&w=2
Attachment:
smime.p7s
Description:
Current thread:
- O_CREAT|O_DIRECTORY on nonexisting file expected behaviour? Fiedler Roman (Nov 26)
- Re: O_CREAT|O_DIRECTORY on nonexisting file expected behaviour? Eric Blake (Nov 26)
- AW: O_CREAT|O_DIRECTORY on nonexisting file expected behaviour? Fiedler Roman (Nov 26)
- Re: AW: O_CREAT|O_DIRECTORY on nonexisting file expected behaviour? Daniel Kahn Gillmor (Nov 26)
- Re: O_CREAT|O_DIRECTORY on nonexisting file expected behaviour? Matthew Daley (Nov 26)
- AW: O_CREAT|O_DIRECTORY on nonexisting file expected behaviour? Fiedler Roman (Nov 26)
- Re: AW: O_CREAT|O_DIRECTORY on nonexisting file expected behaviour? Andy Lutomirski (Dec 01)
- AW: Re: AW: O_CREAT|O_DIRECTORY on nonexisting file expected behaviour? Fiedler Roman (Dec 15)
- AW: O_CREAT|O_DIRECTORY on nonexisting file expected behaviour? Fiedler Roman (Nov 26)
- Re: O_CREAT|O_DIRECTORY on nonexisting file expected behaviour? Eric Blake (Nov 26)