@@ -24,7 +24,7 @@ public static void ZipInputStreamSafe(InputStream inputStream) throws IOExceptio
24
24
// FileInputStream fis = new FileInputStream(filename);
25
25
CRC32 checkSum = new CRC32 ();
26
26
CheckedInputStream gzis = new CheckedInputStream (inputStream , checkSum );
27
- try (ZipInputStream zis = new ZipInputStream (new BufferedInputStream (inputStream ))) { // $bomb
27
+ try (ZipInputStream zis = new ZipInputStream (new BufferedInputStream (inputStream ))) { // $ hasTaintFlow="new BufferedInputStream(...)"
28
28
ZipEntry entry ;
29
29
int entries = 0 ;
30
30
long total = 0 ;
@@ -38,7 +38,7 @@ public static void ZipInputStreamSafe(InputStream inputStream) throws IOExceptio
38
38
}
39
39
FileOutputStream fos = new FileOutputStream ("/tmp/tmptmp" );
40
40
BufferedOutputStream dest = new BufferedOutputStream (fos , BUFFER );
41
- while (total + BUFFER <= TOOBIG && (count = zis .read (data , 0 , BUFFER )) != -1 ) { // $bomb
41
+ while (total + BUFFER <= TOOBIG && (count = zis .read (data , 0 , BUFFER )) != -1 ) { // $ hasTaintFlow="zis"
42
42
dest .write (data , 0 , count );
43
43
total += count ;
44
44
}
@@ -63,7 +63,7 @@ public static void ZipInputStreamSafe2(InputStream inputStream) throws IOExcepti
63
63
int BUFFER = 512 ;
64
64
int TOOBIG = 100 * 1024 * 1024 ; // 100MB
65
65
// FileInputStream fis = new FileInputStream(filename);
66
- try (ZipInputStream zis = new ZipInputStream (new BufferedInputStream (inputStream ))) { // $bomb
66
+ try (ZipInputStream zis = new ZipInputStream (new BufferedInputStream (inputStream ))) { // $ hasTaintFlow="new BufferedInputStream(...)"
67
67
ZipEntry entry ;
68
68
while ((entry = zis .getNextEntry ()) != null ) {
69
69
System .out .println ("Extracting: " + entry );
@@ -78,7 +78,7 @@ public static void ZipInputStreamSafe2(InputStream inputStream) throws IOExcepti
78
78
}
79
79
FileOutputStream fos = new FileOutputStream (entry .getName ());
80
80
BufferedOutputStream dest = new BufferedOutputStream (fos , BUFFER );
81
- while ((count = zis .read (data , 0 , BUFFER )) != -1 ) { // $bomb
81
+ while ((count = zis .read (data , 0 , BUFFER )) != -1 ) { // $ hasTaintFlow="zis"
82
82
dest .write (data , 0 , count );
83
83
}
84
84
dest .flush ();
@@ -91,7 +91,7 @@ public static void ZipInputStreamSafe2(InputStream inputStream) throws IOExcepti
91
91
public static void ZipInputStreamUnsafe (InputStream inputStream ) throws IOException {
92
92
int BUFFER = 512 ;
93
93
// FileInputStream fis = new FileInputStream(filename);
94
- try (ZipInputStream zis = new ZipInputStream (new BufferedInputStream (inputStream ))) { // $bomb
94
+ try (ZipInputStream zis = new ZipInputStream (new BufferedInputStream (inputStream ))) { // $ hasTaintFlow="new BufferedInputStream(...)"
95
95
ZipEntry entry ;
96
96
while ((entry = zis .getNextEntry ()) != null ) {
97
97
System .out .println ("Extracting: " + entry );
@@ -100,7 +100,7 @@ public static void ZipInputStreamUnsafe(InputStream inputStream) throws IOExcept
100
100
// Write the files to the disk
101
101
FileOutputStream fos = new FileOutputStream (entry .getName ());
102
102
BufferedOutputStream dest = new BufferedOutputStream (fos , BUFFER );
103
- while ((count = zis .read (data , 0 , BUFFER )) != -1 ) { // $bomb
103
+ while ((count = zis .read (data , 0 , BUFFER )) != -1 ) { // $ hasTaintFlow="zis"
104
104
dest .write (data , 0 , count );
105
105
}
106
106
dest .flush ();
@@ -112,12 +112,12 @@ public static void ZipInputStreamUnsafe(InputStream inputStream) throws IOExcept
112
112
113
113
public static void GZipInputStreamUnsafe (InputStream inputStream ) throws IOException {
114
114
int BUFFER = 512 ;
115
- try (GZIPInputStream gzis = new GZIPInputStream (inputStream )) { // $bomb
115
+ try (GZIPInputStream gzis = new GZIPInputStream (inputStream )) { // $ hasTaintFlow="inputStream"
116
116
int count ;
117
117
byte [] data = new byte [BUFFER ];
118
118
FileOutputStream fos = new FileOutputStream ("/tmp/tmp" );
119
119
BufferedOutputStream dest = new BufferedOutputStream (fos , BUFFER );
120
- while ((count = gzis .read (data , 0 , BUFFER )) != -1 ) { // $bomb
120
+ while ((count = gzis .read (data , 0 , BUFFER )) != -1 ) { // $ hasTaintFlow="gzis"
121
121
dest .write (data , 0 , count );
122
122
}
123
123
dest .flush ();
@@ -127,12 +127,12 @@ public static void GZipInputStreamUnsafe(InputStream inputStream) throws IOExcep
127
127
128
128
public static void InflaterInputStreamUnsafe (InputStream inputStream ) throws IOException {
129
129
int BUFFER = 512 ;
130
- try (InflaterInputStream Izis = new InflaterInputStream (inputStream )) { // $bomb
130
+ try (InflaterInputStream Izis = new InflaterInputStream (inputStream )) { // $ hasTaintFlow="inputStream"
131
131
int count ;
132
132
byte [] data = new byte [BUFFER ];
133
133
FileOutputStream fos = new FileOutputStream ("/tmp/tmp" );
134
134
BufferedOutputStream dest = new BufferedOutputStream (fos , BUFFER );
135
- while ((count = Izis .read (data , 0 , BUFFER )) != -1 ) { // $bomb
135
+ while ((count = Izis .read (data , 0 , BUFFER )) != -1 ) { // $ hasTaintFlow="Izis"
136
136
dest .write (data , 0 , count );
137
137
}
138
138
dest .flush ();
@@ -142,7 +142,7 @@ public static void InflaterInputStreamUnsafe(InputStream inputStream) throws IOE
142
142
143
143
public static void InflaterUnsafe (byte [] inputBytes ) throws DataFormatException , IOException {
144
144
Inflater inflater = new Inflater ();
145
- inflater .setInput (inputBytes ); // $bomb
145
+ inflater .setInput (inputBytes ); // $ hasTaintFlow="inputBytes"
146
146
try (final ByteArrayOutputStream outputStream = new ByteArrayOutputStream (inputBytes .length )) {
147
147
byte [] buffer = new byte [1024 ];
148
148
while (!inflater .finished ()) {
@@ -156,7 +156,7 @@ public static void InflaterUnsafe(byte[] inputBytes) throws DataFormatException,
156
156
public static void ZipFile1 (String zipFilePath ) throws DataFormatException , IOException {
157
157
try {
158
158
System .out .println ("zipFilePath = " + zipFilePath );
159
- ZipFile zipFile = new ZipFile (zipFilePath ); // $bomb
159
+ ZipFile zipFile = new ZipFile (zipFilePath ); // $ hasTaintFlow="zipFilePath"
160
160
Enumeration <? extends ZipEntry > entries = zipFile .entries ();
161
161
while (entries .hasMoreElements ()) {
162
162
ZipEntry entry = entries .nextElement ();
@@ -169,7 +169,7 @@ public static void ZipFile1(String zipFilePath) throws DataFormatException, IOEx
169
169
} else {
170
170
String destPath = "tmp" + File .separator + entry .getName ();
171
171
172
- try (InputStream inputStream = zipFile .getInputStream (entry ); // $bomb
172
+ try (InputStream inputStream = zipFile .getInputStream (entry ); // $ hasTaintFlow="zipFile"
173
173
FileOutputStream outputStream = new FileOutputStream (destPath );) {
174
174
int data = inputStream .read ();
175
175
while (data != -1 ) {
0 commit comments