-
Bug
-
Resolution: Not an Issue
-
P3
-
None
-
6u31
-
x86
-
windows_7
FULL PRODUCT VERSION :
java version "1.6.0_29"
Java(TM) SE Runtime Environment (build 1.6.0_29-b11)
Java HotSpot(TM) Client VM (build 20.4-b02, mixed mode, sharing)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows [version 6.1.7601]
A DESCRIPTION OF THE PROBLEM :
when i read a zip file as a inputstream,it cause
java.util.zip.ZipException: invalid entry compressed size
I think the zlib 1.2+,add a new Adler byte after the zip entry data.
REGRESSION. Last worked in version 6u31
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
when i read this file(it's a zip) as a stream.
file's data,use InputStream.read():
80 75 3 4 0 0 0 0 8 0 0 0 0 0 241 235 10 226 247 0 0 0 177 1 0 0 7 0 0 0 79 70 68 46 120 109 108 85 144 77 111 131 48 12 134 239 147 246 31 162 220 249 8 31 165 138 32 149 74 130 180 211 164 137 237 58 85 144 118 72 107 140 32 27 237 191 159 71 161 133 75 156 215 126 94 203 118 186 187 156 191 201 175 238 250 6 76 70 153 235 83 162 77 5 117 99 78 25 125 47 11 103 75 119 34 133 99 205 95 11 73 16 54 61 71 149 209 47 107 91 238 121 195 48 184 168 251 86 87 46 116 39 74 62 86 189 36 84 229 181 213 25 69 55 189 245 193 212 30 234 235 93 188 152 35 60 132 20 42 76 228 62 137 35 166 100 30 197 69 188 9 101 158 168 60 12 21 99 76 109 139 212 123 176 207 79 163 49 239 244 193 66 39 10 184 52 150 252 15 58 101 110 236 92 94 211 211 160 2 231 92 97 115 126 73 163 150 7 171 69 224 179 192 137 156 32 41 25 227 225 134 179 165 117 134 208 232 45 119 155 26 161 124 3 176 2 227 167 239 225 251 115 214 198 186 120 210 59 62 214 23 246 241 78 179 198 181 240 255 7 193 8 137 35 80 75 1 2 0 0 0 0 0 0 8 0 0 0 0 0 241 235 10 226 247 0 0 0 177 1 0 0 7 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 79 70 68 46 120 109 108 80 75 5 6 0 0 0 0 1 0 1 0 53 0 0 0 28 1 0 0 0 0
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
print the zip entry OFD.xml content
ACTUAL -
throw exception
ERROR MESSAGES/STACK TRACES THAT OCCUR :
java.util.zip.ZipException: invalid entry compressed size (expected 247 but got 243 bytes)
at java.util.zip.ZipInputStream.readEnd(ZipInputStream.java:408)
at java.util.zip.ZipInputStream.read(ZipInputStream.java:195)
at java.io.FilterInputStream.read(FilterInputStream.java:107)
at test.CommonTest.read(CommonTest.java:46)
at test.CommonTest.main(CommonTest.java:28)
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
public class CommonTest {
/**
* @param args
*/
public static void main(String[] args) {
try {
read("test-zlib.zip");
} catch (IOException e) {
e.printStackTrace();
}
}
private static void read(String name) throws IOException {
InputStream is = CommonTest.class.getResourceAsStream(name);
CheckedInputStream cis = new CheckedInputStream(is, new Adler32());
ZipInputStream zis = new ZipInputStream(cis);
ZipEntry entry = null;
try {
while ((entry = zis.getNextEntry()) != null) {
String en = entry.getName();
System.out.println("------ " + en + " ------");
byte[] b = new byte[1024];
int l = -1;
ByteArrayOutputStream baos = new ByteArrayOutputStream();
while ((l = zis.read(b)) != -1) {
baos.write(b, 0, l);
}
System.out.println(new String(baos.toByteArray(), "UTF-8"));
zis.closeEntry();
}
System.out.println(cis.getChecksum().getValue());
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
zis.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
ZipInputStream must be cause exception,but ZipFile is OK.
so can be save stream to a temp file,then read this file....
It will be slow and I/O more.
java version "1.6.0_29"
Java(TM) SE Runtime Environment (build 1.6.0_29-b11)
Java HotSpot(TM) Client VM (build 20.4-b02, mixed mode, sharing)
ADDITIONAL OS VERSION INFORMATION :
Microsoft Windows [version 6.1.7601]
A DESCRIPTION OF THE PROBLEM :
when i read a zip file as a inputstream,it cause
java.util.zip.ZipException: invalid entry compressed size
I think the zlib 1.2+,add a new Adler byte after the zip entry data.
REGRESSION. Last worked in version 6u31
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
when i read this file(it's a zip) as a stream.
file's data,use InputStream.read():
80 75 3 4 0 0 0 0 8 0 0 0 0 0 241 235 10 226 247 0 0 0 177 1 0 0 7 0 0 0 79 70 68 46 120 109 108 85 144 77 111 131 48 12 134 239 147 246 31 162 220 249 8 31 165 138 32 149 74 130 180 211 164 137 237 58 85 144 118 72 107 140 32 27 237 191 159 71 161 133 75 156 215 126 94 203 118 186 187 156 191 201 175 238 250 6 76 70 153 235 83 162 77 5 117 99 78 25 125 47 11 103 75 119 34 133 99 205 95 11 73 16 54 61 71 149 209 47 107 91 238 121 195 48 184 168 251 86 87 46 116 39 74 62 86 189 36 84 229 181 213 25 69 55 189 245 193 212 30 234 235 93 188 152 35 60 132 20 42 76 228 62 137 35 166 100 30 197 69 188 9 101 158 168 60 12 21 99 76 109 139 212 123 176 207 79 163 49 239 244 193 66 39 10 184 52 150 252 15 58 101 110 236 92 94 211 211 160 2 231 92 97 115 126 73 163 150 7 171 69 224 179 192 137 156 32 41 25 227 225 134 179 165 117 134 208 232 45 119 155 26 161 124 3 176 2 227 167 239 225 251 115 214 198 186 120 210 59 62 214 23 246 241 78 179 198 181 240 255 7 193 8 137 35 80 75 1 2 0 0 0 0 0 0 8 0 0 0 0 0 241 235 10 226 247 0 0 0 177 1 0 0 7 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 79 70 68 46 120 109 108 80 75 5 6 0 0 0 0 1 0 1 0 53 0 0 0 28 1 0 0 0 0
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
print the zip entry OFD.xml content
ACTUAL -
throw exception
ERROR MESSAGES/STACK TRACES THAT OCCUR :
java.util.zip.ZipException: invalid entry compressed size (expected 247 but got 243 bytes)
at java.util.zip.ZipInputStream.readEnd(ZipInputStream.java:408)
at java.util.zip.ZipInputStream.read(ZipInputStream.java:195)
at java.io.FilterInputStream.read(FilterInputStream.java:107)
at test.CommonTest.read(CommonTest.java:46)
at test.CommonTest.main(CommonTest.java:28)
REPRODUCIBILITY :
This bug can be reproduced always.
---------- BEGIN SOURCE ----------
public class CommonTest {
/**
* @param args
*/
public static void main(String[] args) {
try {
read("test-zlib.zip");
} catch (IOException e) {
e.printStackTrace();
}
}
private static void read(String name) throws IOException {
InputStream is = CommonTest.class.getResourceAsStream(name);
CheckedInputStream cis = new CheckedInputStream(is, new Adler32());
ZipInputStream zis = new ZipInputStream(cis);
ZipEntry entry = null;
try {
while ((entry = zis.getNextEntry()) != null) {
String en = entry.getName();
System.out.println("------ " + en + " ------");
byte[] b = new byte[1024];
int l = -1;
ByteArrayOutputStream baos = new ByteArrayOutputStream();
while ((l = zis.read(b)) != -1) {
baos.write(b, 0, l);
}
System.out.println(new String(baos.toByteArray(), "UTF-8"));
zis.closeEntry();
}
System.out.println(cis.getChecksum().getValue());
} catch (IOException e) {
e.printStackTrace();
} finally {
try {
zis.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
---------- END SOURCE ----------
CUSTOMER SUBMITTED WORKAROUND :
ZipInputStream must be cause exception,but ZipFile is OK.
so can be save stream to a temp file,then read this file....
It will be slow and I/O more.