Skip to content

Commit f21c5cf

Browse files
committed
EXP43-C: Add explicitly mentioned functions
1 parent 4cd4896 commit f21c5cf

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

c/cert/src/rules/EXP43-C/DoNotPassAliasedPointerToRestrictQualifiedParam.ql

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,26 @@ class FunctionWithRestrictParameters extends Function {
2525
Parameter restrictPtrParam;
2626

2727
FunctionWithRestrictParameters() {
28-
restrictPtrParam = this.getAParameter() and
2928
restrictPtrParam.getUnspecifiedType() instanceof PointerOrArrayType and
30-
restrictPtrParam.getType().hasSpecifier("restrict")
29+
(
30+
restrictPtrParam.getType().hasSpecifier(["restrict"]) and
31+
restrictPtrParam = this.getAParameter()
32+
or
33+
this.hasGlobalName(["strcpy", "strncpy", "strcat", "strncat", "memcpy"]) and
34+
restrictPtrParam = this.getParameter([0, 1])
35+
or
36+
this.hasGlobalName(["strcpy_s", "strncpy_s", "strcat_s", "strncat_s", "memcpy_s"]) and
37+
restrictPtrParam = this.getParameter([0, 2])
38+
or
39+
this.hasGlobalName(["strtok_s"]) and
40+
restrictPtrParam = this.getAParameter()
41+
or
42+
this.hasGlobalName(["printf", "printf_s", "scanf", "scanf_s"]) and
43+
restrictPtrParam = this.getParameter(0)
44+
or
45+
this.hasGlobalName(["sprintf", "sprintf_s", "snprintf", "snprintf_s"]) and
46+
restrictPtrParam = this.getParameter(3)
47+
)
3148
}
3249

3350
Parameter getARestrictPtrParam() { result = restrictPtrParam }

0 commit comments

Comments
 (0)