File tree Expand file tree Collapse file tree 2 files changed +21
-3
lines changed
test/library-tests/dataflow/stream-read Expand file tree Collapse file tree 2 files changed +21
-3
lines changed Original file line number Diff line number Diff line change @@ -232,10 +232,10 @@ private class InputStreamWrapperAnonymousStep extends AdditionalTaintStep {
232
232
*/
233
233
private class InputStreamWrapperConstructorStep extends AdditionalTaintStep {
234
234
override predicate step ( DataFlow:: Node n1 , DataFlow:: Node n2 ) {
235
- exists ( ClassInstanceExpr cc , Argument a , AssignExpr ae |
235
+ exists ( ClassInstanceExpr cc , Argument a , AssignExpr ae , int pos |
236
236
cc .getConstructedType ( ) .getASourceSupertype + ( ) instanceof TypeInputStream and
237
- cc .getAnArgument ( ) = a and
238
- cc .getCallee ( ) .getParameter ( a . getParameterPos ( ) ) .getAnAccess ( ) = ae .getRhs ( ) and
237
+ cc .getArgument ( pragma [ only_bind_into ] ( pos ) ) = a and
238
+ cc .getCallee ( ) .getParameter ( pragma [ only_bind_into ] ( pos ) ) .getAnAccess ( ) = ae .getRhs ( ) and
239
239
ae .getDest ( ) .( FieldWrite ) .getField ( ) .getType ( ) .( RefType ) .getASourceSupertype * ( ) instanceof
240
240
TypeInputStream
241
241
|
Original file line number Diff line number Diff line change @@ -84,4 +84,22 @@ public int read(byte[] b) throws IOException {
84
84
sink (wrapper ); // $ hasTaintFlow
85
85
}
86
86
87
+ public static InputStream wrapStream (InputStream in ) {
88
+ return new InputStream () {
89
+ @ Override
90
+ public int read () throws IOException {
91
+ return 0 ;
92
+ }
93
+
94
+ @ Override
95
+ public int read (byte [] b ) throws IOException {
96
+ return in .read (b );
97
+ }
98
+ };
99
+ }
100
+
101
+ public static void testWrapCall () {
102
+ sink (wrapStream (null )); // no flow
103
+ sink (wrapStream (source ())); // $ hasTaintFlow
104
+ }
87
105
}
You can’t perform that action at this time.
0 commit comments