mirror of
https://github.com/github/codeql.git
synced 2026-04-30 03:05:15 +02:00
C++: respond to PR comments
This commit is contained in:
@@ -36,7 +36,7 @@ predicate spaceProblem(FunctionCall append, string msg) {
|
||||
buffer.getAnAccess() = strlen.getStringExpr() and
|
||||
(
|
||||
insert.getTarget().hasGlobalOrStdName("strcpy") or
|
||||
insert.getTarget().hasGlobalName("strncpy")
|
||||
insert.getTarget().hasGlobalOrStdName("strncpy")
|
||||
) and
|
||||
(
|
||||
append.getTarget().hasGlobalOrStdName("strcat") or
|
||||
|
||||
@@ -58,7 +58,7 @@ predicate overflowOffsetInLoop(BufferAccess bufaccess, string msg) {
|
||||
}
|
||||
|
||||
predicate bufferAndSizeFunction(Function f, int buf, int size) {
|
||||
f.hasGlobalOrStdName("read") and buf = 1 and size = 2
|
||||
f.hasGlobalName("read") and buf = 1 and size = 2
|
||||
or
|
||||
f.hasGlobalOrStdName("fgets") and buf = 0 and size = 1
|
||||
or
|
||||
|
||||
@@ -34,10 +34,7 @@ class FileFunction extends FunctionWithWrappers {
|
||||
nme.matches("CreateFile%")
|
||||
)
|
||||
or
|
||||
exists(string nme | this.hasStdName(nme) |
|
||||
nme = "fopen" or
|
||||
nme = "open"
|
||||
)
|
||||
this.hasStdName("fopen")
|
||||
or
|
||||
// on any of the fstream classes, or filebuf
|
||||
exists(string nme | this.getDeclaringType().hasStdName(nme) |
|
||||
|
||||
@@ -66,7 +66,7 @@ class VarargsFunction extends Function {
|
||||
}
|
||||
|
||||
predicate isWhitelisted() {
|
||||
this.hasGlobalOrStdName("open") or
|
||||
this.hasGlobalName("open") or
|
||||
this.hasGlobalName("fcntl") or
|
||||
this.hasGlobalName("ptrace")
|
||||
}
|
||||
|
||||
@@ -26,10 +26,10 @@ predicate fcloseCall(FunctionCall fc, Expr closed) {
|
||||
f.hasGlobalOrStdName("fclose") and
|
||||
closed = fc.getArgument(0)
|
||||
or
|
||||
f.hasGlobalOrStdName("close") and
|
||||
f.hasGlobalName("close") and
|
||||
closed = fc.getArgument(0)
|
||||
or
|
||||
f.hasGlobalOrStdName("_close") and
|
||||
f.hasGlobalName("_close") and
|
||||
closed = fc.getArgument(0)
|
||||
or
|
||||
f.hasGlobalOrStdName("CloseHandle") and
|
||||
|
||||
@@ -73,8 +73,6 @@ class SecurityOptions extends string {
|
||||
functionCall.getTarget().hasGlobalOrStdName(fname) and
|
||||
exists(functionCall.getArgument(arg)) and
|
||||
(
|
||||
fname = "read" and arg = 1
|
||||
or
|
||||
fname = "fread" and arg = 0
|
||||
or
|
||||
fname = "fgets" and arg = 0
|
||||
@@ -91,6 +89,8 @@ class SecurityOptions extends string {
|
||||
functionCall.getTarget().hasGlobalName(fname) and
|
||||
exists(functionCall.getArgument(arg)) and
|
||||
(
|
||||
fname = "read" and arg = 1
|
||||
or
|
||||
fname = "getaddrinfo" and arg = 3
|
||||
or
|
||||
fname = "recv" and arg = 1
|
||||
|
||||
@@ -459,7 +459,7 @@ private predicate copyValueBetweenArguments(Function f, int sourceArg, int destA
|
||||
or
|
||||
f.hasGlobalName("inet_pton") and sourceArg = 1 and destArg = 2
|
||||
or
|
||||
f.hasGlobalName("strftime") and sourceArg in [2 .. maxArgIndex(f)] and destArg = 0
|
||||
f.hasGlobalOrStdName("strftime") and sourceArg in [2 .. maxArgIndex(f)] and destArg = 0
|
||||
or
|
||||
exists(FormattingFunction ff | ff = f |
|
||||
sourceArg in [ff.getFormatParameterIndex() .. maxArgIndex(f)] and
|
||||
|
||||
Reference in New Issue
Block a user