mirror of
https://github.com/github/codeql.git
synced 2026-01-16 16:04:45 +01:00
Merge pull request #16662 from jketema/gets
C++: Ignore `gets`'es with incorrect parameter counts
This commit is contained in:
@@ -17,5 +17,6 @@ import cpp
|
||||
from FunctionCall call, Function target
|
||||
where
|
||||
call.getTarget() = target and
|
||||
target.hasGlobalOrStdName("gets")
|
||||
target.hasGlobalOrStdName("gets") and
|
||||
target.getNumberOfParameters() = 1
|
||||
select call, "'gets' does not guard against buffer overflow."
|
||||
|
||||
4
cpp/ql/src/change-notes/2014-06-05-gets-parameter.md
Normal file
4
cpp/ql/src/change-notes/2014-06-05-gets-parameter.md
Normal file
@@ -0,0 +1,4 @@
|
||||
---
|
||||
category: minorAnalysis
|
||||
---
|
||||
* The `cpp/dangerous-function-overflow` no longer produces a false positive alert when the `gets` function does not have exactly one parameter.
|
||||
@@ -36,7 +36,7 @@ char *gets(char *s);
|
||||
|
||||
void testGets() {
|
||||
char buf1[1024];
|
||||
char buf2 = malloc(1024);
|
||||
char *buf2 = malloc(1024);
|
||||
char *s;
|
||||
|
||||
gets(buf1); // BAD: use of gets
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
char *gets();
|
||||
|
||||
void testOtherGets() {
|
||||
char *s;
|
||||
|
||||
s = gets(); // GOOD: this is not the gets from stdio.h
|
||||
}
|
||||
Reference in New Issue
Block a user