...
This compliant solution eliminates the race condition by:
- calling
lstat()on the filenamefile name. - calling
open()to open the file. - calling
fstat()on the file descriptor returned byopen(). - comparing the file information returned by the calls to
lstat()andfstat()to ensure that the files are the same.
...
| Wiki Markup |
|---|
\[[Dowd 06|AA. C References#Dowd 06]\] Chapter 9, "UNIX 1: Privileges and Files" \[[ISO/IEC 9899-:1999|AA. C References#ISO/IEC 9899-1999]\] Section 7.19, "Input/output <stdio.h>" \[[MITRE 07|AA. C References#MITRE 07]\] [CWE ID 365|http://cwe.mitre.org/data/definitions/365.html], "Race Condition in Switch" \[[Open Group 04|AA. C References#Open Group 04]\] [lstat()|http://www.opengroup.org/onlinepubs/000095399/functions/lstat.html], [fstat()|http://www.opengroup.org/onlinepubs/009695399/functions/fstat.html], [open()|http://www.opengroup.org/onlinepubs/009695399/functions/open.html] \[[Seacord 05|AA. C References#Seacord 05]\] Chapter 7, "File I/O" |
...