Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 9d19752

Browse files
authored
C++: Model bsl functions in Strcat.qll.
1 parent 9b8d94d commit 9d19752

2 files changed

Lines changed: 14 additions & 1 deletion

File tree

cpp/ql/src/semmle/code/cpp/Declaration.qll

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,19 @@ class Declaration extends Locatable, @declaration {
139139
this.hasQualifiedName("std", "", name)
140140
}
141141

142+
/**
143+
* Holds if this declaration has the given name in the global namespace,
144+
* the `std` namespace or the `bsl` namespace.
145+
* We treat `std` and `bsl` as the same in a bunch of our models.
146+
*/
147+
predicate hasGlobalOrStdishName(string name) {
148+
this.hasGlobalName(name)
149+
or
150+
this.hasQualifiedName("std", "", name)
151+
or
152+
this.hasQualifiedName("bsl", "", name)
153+
}
154+
142155
/** Gets a specifier of this declaration. */
143156
Specifier getASpecifier() { none() } // overridden in subclasses
144157

cpp/ql/src/semmle/code/cpp/models/implementations/Strcat.qll

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ import semmle.code.cpp.models.interfaces.SideEffect
1313
*/
1414
class StrcatFunction extends TaintFunction, DataFlowFunction, ArrayFunction, SideEffectFunction {
1515
StrcatFunction() {
16-
this.hasGlobalOrStdName([
16+
this.hasGlobalOrStdishName([
1717
"strcat", // strcat(dst, src)
1818
"strncat", // strncat(dst, src, max_amount)
1919
"wcscat", // wcscat(dst, src)

0 commit comments

Comments
 (0)