@@ -16,6 +16,8 @@ class PureStrFunction extends AliasFunction, ArrayFunction, TaintFunction, Side
1616 or name = "strchnul"
1717 or name = "strchr"
1818 or name = "strchrnul"
19+ or name = "strstr"
20+ or name = "strpbrk"
1921 or name = "strcmp"
2022 or name = "strcspn"
2123 or name = "strlen"
@@ -46,68 +48,22 @@ class PureStrFunction extends AliasFunction, ArrayFunction, TaintFunction, Side
4648 )
4749 ) and
4850 (
49- output .isOutReturnValue ( )
51+ output .isOutReturnValue ( ) or
52+ output .isOutReturnPointer ( )
5053 )
5154 }
5255
5356 override predicate parameterNeverEscapes ( int i ) {
54- getParameter ( i ) .getUnspecifiedType ( ) instanceof PointerType
55- }
56-
57- override predicate parameterEscapesOnlyViaReturn ( int i ) {
58- none ( )
59- }
60-
61- override predicate parameterIsAlwaysReturned ( int i ) {
62- none ( )
63- }
64-
65- override predicate neverReadsMemory ( ) {
66- none ( )
67- }
68-
69- override predicate neverWritesMemory ( ) {
70- any ( )
71- }
72- }
73- class PureReturningStrFunction extends AliasFunction , ArrayFunction , TaintFunction , SideEffectFunction {
74- PureReturningStrFunction ( ) {
75- exists ( string name |
76- hasName ( name ) and
77- (
78- name = "strstr" or
79- name = "strpbrk"
80- )
57+ getParameter ( i ) .getUnspecifiedType ( ) instanceof PointerType and
58+ not (
59+ i = 0 and
60+ getType ( ) .getUnspecifiedType ( ) instanceof PointerType
8161 )
8262 }
83-
84- override predicate hasArrayInput ( int bufParam ) {
85- getParameter ( bufParam ) .getUnspecifiedType ( ) instanceof PointerType
86- }
87-
88- override predicate hasTaintFlow ( FunctionInput input , FunctionOutput output ) {
89- exists ( ParameterIndex i |
90- input .isInParameter ( i ) or
91- (
92- input .isInParameterPointer ( i ) and
93- getParameter ( i ) .getUnspecifiedType ( ) instanceof PointerType
94- )
95- ) and
96- (
97- (
98- output .isOutReturnPointer ( ) and
99- getUnspecifiedType ( ) instanceof PointerType
100- ) or
101- output .isOutReturnValue ( )
102- )
103- }
104-
105- override predicate parameterNeverEscapes ( int i ) {
106- i = 1
107- }
10863
10964 override predicate parameterEscapesOnlyViaReturn ( int i ) {
110- i = 0
65+ i = 0 and
66+ getType ( ) .getUnspecifiedType ( ) instanceof PointerType
11167 }
11268
11369 override predicate parameterIsAlwaysReturned ( int i ) {
0 commit comments