mirror of
https://github.com/github/codeql.git
synced 2026-05-04 21:25:44 +02:00
scanf fixes, still need to update qhelp file
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
///// Library routines /////
|
||||
|
||||
int scanf(const char* format, ... );
|
||||
int sscanf(const char* str, const char* format, ...);
|
||||
int fscanf(const char* str, const char* format, ...);
|
||||
|
||||
///// Test code /////
|
||||
|
||||
int main(int argc, char** argv) {
|
||||
|
||||
// BAD, do not use scanf without specifying a length first
|
||||
char buf1[10];
|
||||
scanf("%s", buf1);
|
||||
|
||||
// GOOD, length is specified
|
||||
char buf2[10];
|
||||
sscanf(buf2, "%9s");
|
||||
|
||||
// BAD, do not use scanf without specifying a length first
|
||||
char file[10];
|
||||
fscanf(file, "%s", buf2);
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
| MemoryUnsafeFunctionScan.cpp:13:5:13:9 | call to scanf | Dangerous use of one of the scanf functions |
|
||||
| MemoryUnsafeFunctionScan.cpp:21:5:21:10 | call to fscanf | Dangerous use of one of the scanf functions |
|
||||
@@ -0,0 +1 @@
|
||||
experimental/Security/CWE/CWE-120/MemoryUnsafeFunctionScan.ql
|
||||
Reference in New Issue
Block a user