View | Details | Raw Unified | Return to bug 36560 | Differences between
and this patch

Collapse All | Expand All

(-)java/util/zip/ZipFile.java (-1 / +5 lines)
Lines 261-267 Link Here
261
	if (inp.readLeInt() != CENSIG)
261
	if (inp.readLeInt() != CENSIG)
262
	  throw new ZipException("Wrong Central Directory signature: " + name);
262
	  throw new ZipException("Wrong Central Directory signature: " + name);
263
263
264
        inp.skip(6);
264
        inp.skip(4);
265
    int generalPurposeFlags = inp.readLeShort();
265
	int method = inp.readLeShort();
266
	int method = inp.readLeShort();
266
	int dostime = inp.readLeInt();
267
	int dostime = inp.readLeInt();
267
	int crc = inp.readLeInt();
268
	int crc = inp.readLeInt();
Lines 275-280 Link Here
275
	String name = inp.readString(nameLen);
276
	String name = inp.readString(nameLen);
276
277
277
	ZipEntry entry = new ZipEntry(name);
278
	ZipEntry entry = new ZipEntry(name);
279
    entry.setGeneralPurposeFlags(generalPurposeFlags);
278
	entry.setMethod(method);
280
	entry.setMethod(method);
279
	entry.setCrc(crc & 0xffffffffL);
281
	entry.setCrc(crc & 0xffffffffL);
280
	entry.setSize(size & 0xffffffffL);
282
	entry.setSize(size & 0xffffffffL);
Lines 422-427 Link Here
422
    ZipEntry zipEntry = entries.get(name);
424
    ZipEntry zipEntry = entries.get(name);
423
    if (zipEntry == null)
425
    if (zipEntry == null)
424
      return null;
426
      return null;
427
    if (zipEntry.isEncrypted())
428
      throw new ZipException("Entry is encrypted");
425
429
426
    PartialInputStream inp = new PartialInputStream(raf, 1024);
430
    PartialInputStream inp = new PartialInputStream(raf, 1024);
427
    inp.seek(zipEntry.offset);
431
    inp.seek(zipEntry.offset);
(-)java/util/zip/ZipEntry.java (+22 lines)
Lines 64-69 Link Here
64
  private int crc;
64
  private int crc;
65
  private int dostime;
65
  private int dostime;
66
  private short known = 0;
66
  private short known = 0;
67
  private short generalPurposeFlags;
67
  private short method = -1;
68
  private short method = -1;
68
  private byte[] extra = null;
69
  private byte[] extra = null;
69
  private String comment = null;
70
  private String comment = null;
Lines 290-295 Link Here
290
  }
291
  }
291
292
292
  /**
293
  /**
294
   * Sets in the value of the general purpose flags for the zip entry.
295
   *
296
   * @param generalPurposeFlags the general purpose flags.
297
   */
298
  void setGeneralPurposeFlags(int generalPurposeFlags)
299
  {
300
    this.generalPurposeFlags = (short) generalPurposeFlags;
301
  }
302
303
  /**
304
   * Uses the general purpose flags to determine whether the entry is encrypted.
305
   *
306
   * @return {@code true} if the entry is encrypted, {@code false} otherwise.
307
   */
308
  boolean isEncrypted()
309
  {
310
    // bit 0 means it's encrypted.  bit 6 means strong encryption but in this case bit 0 is still set.
311
    return (generalPurposeFlags & 0x1) != 0;
312
  }
313
314
  /**
293
   * Sets the compression method.  Only DEFLATED and STORED are
315
   * Sets the compression method.  Only DEFLATED and STORED are
294
   * supported.
316
   * supported.
295
   * @exception IllegalArgumentException if method is not supported.
317
   * @exception IllegalArgumentException if method is not supported.

Return to bug 36560