Skip to content

Commit 5e78990

Browse files
committed
C++: Remove all uses of hasQualifiedName/1
1 parent 64a87a8 commit 5e78990

22 files changed

+119
-119
lines changed

cpp/ql/src/Critical/DescriptorMayNotBeClosed.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import semmle.code.cpp.pointsto.PointsTo
1313
import Negativity
1414

1515
predicate closeCall(FunctionCall fc, Variable v) {
16-
fc.getTarget().hasQualifiedName("close") and v.getAnAccess() = fc.getArgument(0)
16+
fc.getTarget().hasGlobalName("close") and v.getAnAccess() = fc.getArgument(0)
1717
or
1818
exists(FunctionCall midcall, Function mid, int arg |
1919
fc.getArgument(arg) = v.getAnAccess() and

cpp/ql/src/Critical/DescriptorNeverClosed.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import semmle.code.cpp.pointsto.PointsTo
1313

1414
predicate closed(Expr e) {
1515
exists(FunctionCall fc |
16-
fc.getTarget().hasQualifiedName("close") and
16+
fc.getTarget().hasGlobalName("close") and
1717
fc.getArgument(0) = e
1818
)
1919
}

cpp/ql/src/Critical/GlobalUseBeforeInit.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ predicate useFunc(GlobalVariable v, Function f) {
3030
}
3131

3232
predicate uninitialisedBefore(GlobalVariable v, Function f) {
33-
f.hasQualifiedName("main")
33+
f.hasGlobalName("main")
3434
or
3535
exists(Call call, Function g |
3636
uninitialisedBefore(v, g) and

cpp/ql/src/Critical/MemoryMayNotBeFreed.ql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ predicate allocCallOrIndirect(Expr e) {
5555
* can cause memory leaks.
5656
*/
5757
predicate verifiedRealloc(FunctionCall reallocCall, Variable v, ControlFlowNode verified) {
58-
reallocCall.getTarget().hasQualifiedName("realloc") and
58+
reallocCall.getTarget().hasGlobalName("realloc") and
5959
reallocCall.getArgument(0) = v.getAnAccess() and
6060
(
6161
exists(Variable newV, ControlFlowNode node |
@@ -82,7 +82,7 @@ predicate verifiedRealloc(FunctionCall reallocCall, Variable v, ControlFlowNode
8282
predicate freeCallOrIndirect(ControlFlowNode n, Variable v) {
8383
// direct free call
8484
freeCall(n, v.getAnAccess()) and
85-
not n.(FunctionCall).getTarget().hasQualifiedName("realloc")
85+
not n.(FunctionCall).getTarget().hasGlobalName("realloc")
8686
or
8787
// verified realloc call
8888
verifiedRealloc(_, v, n)

cpp/ql/src/Critical/OverflowCalculated.ql

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,8 @@ import cpp
1414

1515
class MallocCall extends FunctionCall {
1616
MallocCall() {
17-
this.getTarget().hasQualifiedName("malloc") or
18-
this.getTarget().hasQualifiedName("std::malloc")
17+
this.getTarget().hasGlobalName("malloc") or
18+
this.getTarget().hasQualifiedName("std", "malloc")
1919
}
2020

2121
Expr getAllocatedSize() {
@@ -36,12 +36,12 @@ predicate spaceProblem(FunctionCall append, string msg) {
3636
malloc.getAllocatedSize() = add and
3737
buffer.getAnAccess() = strlen.getStringExpr() and
3838
(
39-
insert.getTarget().hasQualifiedName("strcpy") or
40-
insert.getTarget().hasQualifiedName("strncpy")
39+
insert.getTarget().hasGlobalName("strcpy") or
40+
insert.getTarget().hasGlobalName("strncpy")
4141
) and
4242
(
43-
append.getTarget().hasQualifiedName("strcat") or
44-
append.getTarget().hasQualifiedName("strncat")
43+
append.getTarget().hasGlobalName("strcat") or
44+
append.getTarget().hasGlobalName("strncat")
4545
) and
4646
malloc.getASuccessor+() = insert and
4747
insert.getArgument(1) = buffer.getAnAccess() and

cpp/ql/src/Critical/OverflowDestination.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ import semmle.code.cpp.security.TaintTracking
2525
predicate sourceSized(FunctionCall fc, Expr src) {
2626
exists(string name |
2727
(name = "strncpy" or name = "strncat" or name = "memcpy" or name = "memmove") and
28-
fc.getTarget().hasQualifiedName(name)
28+
fc.getTarget().hasGlobalName(name)
2929
) and
3030
exists(Expr dest, Expr size, Variable v |
3131
fc.getArgument(0) = dest and

cpp/ql/src/Critical/OverflowStatic.ql

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -59,21 +59,21 @@ predicate overflowOffsetInLoop(BufferAccess bufaccess, string msg) {
5959
}
6060

6161
predicate bufferAndSizeFunction(Function f, int buf, int size) {
62-
f.hasQualifiedName("read") and buf = 1 and size = 2
62+
f.hasGlobalName("read") and buf = 1 and size = 2
6363
or
64-
f.hasQualifiedName("fgets") and buf = 0 and size = 1
64+
f.hasGlobalName("fgets") and buf = 0 and size = 1
6565
or
66-
f.hasQualifiedName("strncpy") and buf = 0 and size = 2
66+
f.hasGlobalName("strncpy") and buf = 0 and size = 2
6767
or
68-
f.hasQualifiedName("strncat") and buf = 0 and size = 2
68+
f.hasGlobalName("strncat") and buf = 0 and size = 2
6969
or
70-
f.hasQualifiedName("memcpy") and buf = 0 and size = 2
70+
f.hasGlobalName("memcpy") and buf = 0 and size = 2
7171
or
72-
f.hasQualifiedName("memmove") and buf = 0 and size = 2
72+
f.hasGlobalName("memmove") and buf = 0 and size = 2
7373
or
74-
f.hasQualifiedName("snprintf") and buf = 0 and size = 1
74+
f.hasGlobalName("snprintf") and buf = 0 and size = 1
7575
or
76-
f.hasQualifiedName("vsnprintf") and buf = 0 and size = 1
76+
f.hasGlobalName("vsnprintf") and buf = 0 and size = 1
7777
}
7878

7979
class CallWithBufferSize extends FunctionCall {

cpp/ql/src/Critical/UseAfterFree.ql

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import semmle.code.cpp.controlflow.LocalScopeVariableReachability
1616
predicate isFreeExpr(Expr e, LocalScopeVariable v) {
1717
exists(VariableAccess va | va.getTarget() = v |
1818
exists(FunctionCall fc | fc = e |
19-
fc.getTarget().hasQualifiedName("free") and
19+
fc.getTarget().hasGlobalName("free") and
2020
va = fc.getArgument(0)
2121
)
2222
or

cpp/ql/src/DefaultOptions.qll

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ class Options extends string
3232
*/
3333
predicate overrideReturnsNull(Call call) {
3434
// Used in CVS:
35-
call.(FunctionCall).getTarget().hasQualifiedName("Xstrdup")
35+
call.(FunctionCall).getTarget().hasGlobalName("Xstrdup")
3636
or
3737
CustomOptions::overrideReturnsNull(call) // old Options.qll
3838
}
@@ -46,7 +46,7 @@ class Options extends string
4646
*/
4747
predicate returnsNull(Call call) {
4848
// Used in CVS:
49-
call.(FunctionCall).getTarget().hasQualifiedName("Xstrdup") and
49+
call.(FunctionCall).getTarget().hasGlobalName("Xstrdup") and
5050
nullValue(call.getArgument(0))
5151
or
5252
CustomOptions::returnsNull(call) // old Options.qll
@@ -92,7 +92,7 @@ class Options extends string
9292
* By default holds only for `fgets`.
9393
*/
9494
predicate alwaysCheckReturnValue(Function f) {
95-
f.hasQualifiedName("fgets") or
95+
f.hasGlobalName("fgets") or
9696
CustomOptions::alwaysCheckReturnValue(f) // old Options.qll
9797
}
9898

@@ -108,7 +108,7 @@ class Options extends string
108108
fc.isInMacroExpansion()
109109
or
110110
// common way of sleeping using select:
111-
(fc.getTarget().hasQualifiedName("select") and
111+
(fc.getTarget().hasGlobalName("select") and
112112
fc.getArgument(0).getValue() = "0")
113113
or
114114
CustomOptions::okToIgnoreReturnValue(fc) // old Options.qll

cpp/ql/src/Security/CWE/CWE-079/CgiXss.ql

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@ import semmle.code.cpp.security.TaintTracking
1616
/** A call that prints its arguments to `stdout`. */
1717
class PrintStdoutCall extends FunctionCall {
1818
PrintStdoutCall() {
19-
getTarget().hasQualifiedName("puts") or
20-
getTarget().hasQualifiedName("printf")
19+
getTarget().hasGlobalName("puts") or
20+
getTarget().hasGlobalName("printf")
2121
}
2222
}
2323

0 commit comments

Comments
 (0)