Skip to content

Commit 25bfc3a

Browse files
author
dilanbhalla
committed
fixed references and used autoformat
1 parent 3fdd11a commit 25bfc3a

File tree

3 files changed

+10
-14
lines changed

3 files changed

+10
-14
lines changed

cpp/ql/src/experimental/Security/CWE/CWE-120/MemoryUnsafeFunctionScan.qhelp

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,6 @@
88
</overview>
99

1010
<references>
11-
<li>https://cwe.mitre.org/data/definitions/120</li>
12-
<!-- LocalWords: CWE
13-
-->
1411
</references>
1512

1613
</qhelp>

cpp/ql/src/experimental/Security/CWE/CWE-120/MemoryUnsafeFunctionScan.ql

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,12 @@
1313
import cpp
1414
import semmle.code.cpp.commons.Scanf
1515

16-
1716
from FunctionCall call, ScanfFunction sff
1817
where
19-
call.getTarget() = sff
20-
and
18+
call.getTarget() = sff and
2119
(
22-
call.getArgument(sff.getFormatParameterIndex()).toString().regexpMatch(".*%s.*")
23-
or
24-
call.getArgument(sff.getFormatParameterIndex()).toString() = (".*%ls.*")
20+
call.getArgument(sff.getFormatParameterIndex()).toString().regexpMatch(".*%s.*")
21+
or
22+
call.getArgument(sff.getFormatParameterIndex()).toString() = (".*%ls.*")
2523
)
26-
select call, "Dangerous use of one of the scanf functions"
24+
select call, "Dangerous use of one of the scanf functions"

cpp/ql/test/experimental/query-tests/Security/CWE/semmle/tests/MemoryUnsafeFunctionScan.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
///// Library routines /////
22

3-
int scanf(const char* format, ... );
4-
int sscanf(const char* str, const char* format, ...);
5-
int fscanf(const char* str, const char* format, ...);
3+
int scanf(const char *format, ...);
4+
int sscanf(const char *str, const char *format, ...);
5+
int fscanf(const char *str, const char *format, ...);
66

77
///// Test code /////
88

9-
int main(int argc, char** argv) {
9+
int main(int argc, char **argv)
10+
{
1011

1112
// BAD, do not use scanf without specifying a length first
1213
char buf1[10];

0 commit comments

Comments
 (0)