Add files via upload

This commit is contained in:
ihsinme
2021-09-02 10:22:49 +03:00
committed by GitHub
parent 9f4b7255aa
commit 1e88470ad8
3 changed files with 87 additions and 0 deletions

View File

@@ -0,0 +1,3 @@
| test.cpp:20:3:20:8 | call to fclose | Second call to the $@ function is possible. | test.cpp:21:3:21:8 | call to fclose | fclose |
| test.cpp:31:3:31:8 | call to fclose | Second call to the $@ function is possible. | test.cpp:32:3:32:8 | call to fclose | fclose |
| test.cpp:38:3:38:8 | call to fclose | Second call to the $@ function is possible. | test.cpp:44:3:44:8 | call to fclose | fclose |

View File

@@ -0,0 +1 @@
experimental/Security/CWE/CWE-675/DoubleRelease.ql

View File

@@ -0,0 +1,83 @@
#define NULL (0)
typedef int FILE;
FILE *fopen(const char *filename, const char *mode);
int fclose(FILE *stream);
extern FILE * fe;
void test1()
{
FILE *f;
f = fopen("myFile.txt", "wt");
fclose(f); // GOOD
f = NULL;
}
void test2()
{
FILE *f;
f = fopen("myFile.txt", "wt");
fclose(f); // BAD
fclose(f);
}
void test3()
{
FILE *f;
FILE *g;
f = fopen("myFile.txt", "wt");
g = f;
fclose(f); // BAD
fclose(g);
}
int fGtest4_1()
{
fe = fopen("myFile.txt", "wt");
fclose(fe); // BAD
return -1;
}
int fGtest4_2()
{
fclose(fe);
return -1;
}
void Gtest4()
{
fGtest4_1();
fGtest4_2();
}
int fGtest5_1()
{
fe = fopen("myFile.txt", "wt");
fclose(fe); // GOOD
fe = NULL;
return -1;
}
int fGtest5_2()
{
fclose(fe);
return -1;
}
void Gtest5()
{
fGtest5_1();
fGtest5_2();
}
int main(int argc, char *argv[])
{
test1();
test2();
test3();
Gtest4();
Gtest5();
return 0;
}