File tree Expand file tree Collapse file tree 2 files changed +16
-2
lines changed
Expand file tree Collapse file tree 2 files changed +16
-2
lines changed Original file line number Diff line number Diff line change @@ -127,7 +127,7 @@ private void consumeHeader() throws IOException {
127127 if (((flags >> FEXTRA ) & 1 ) == 1 ) {
128128 source .require (2 );
129129 if (fhcrc ) updateCrc (source .buffer (), 0 , 2 );
130- int xlen = source .buffer ().readShortLe ();
130+ int xlen = source .buffer ().readShortLe () & 0xffff ;
131131 source .require (xlen );
132132 if (fhcrc ) updateCrc (source .buffer (), 0 , xlen );
133133 source .skip (xlen );
Original file line number Diff line number Diff line change 1515 */
1616package okio ;
1717
18+ import org .junit .Test ;
19+
20+ import java .io .ByteArrayOutputStream ;
1821import java .io .IOException ;
1922import java .util .zip .CRC32 ;
20- import org .junit .Test ;
2123
2224import static okio .Util .UTF_8 ;
2325import static org .junit .Assert .assertEquals ;
@@ -182,6 +184,18 @@ private void assertGzipped(Buffer gzipped) throws IOException {
182184 }
183185 }
184186
187+ @ Test public void extraLongXlen () throws Exception {
188+ int xlen = 0xffff ;
189+ Buffer gzippedSource = new Buffer ()
190+ .write (gzipHeaderWithFlags ((byte ) 0x04 ));
191+ gzippedSource .writeShort ((short ) xlen );
192+ gzippedSource .write (new byte [xlen ]);
193+ gzippedSource .write (ByteString .decodeHex ("f3c8540400dac59e7903000000" ));
194+
195+ Buffer gunzipped = gunzip (gzippedSource );
196+ assertEquals ("Hi!" , gunzipped .readUtf8 ());
197+ }
198+
185199 private ByteString gzipHeaderWithFlags (byte flags ) {
186200 byte [] result = gzipHeader .toByteArray ();
187201 result [3 ] = flags ;
You can’t perform that action at this time.
0 commit comments