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

Skip to content

Commit 0541950

Browse files
committed
CPP: Clean up PotentialBufferOverflow.ql a bit.
1 parent 2a708d3 commit 0541950

1 file changed

Lines changed: 4 additions & 9 deletions

File tree

cpp/ql/src/Likely Bugs/Memory Management/PotentialBufferOverflow.ql

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,7 @@
1313
import cpp
1414
import semmle.code.cpp.commons.Buffer
1515

16-
abstract class PotentiallyDangerousFunctionCall extends FunctionCall {
17-
abstract predicate isDangerous();
18-
abstract string getDescription();
19-
}
20-
21-
class SprintfCall extends PotentiallyDangerousFunctionCall {
16+
class SprintfCall extends FunctionCall {
2217
SprintfCall() {
2318
this.getTarget().hasName("sprintf") or this.getTarget().hasName("vsprintf")
2419
}
@@ -31,16 +26,16 @@ class SprintfCall extends PotentiallyDangerousFunctionCall {
3126
result = this.getArgument(1).(FormatLiteral).getMaxConvertedLength()
3227
}
3328

34-
override predicate isDangerous() {
29+
predicate isDangerous() {
3530
this.getMaxConvertedLength() > this.getBufferSize()
3631
}
3732

38-
override string getDescription() {
33+
string getDescription() {
3934
result = "This conversion may yield a string of length "+this.getMaxConvertedLength().toString()+
4035
", which exceeds the allocated buffer size of "+this.getBufferSize().toString()
4136
}
4237
}
4338

44-
from PotentiallyDangerousFunctionCall c
39+
from SprintfCall c
4540
where c.isDangerous()
4641
select c, c.getDescription()

0 commit comments

Comments
 (0)