Skip to content

Commit ef2a70e

Browse files
committed
Limit open/openat target to global/std scope
1 parent 0b9b6d7 commit ef2a70e

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

cpp/ql/src/Security/CWE/CWE-732/FilePermissions.qll

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ abstract class FileCreationWithOptionalModeExpr extends FileCreationExpr {
134134

135135
class OpenCreationExpr extends FileCreationWithOptionalModeExpr {
136136
OpenCreationExpr() {
137-
this.getTarget().getName() = ["open", "_open", "_wopen"] and
137+
this.getTarget().hasGlobalOrStdName(["open", "_open", "_wopen"]) and
138138
exists(int flag | flag = this.getArgument(1).getValue().toInt() |
139139
setsFlag(flag, o_creat()) or setsFlag(flag, o_tmpfile())
140140
)
@@ -163,7 +163,7 @@ class CreatCreationExpr extends FileCreationExpr {
163163

164164
class OpenatCreationExpr extends FileCreationWithOptionalModeExpr {
165165
OpenatCreationExpr() {
166-
this.getTarget().getName() = "openat" and
166+
this.getTarget().hasGlobalOrStdName("openat") and
167167
exists(int flag | flag = this.getArgument(2).getValue().toInt() |
168168
setsFlag(flag, o_creat()) or setsFlag(flag, o_tmpfile())
169169
)

0 commit comments

Comments
 (0)