File tree Expand file tree Collapse file tree
cpp/ql/src/Security/CWE/CWE-468 Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1313import cpp
1414import IncorrectPointerScalingCommon
1515
16- private predicate isCharPtrExpr ( Expr e ) {
16+ private predicate isCharSzPtrExpr ( Expr e ) {
1717 exists ( PointerType pt
1818 | pt = e .getFullyConverted ( ) .getUnderlyingType ( )
19- | pt .getBaseType ( ) .getUnspecifiedType ( ) instanceof CharType )
19+ | pt .getBaseType ( ) .getUnspecifiedType ( ) instanceof CharType
20+ or pt .getBaseType ( ) .getUnspecifiedType ( ) instanceof VoidType )
2021}
2122
2223from Expr sizeofExpr , Expr e
2324where
2425 // If we see an addWithSizeof then we expect the type of
25- // the pointer expression to be char*. Otherwise it is probably
26- // a mistake.
27- addWithSizeof ( e , sizeofExpr , _) and not isCharPtrExpr ( e )
26+ // the pointer expression to be char* or void* . Otherwise it
27+ // is probably a mistake.
28+ addWithSizeof ( e , sizeofExpr , _) and not isCharSzPtrExpr ( e )
2829select
2930 sizeofExpr ,
3031 "Suspicious sizeof offset in a pointer arithmetic expression. " +
You can’t perform that action at this time.
0 commit comments