Skip to content

Commit 69619f1

Browse files
authored
Merge pull request github#12738 from MathiasVP/fix-join-in-suspecious-call-to-strncat
C++: Fix join order in `cpp/unsafe-strncat`
2 parents 2b9daed + e5700e0 commit 69619f1

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

cpp/ql/src/Likely Bugs/Memory Management/SuspiciousCallToStrncat.ql

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,11 @@ predicate case1(FunctionCall fc, Expr sizeArg, VariableAccess destArg) {
4848
* Holds if `fc` is a call to `strncat` with size argument `sizeArg` and destination
4949
* argument `destArg`, and `sizeArg` computes the value `sizeof (dest) - strlen (dest)`.
5050
*/
51-
predicate case2(FunctionCall fc, Expr sizeArg, VariableAccess destArg) {
52-
interestingCallWithArgs(fc, sizeArg, destArg) and
51+
predicate case2(FunctionCall fc, Expr sizeArg, Expr destArg) {
52+
interestingCallWithArgs(fc, pragma[only_bind_into](sizeArg), pragma[only_bind_into](destArg)) and
5353
exists(SubExpr sub, int n |
5454
// The destination buffer is an array of size n
55-
destArg.getUnspecifiedType().(ArrayType).getSize() = n and
55+
pragma[only_bind_out](destArg.getUnspecifiedType().(ArrayType).getSize()) = n and
5656
// The size argument is equivalent to a subtraction
5757
globalValueNumber(sizeArg).getAnExpr() = sub and
5858
// ... where the left side of the subtraction is the constant n

0 commit comments

Comments
 (0)