Skip to content

Commit b6bcf9f

Browse files
authored
Add files via upload
1 parent b393c6a commit b6bcf9f

File tree

3 files changed

+29
-0
lines changed

3 files changed

+29
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
| test.cpp:23:3:23:8 | call to fclose | consider changing the call to $@ | test.cpp:9:6:9:13 | myFclose | myFclose |
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
experimental/Security/CWE/CWE-1041/FindWrapperFunctions.ql
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#define NULL (0)
2+
typedef int FILE;
3+
FILE *fopen(const char *filename, const char *mode);
4+
int fclose(FILE *stream);
5+
extern FILE * fe;
6+
extern int printf(const char *fmt, ...);
7+
void exit(int status);
8+
9+
void myFclose(FILE * fmy)
10+
{
11+
int i;
12+
if(fmy) {
13+
i = fclose(fmy);
14+
fmy = NULL;
15+
printf("close end is code %d",i);
16+
if(i!=0) exit(1);
17+
}
18+
}
19+
20+
int main(int argc, char *argv[])
21+
{
22+
fe = fopen("myFile.txt", "wt");
23+
fclose(fe); // BAD
24+
fe = fopen("myFile.txt", "wt");
25+
myFclose(fe); // GOOD
26+
return 0;
27+
}

0 commit comments

Comments
 (0)