RFR: 8242882: opening jar file with large manifest might throw NegativeArraySizeException [v2]

Brent Christian bchristi at openjdk.java.net
Thu Oct 8 06:55:24 UTC 2020


On Thu, 1 Oct 2020 14:39:50 GMT, Jaikiran Pai <jpai at openjdk.org> wrote:

>> test/jdk/java/util/jar/JarFile/LargeManifestOOMTest.java line 78:
>> 
>>> 76:             bw.write("OOM-Test: ");
>>> 77:             for (long i = 0; i < 2147483648L; i++) {
>>> 78:                 bw.write("a");
>> 
>> As you probably noticed, this test takes a little while to run.  One way to speed it up a little would be to write more
>> characters at a time.  While we're at it, we may as well make the Manifest well-formed by breaking it into 72-byte
>> lines.  See "Line length" under:
>> https://docs.oracle.com/en/java/javase/15/docs/specs/jar/jar.html#notes-on-manifest-and-signature-files  Just write
>> enough lines to exceed Integer.MAX_VALUE bytes.
>
> I decided to slightly change the way this large manifest file was being created. I borrowed the idea from
> `Zip64SizeTest`[1] to create the file and set its length to a large value. I hope that is OK. If not, let me know, I
> will change this part.  [1]
> https://github.com/openjdk/jdk/blob/master/test/jdk/java/util/zip/ZipFile/Zip64SizeTest.java#L121

I did some automated test runs, and the duration of this test is sufficiently improved, IMO.

While not representative of a real MANIFEST.MF file, I think it works well enough for this specific test.

-------------

PR: https://git.openjdk.java.net/jdk/pull/323



More information about the security-dev mailing list