equal
deleted
inserted
replaced
32 import java.util.zip.*; |
32 import java.util.zip.*; |
33 import java.security.CodeSigner; |
33 import java.security.CodeSigner; |
34 import java.security.cert.Certificate; |
34 import java.security.cert.Certificate; |
35 import java.security.AccessController; |
35 import java.security.AccessController; |
36 import java.security.CodeSource; |
36 import java.security.CodeSource; |
|
37 import sun.misc.IOUtils; |
37 import sun.security.action.GetPropertyAction; |
38 import sun.security.action.GetPropertyAction; |
38 import sun.security.util.ManifestEntryVerifier; |
39 import sun.security.util.ManifestEntryVerifier; |
39 import sun.misc.SharedSecrets; |
40 import sun.misc.SharedSecrets; |
40 |
41 |
41 /** |
42 /** |
327 try { |
328 try { |
328 String[] names = getMetaInfEntryNames(); |
329 String[] names = getMetaInfEntryNames(); |
329 if (names != null) { |
330 if (names != null) { |
330 for (int i = 0; i < names.length; i++) { |
331 for (int i = 0; i < names.length; i++) { |
331 JarEntry e = getJarEntry(names[i]); |
332 JarEntry e = getJarEntry(names[i]); |
|
333 if (e == null) { |
|
334 throw new JarException("corrupted jar file"); |
|
335 } |
332 if (!e.isDirectory()) { |
336 if (!e.isDirectory()) { |
333 if (mev == null) { |
337 if (mev == null) { |
334 mev = new ManifestEntryVerifier |
338 mev = new ManifestEntryVerifier |
335 (getManifestFromReference()); |
339 (getManifestFromReference()); |
336 } |
340 } |
346 } catch (IOException ex) { |
350 } catch (IOException ex) { |
347 // if we had an error parsing any blocks, just |
351 // if we had an error parsing any blocks, just |
348 // treat the jar file as being unsigned |
352 // treat the jar file as being unsigned |
349 jv = null; |
353 jv = null; |
350 verify = false; |
354 verify = false; |
|
355 if (JarVerifier.debug != null) { |
|
356 JarVerifier.debug.println("jarfile parsing error!"); |
|
357 ex.printStackTrace(); |
|
358 } |
351 } |
359 } |
352 |
360 |
353 // if after initializing the verifier we have nothing |
361 // if after initializing the verifier we have nothing |
354 // signed, we null it out. |
362 // signed, we null it out. |
355 |
363 |
373 /* |
381 /* |
374 * Reads all the bytes for a given entry. Used to process the |
382 * Reads all the bytes for a given entry. Used to process the |
375 * META-INF files. |
383 * META-INF files. |
376 */ |
384 */ |
377 private byte[] getBytes(ZipEntry ze) throws IOException { |
385 private byte[] getBytes(ZipEntry ze) throws IOException { |
378 byte[] b = new byte[(int)ze.getSize()]; |
386 try (InputStream is = super.getInputStream(ze)) { |
379 try (DataInputStream is = new DataInputStream(super.getInputStream(ze))) { |
387 return IOUtils.readFully(is, (int)ze.getSize(), true); |
380 is.readFully(b, 0, b.length); |
388 } |
381 } |
|
382 return b; |
|
383 } |
389 } |
384 |
390 |
385 /** |
391 /** |
386 * Returns an input stream for reading the contents of the specified |
392 * Returns an input stream for reading the contents of the specified |
387 * zip file entry. |
393 * zip file entry. |
477 |
483 |
478 hasClassPathAttribute = false; |
484 hasClassPathAttribute = false; |
479 if (!isKnownToNotHaveClassPathAttribute()) { |
485 if (!isKnownToNotHaveClassPathAttribute()) { |
480 JarEntry manEntry = getManEntry(); |
486 JarEntry manEntry = getManEntry(); |
481 if (manEntry != null) { |
487 if (manEntry != null) { |
482 byte[] b = new byte[(int)manEntry.getSize()]; |
488 byte[] b = getBytes(manEntry); |
483 try (DataInputStream dis = new DataInputStream( |
|
484 super.getInputStream(manEntry))) { |
|
485 dis.readFully(b, 0, b.length); |
|
486 } |
|
487 |
|
488 int last = b.length - src.length; |
489 int last = b.length - src.length; |
489 int i = 0; |
490 int i = 0; |
490 next: |
491 next: |
491 while (i<=last) { |
492 while (i<=last) { |
492 for (int j=9; j>=0; j--) { |
493 for (int j=9; j>=0; j--) { |