mirror of
https://github.com/github/codeql.git
synced 2026-04-30 11:15:13 +02:00
fixed references and used autoformat
This commit is contained in:
@@ -8,9 +8,6 @@
|
||||
</overview>
|
||||
|
||||
<references>
|
||||
<li>https://cwe.mitre.org/data/definitions/120</li>
|
||||
<!-- LocalWords: CWE
|
||||
-->
|
||||
</references>
|
||||
|
||||
</qhelp>
|
||||
|
||||
@@ -13,14 +13,12 @@
|
||||
import cpp
|
||||
import semmle.code.cpp.commons.Scanf
|
||||
|
||||
|
||||
from FunctionCall call, ScanfFunction sff
|
||||
where
|
||||
call.getTarget() = sff
|
||||
and
|
||||
call.getTarget() = sff and
|
||||
(
|
||||
call.getArgument(sff.getFormatParameterIndex()).toString().regexpMatch(".*%s.*")
|
||||
or
|
||||
call.getArgument(sff.getFormatParameterIndex()).toString() = (".*%ls.*")
|
||||
call.getArgument(sff.getFormatParameterIndex()).toString().regexpMatch(".*%s.*")
|
||||
or
|
||||
call.getArgument(sff.getFormatParameterIndex()).toString() = (".*%ls.*")
|
||||
)
|
||||
select call, "Dangerous use of one of the scanf functions"
|
||||
select call, "Dangerous use of one of the scanf functions"
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
///// Library routines /////
|
||||
|
||||
int scanf(const char* format, ... );
|
||||
int sscanf(const char* str, const char* format, ...);
|
||||
int fscanf(const char* str, const char* format, ...);
|
||||
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) {
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
|
||||
// BAD, do not use scanf without specifying a length first
|
||||
char buf1[10];
|
||||
|
||||
Reference in New Issue
Block a user