@@ -14,30 +14,34 @@ import cpp
14
14
import codingstandards.c.misra
15
15
import codingstandards.cpp.ReadErrorsAndEOF
16
16
import semmle.code.cpp.rangeanalysis.SimpleRangeAnalysis
17
- import semmle.code.cpp.rangeanalysis.RangeAnalysisUtils
18
17
18
+ //import semmle.code.cpp.rangeanalysis.RangeAnalysisUtils
19
19
class CtypeFunction extends Function {
20
20
CtypeFunction ( ) { this .getADeclaration ( ) .getAFile ( ) .( HeaderFile ) .getBaseName ( ) = "ctype.h" }
21
21
}
22
22
23
+ /* TODO Under construction */
23
24
from FunctionCall ctypeCall
24
25
where
25
26
not isExcluded ( ctypeCall ,
26
- StandardLibraryFunctionTypesPackage:: ctypeFunctionArgNotUnsignedCharOrEofQuery ( ) ) and
27
- not exists ( CtypeFunction ctype , UnsignedCharType unsignedChar |
28
- ctypeCall = ctype .getACallToThisFunction ( )
29
- |
30
- /* Case 1: The argument's value should be in the `unsigned char` range. */
31
- // Use `.getExplicitlyConverted` to consider inline argument casts.
32
- typeLowerBound ( unsignedChar ) <= lowerBound ( ctypeCall .getAnArgument ( ) .getExplicitlyConverted ( ) ) and
33
- upperBound ( ctypeCall .getAnArgument ( ) .getExplicitlyConverted ( ) ) <= typeUpperBound ( unsignedChar )
34
- or
35
- /* Case 2: EOF flows to this argument without modifications. */
36
- exists ( EOFInvocation eof |
37
- DataFlow:: localFlow ( DataFlow:: exprNode ( eof .getExpr ( ) ) ,
38
- DataFlow:: exprNode ( ctypeCall .getAnArgument ( ) ) )
39
- )
40
- )
41
- select ctypeCall ,
42
- "The <ctype.h> function " + ctypeCall + " accepts an argument " +
43
- ctypeCall .getAnArgument ( ) .toString ( ) + " that is not an unsigned char nor an EOF."
27
+ StandardLibraryFunctionTypesPackage:: ctypeFunctionArgNotUnsignedCharOrEofQuery ( ) )
28
+ // and
29
+ // not exists(CtypeFunction ctype, Expr ctypeCallArgument |
30
+ // ctype = ctypeCall.getTarget() and
31
+ // ctypeCallArgument = ctypeCall.getAnArgument().getExplicitlyConverted()
32
+ // |
33
+ // /* Case 1: The argument's value should be in the `unsigned char` range. */
34
+ // // Use `.getExplicitlyConverted` to consider inline argument casts.
35
+ // -1 <= lowerBound(ctypeCallArgument) and
36
+ // upperBound(ctypeCallArgument) <= 255
37
+ // or
38
+ // /* Case 2: EOF flows to this argument without modifications. */
39
+ // exists(EOFInvocation eof |
40
+ // DataFlow::localFlow(DataFlow::exprNode(eof.getExpr()), DataFlow::exprNode(ctypeCallArgument))
41
+ // )
42
+ // )
43
+ select ctypeCall .getAnArgument ( ) , lowerBound ( ctypeCall .getAnArgument ( ) ) ,
44
+ upperBound ( ctypeCall .getAnArgument ( ) )
45
+ // select ctypeCall,
46
+ // "The <ctype.h> function " + ctypeCall + " accepts an argument " +
47
+ // ctypeCall.getAnArgument().toString() + " that is not an unsigned char nor an EOF."
0 commit comments