Skip to content

Commit 440e621

Browse files
committed
CPP: correctly escape underscores in calls to .matches()
1 parent e32a04f commit 440e621

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

cpp/ql/src/Likely Bugs/Conversion/LossyFunctionResultCast.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ predicate whitelist(Function f) {
1919
"nearbyintl", "rint", "rintf", "rintl", "round", "roundf", "roundl", "trunc", "truncf",
2020
"truncl"
2121
] or
22-
f.getName().matches("__builtin_%")
22+
f.getName().matches("\\_\\_builtin\\_%")
2323
}
2424

2525
predicate whitelistPow(FunctionCall fc) {

cpp/ql/src/experimental/Security/CWE/CWE-266/IncorrectPrivilegeAssignment.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ where
5858
// unfortunately cannot use numeric value here because // O_CREAT is defined differently on different OSes:
5959
// https://github.com/red/red/blob/92feb0c0d5f91e087ab35fface6906afbf99b603/runtime/definitions.reds#L477-L491
6060
// this may introduce false negatives
61-
fctmp.getArgument(1).(BitwiseOrExpr).getAChild*().getValueText().matches("O_CREAT") or
61+
fctmp.getArgument(1).(BitwiseOrExpr).getAChild*().getValueText().matches("O\\_CREAT") or
6262
fctmp.getArgument(1).getValueText().matches("%O_CREAT%")
6363
) and
6464
fctmp.getNumberOfArguments() = 2 and

0 commit comments

Comments
 (0)