Skip to content

Commit a4c0a03

Browse files
authored
Merge pull request github#12426 from github/redsun82/cpp-file-permissions-example
C++: fix example code for `FilePermissions.qll`
2 parents 6a985a3 + c4fd39e commit a4c0a03

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed
Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
1-
int write_default_config_bad() {
1+
void write_default_config_bad() {
22
// BAD - this is world-writable so any user can overwrite the config
3-
FILE* out = creat(OUTFILE, 0666);
4-
fprintf(out, DEFAULT_CONFIG);
3+
int out = creat(OUTFILE, 0666);
4+
dprintf(out, DEFAULT_CONFIG);
55
}
66

7-
int write_default_config_good() {
7+
void write_default_config_good() {
88
// GOOD - this allows only the current user to modify the file
9-
FILE* out = creat(OUTFILE, S_IWUSR | S_IRUSR);
10-
fprintf(out, DEFAULT_CONFIG);
9+
int out = creat(OUTFILE, S_IWUSR | S_IRUSR);
10+
dprintf(out, DEFAULT_CONFIG);
1111
}

0 commit comments

Comments
 (0)