Skip to content

Commit 363514e

Browse files
committed
C++: Expand heuristic to catch more sources.
1 parent 9da7c9f commit 363514e

File tree

2 files changed

+2
-2
lines changed
  • cpp/ql
    • lib/semmle/code/cpp/models/implementations
    • test/experimental/query-tests/Security/CWE/CWE-119

2 files changed

+2
-2
lines changed

cpp/ql/lib/semmle/code/cpp/models/implementations/Allocation.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -437,7 +437,7 @@ private module HeuristicAllocation {
437437
int sizeArg;
438438

439439
HeuristicAllocationFunctionByName() {
440-
Function.super.getName().matches("%alloc%") and
440+
Function.super.getName().matches(["%alloc%", "%Alloc%"]) and
441441
Function.super.getUnspecifiedType() instanceof PointerType and
442442
sizeArg = unique( | | getAnUnsignedParameter(this))
443443
}

cpp/ql/test/experimental/query-tests/Security/CWE/CWE-119/test.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,6 @@ void test_flow_through_setter(unsigned size) {
246246
void* my_alloc(unsigned size);
247247

248248
void foo(unsigned size) {
249-
int* p = (int*)my_alloc(size); // BAD [NOT DETECTED]
249+
int* p = (int*)my_alloc(size); // BAD
250250
memset(p, 0, size + 1);
251251
}

0 commit comments

Comments
 (0)