@@ -24,7 +24,7 @@ public static void ZipInputStreamSafe(InputStream inputStream) throws IOExceptio
2424 // FileInputStream fis = new FileInputStream(filename);
2525 CRC32 checkSum = new CRC32 ();
2626 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(...)"
2828 ZipEntry entry ;
2929 int entries = 0 ;
3030 long total = 0 ;
@@ -38,7 +38,7 @@ public static void ZipInputStreamSafe(InputStream inputStream) throws IOExceptio
3838 }
3939 FileOutputStream fos = new FileOutputStream ("/tmp/tmptmp" );
4040 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"
4242 dest .write (data , 0 , count );
4343 total += count ;
4444 }
@@ -63,7 +63,7 @@ public static void ZipInputStreamSafe2(InputStream inputStream) throws IOExcepti
6363 int BUFFER = 512 ;
6464 int TOOBIG = 100 * 1024 * 1024 ; // 100MB
6565 // 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(...)"
6767 ZipEntry entry ;
6868 while ((entry = zis .getNextEntry ()) != null ) {
6969 System .out .println ("Extracting: " + entry );
@@ -78,7 +78,7 @@ public static void ZipInputStreamSafe2(InputStream inputStream) throws IOExcepti
7878 }
7979 FileOutputStream fos = new FileOutputStream (entry .getName ());
8080 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"
8282 dest .write (data , 0 , count );
8383 }
8484 dest .flush ();
@@ -91,7 +91,7 @@ public static void ZipInputStreamSafe2(InputStream inputStream) throws IOExcepti
9191 public static void ZipInputStreamUnsafe (InputStream inputStream ) throws IOException {
9292 int BUFFER = 512 ;
9393 // 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(...)"
9595 ZipEntry entry ;
9696 while ((entry = zis .getNextEntry ()) != null ) {
9797 System .out .println ("Extracting: " + entry );
@@ -100,7 +100,7 @@ public static void ZipInputStreamUnsafe(InputStream inputStream) throws IOExcept
100100 // Write the files to the disk
101101 FileOutputStream fos = new FileOutputStream (entry .getName ());
102102 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"
104104 dest .write (data , 0 , count );
105105 }
106106 dest .flush ();
@@ -112,12 +112,12 @@ public static void ZipInputStreamUnsafe(InputStream inputStream) throws IOExcept
112112
113113 public static void GZipInputStreamUnsafe (InputStream inputStream ) throws IOException {
114114 int BUFFER = 512 ;
115- try (GZIPInputStream gzis = new GZIPInputStream (inputStream )) { // $bomb
115+ try (GZIPInputStream gzis = new GZIPInputStream (inputStream )) { // $ hasTaintFlow="inputStream"
116116 int count ;
117117 byte [] data = new byte [BUFFER ];
118118 FileOutputStream fos = new FileOutputStream ("/tmp/tmp" );
119119 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"
121121 dest .write (data , 0 , count );
122122 }
123123 dest .flush ();
@@ -127,12 +127,12 @@ public static void GZipInputStreamUnsafe(InputStream inputStream) throws IOExcep
127127
128128 public static void InflaterInputStreamUnsafe (InputStream inputStream ) throws IOException {
129129 int BUFFER = 512 ;
130- try (InflaterInputStream Izis = new InflaterInputStream (inputStream )) { // $bomb
130+ try (InflaterInputStream Izis = new InflaterInputStream (inputStream )) { // $ hasTaintFlow="inputStream"
131131 int count ;
132132 byte [] data = new byte [BUFFER ];
133133 FileOutputStream fos = new FileOutputStream ("/tmp/tmp" );
134134 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"
136136 dest .write (data , 0 , count );
137137 }
138138 dest .flush ();
@@ -142,7 +142,7 @@ public static void InflaterInputStreamUnsafe(InputStream inputStream) throws IOE
142142
143143 public static void InflaterUnsafe (byte [] inputBytes ) throws DataFormatException , IOException {
144144 Inflater inflater = new Inflater ();
145- inflater .setInput (inputBytes ); // $bomb
145+ inflater .setInput (inputBytes ); // $ hasTaintFlow="inputBytes"
146146 try (final ByteArrayOutputStream outputStream = new ByteArrayOutputStream (inputBytes .length )) {
147147 byte [] buffer = new byte [1024 ];
148148 while (!inflater .finished ()) {
@@ -156,7 +156,7 @@ public static void InflaterUnsafe(byte[] inputBytes) throws DataFormatException,
156156 public static void ZipFile1 (String zipFilePath ) throws DataFormatException , IOException {
157157 try {
158158 System .out .println ("zipFilePath = " + zipFilePath );
159- ZipFile zipFile = new ZipFile (zipFilePath ); // $bomb
159+ ZipFile zipFile = new ZipFile (zipFilePath ); // $ hasTaintFlow="zipFilePath"
160160 Enumeration <? extends ZipEntry > entries = zipFile .entries ();
161161 while (entries .hasMoreElements ()) {
162162 ZipEntry entry = entries .nextElement ();
@@ -169,7 +169,7 @@ public static void ZipFile1(String zipFilePath) throws DataFormatException, IOEx
169169 } else {
170170 String destPath = "tmp" + File .separator + entry .getName ();
171171
172- try (InputStream inputStream = zipFile .getInputStream (entry ); // $bomb
172+ try (InputStream inputStream = zipFile .getInputStream (entry ); // $ hasTaintFlow="zipFile"
173173 FileOutputStream outputStream = new FileOutputStream (destPath );) {
174174 int data = inputStream .read ();
175175 while (data != -1 ) {
0 commit comments