summaryrefslogtreecommitdiffstats
path: root/.lgtm/cpp-queries/fgets.ql
blob: a4181e4f3db89504e8d886d7ef6bba97ad18df1d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
/**
 * @name Use of fgets()
 * @description fgets() is dangerous to call. Use read_line() instead.
 * @kind problem
 * @problem.severity error
 * @precision high
 * @id cpp/fgets
 * @tags reliability
 *       security
 */
import cpp

predicate dangerousFunction(Function function) {
  exists (string name | name = function.getQualifiedName() |
    name = "fgets")
}

from FunctionCall call, Function target
where call.getTarget() = target
  and dangerousFunction(target)
select call, target.getQualifiedName() + " is potentially dangerous"