intended language: C

click here for answer
1. Call the lstat function to get information about the file. (Do not use the stat function, as that function follows symbolic links.) Save the stat structure returned by the lstat function.
2. Check the file's status information to make sure the file is not a symbolic link.
3. Check the user ID (UID) and group ID (GID) of the file,using the structure, to make sure they are correct.
4. Check the filetype to make sure it's correct.
5.Check the read, write, and execute permissions for the file, using the structure, to make sure they are what you expect.
6. Check that there is only one hard link to the file, using the structure's variable 'st_nlink'
7. Call the open function and save the file descriptor.
8. Using the file descriptor, call the fstat function to obtain the stat structure for the file you opened.
9. Compare the device and inode numbers in the stat structure obtained before you opened the file with those in the stat structure obtained after you opened the file to verify that they are the same file.
10. Check all the information in the stat structure returned by the fstat function to make sure it is what you expect.
ref:http://developer.apple.com/documentation/Security/Conceptual/SecureCodingGuide/Articles/RaceConditions.html
No comments:
Post a Comment