Nmap Development mailing list archives
Re: fileexistsandisreadable() is still broken
From: Kris Katterjohn <katterjohn () gmail com>
Date: Mon, 11 Dec 2006 15:12:16 -0600
In 4.21ALPHA1: #ifdef WIN32 #define STAT_READABLE(st) st.st_mode & S_IREAD #else #define STAT_READABLE(st) st.st_mode & S_IRUSR #endif /* Returns true (nonzero) if the file pathname given exists, is not * a directory and is readable by the executing process. Returns * zero if it is not */ int fileexistsandisreadable(char *pathname) { struct stat st; if (stat(pathname, &st) == -1) return 0; if (!S_ISDIR(st.st_mode) && STAT_READABLE(st)) return 1; if ((st.st_mode & S_IFDIR) && STAT_READABLE(st)) return 2; return 0; }The reason why I modified this function is because I needed it to distinguish between files and directories. Before my changes it only considered files. I slightly changed it to tell me if a file or directory exists and is readable. My changes don't have anything to do with access(). As long as the semantics remain the same, a change is probably justified cheers Diman
The directory check makes sense, but I figured that because access() wasn't used after Fyodor said he'd apply it that there was a problem with it that I didn't see. I then checked it again (using strace this time to be really sure) and replied. Thanks, Kris Katterjohn _______________________________________________ Sent through the nmap-dev mailing list http://cgi.insecure.org/mailman/listinfo/nmap-dev Archived at http://SecLists.Org
Current thread:
- fileexistsandisreadable() is still broken Kris Katterjohn (Dec 11)
- Re: fileexistsandisreadable() is still broken Diman Todorov (Dec 11)
- Re: fileexistsandisreadable() is still broken Kris Katterjohn (Dec 11)
- Re: fileexistsandisreadable() is still broken Fyodor (Dec 12)
- Re: fileexistsandisreadable() is still broken Diman Todorov (Dec 11)