Skip to content

Commit e02ebfb

Browse files
committed
C++: Add extra cases to Allocation / Deallocation.
1 parent 899d1ab commit e02ebfb

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,9 @@ private class AllocaAllocationFunction extends AllocationFunction {
8282
hasGlobalName([
8383
// --- stack allocation
8484
"alloca", // // alloca(size)
85-
"__builtin_alloca" // __builtin_alloca(size)
85+
"__builtin_alloca", // __builtin_alloca(size)
86+
"_alloca", // __alloca(size)
87+
"_malloca" // _malloca(size)
8688
]) and
8789
sizeArg = 0
8890
}

cpp/ql/src/semmle/code/cpp/models/implementations/Strdup.qll

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,14 @@ import semmle.code.cpp.models.interfaces.Taint
1414
private class StrdupFunction extends AllocationFunction, ArrayFunction, DataFlowFunction {
1515
StrdupFunction() {
1616
hasGlobalName([
17+
// --- C library allocation
1718
"strdup", // strdup(str)
1819
"wcsdup", // wcsdup(str)
1920
"_strdup", // _strdup(str)
2021
"_wcsdup", // _wcsdup(str)
21-
"_mbsdup" // _mbsdup(str)
22+
"_mbsdup", // _mbsdup(str)
23+
// --- Windows Automation
24+
"SysAllocString" // SysAllocString(string)
2225
])
2326
}
2427

@@ -39,8 +42,8 @@ private class StrndupFunction extends AllocationFunction, ArrayFunction, DataFlo
3942
StrndupFunction() {
4043
exists(string name |
4144
hasGlobalName(name) and
42-
// strndup(str, maxlen)
43-
name = "strndup"
45+
// --- C library allocation
46+
name = "strndup" // strndup(str, maxlen)
4447
)
4548
}
4649

0 commit comments

Comments
 (0)