Skip to content

Commit 6dd941e

Browse files
authored
Merge pull request #14996 from jketema/toctou-test
C++: Fix `chmod` prototype in toctou test and additional test
2 parents 570538b + 7f1bd49 commit 6dd941e

File tree

1 file changed

+6
-1
lines changed
  • cpp/ql/test/query-tests/Security/CWE/CWE-367/semmle

1 file changed

+6
-1
lines changed

cpp/ql/test/query-tests/Security/CWE/CWE-367/semmle/test2.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ bool stat(const char *path, stat_data *buf);
1919
bool fstat(int file, stat_data *buf);
2020
bool lstat(const char *path, stat_data *buf);
2121
bool fstatat(int dir, const char *path, stat_data *buf);
22-
void chmod(const char *path, int setting);
22+
int chmod(const char *path, int setting);
2323
int rename(const char *from, const char *to);
2424
bool remove(const char *path);
2525

@@ -408,3 +408,8 @@ void test7_1(const char *path1, const char *path2)
408408
chmod(path2, 1234); // BAD
409409
}
410410
}
411+
412+
int test8(const char *path, int mode)
413+
{
414+
return (chmod(path, mode) == 0 ? 1 : 0); // GOOD
415+
}

0 commit comments

Comments
 (0)