-
Notifications
You must be signed in to change notification settings - Fork 77
Expand file tree
/
Copy pathDoNotCallGetcAndPutcWithSideEffects.ql
More file actions
30 lines (28 loc) · 1.13 KB
/
DoNotCallGetcAndPutcWithSideEffects.ql
File metadata and controls
30 lines (28 loc) · 1.13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
/**
* @id c/cert/do-not-call-getc-and-putc-with-side-effects
* @name FIO41-C: Do not call getc(), putc(), getwc(), or putwc() with a stream argument that has side effects
* @description Using an expression that has side effects as the stream argument to `getc()` or
* `putc()` can result in unexpected behavior.
* @kind problem
* @precision very-high
* @problem.severity error
* @tags external/cert/id/fio41-c
* correctness
* external/cert/severity/low
* external/cert/likelihood/unlikely
* external/cert/remediation-cost/medium
* external/cert/priority/p2
* external/cert/level/l3
* coding-standards/baseline/safety
* external/cert/obligation/rule
*/
import cpp
import codingstandards.c.cert
import codingstandards.cpp.standardlibrary.FileAccess
from FileAccess fa
where
not isExcluded(fa.getFileExpr(), IO2Package::doNotCallGetcAndPutcWithSideEffectsQuery()) and
fa.getTarget().hasGlobalName(["getc", "putc", "getwc", "putwc"]) and
not fa.getFileExpr().isPure()
select fa.getFileExpr(),
"The stream argument has side effects and might be evaluated more then once."