Files
codeql/cpp/ql/src/Security/CWE/CWE-367/TOCTOUFilesystemRaceGood.c

22 lines
241 B
C

char *file_name;
int fd;
/* Initialize file_name */
fd = open(
file_name,
O_WRONLY | O_CREAT | O_EXCL,
S_IRWXU
);
if (fd == -1) {
/* Handle error */
}
/* ... */
if (fchmod(fd, S_IRUSR) == -1) {
/* Handle error */
}
close(fd);