C++: respond to PR comments

This commit is contained in:
Robert Marsh
2019-10-02 11:21:10 -07:00
parent 68c38ba34a
commit 4018ed67a6
7 changed files with 9 additions and 12 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -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) |

View File

@@ -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")
}

View File

@@ -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

View File

@@ -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

View File

@@ -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