mirror of
https://github.com/github/codeql.git
synced 2025-12-21 03:06:31 +01:00
Merge pull request #2647 from geoffw0/modelpure
CPP: Improve strlen model
This commit is contained in:
@@ -80,14 +80,6 @@ predicate functionArgumentMustBeNullTerminated(Function f, int i) {
|
||||
f.(ArrayFunction).hasArrayInput(i)
|
||||
or
|
||||
f instanceof StrcatFunction and i = 0
|
||||
or
|
||||
f.hasName("strlen") and i = 0
|
||||
or
|
||||
f.hasName("strcmp") and i in [0 .. 1]
|
||||
or
|
||||
f.hasName("strchr") and i = 0
|
||||
or
|
||||
f.hasName("strstr") and i in [0 .. 1]
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -30,7 +30,16 @@ class PureStrFunction extends AliasFunction, ArrayFunction, TaintFunction, SideE
|
||||
name = "strtol" or
|
||||
name = "strtoll" or
|
||||
name = "strtoq" or
|
||||
name = "strtoul"
|
||||
name = "strtoul" or
|
||||
name = "wcslen"
|
||||
)
|
||||
or
|
||||
hasGlobalName(name) and
|
||||
(
|
||||
name = "_mbslen" or
|
||||
name = "_mbslen_l" or
|
||||
name = "_mbstrlen" or
|
||||
name = "_mbstrlen_l"
|
||||
)
|
||||
)
|
||||
}
|
||||
@@ -39,6 +48,10 @@ class PureStrFunction extends AliasFunction, ArrayFunction, TaintFunction, SideE
|
||||
getParameter(bufParam).getUnspecifiedType() instanceof PointerType
|
||||
}
|
||||
|
||||
override predicate hasArrayWithNullTerminator(int bufParam) {
|
||||
getParameter(bufParam).getUnspecifiedType() instanceof PointerType
|
||||
}
|
||||
|
||||
override predicate hasTaintFlow(FunctionInput input, FunctionOutput output) {
|
||||
exists(ParameterIndex i |
|
||||
input.isParameter(i) and
|
||||
|
||||
Reference in New Issue
Block a user