Merge pull request #4824 from geoffw0/modelchanges5

C++: Add cases in the Allocation model.
This commit is contained in:
Jonas Jensen
2020-12-18 09:16:01 +01:00
committed by GitHub
4 changed files with 30 additions and 3 deletions

View File

@@ -82,7 +82,9 @@ private class AllocaAllocationFunction extends AllocationFunction {
hasGlobalName([
// --- stack allocation
"alloca", // // alloca(size)
"__builtin_alloca" // __builtin_alloca(size)
"__builtin_alloca", // __builtin_alloca(size)
"_alloca", // _alloca(size)
"_malloca" // _malloca(size)
]) and
sizeArg = 0
}

View File

@@ -14,6 +14,7 @@ import semmle.code.cpp.models.interfaces.Taint
private class StrdupFunction extends AllocationFunction, ArrayFunction, DataFlowFunction {
StrdupFunction() {
hasGlobalName([
// --- C library allocation
"strdup", // strdup(str)
"wcsdup", // wcsdup(str)
"_strdup", // _strdup(str)
@@ -39,8 +40,8 @@ private class StrndupFunction extends AllocationFunction, ArrayFunction, DataFlo
StrndupFunction() {
exists(string name |
hasGlobalName(name) and
// strndup(str, maxlen)
name = "strndup"
// --- C library allocation
name = "strndup" // strndup(str, maxlen)
)
}