<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body style="word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">
I think it is fine to move the validation immediately following findEND() though I am not sure there is a big win overall.
<div class=""><br class="">
</div>
<div class="">I also would prefer to see the test based off of an actual ZIP(or at least have the current/modified version of the test).   I would prefer to avoid having another place where we have  duplicate code creating a CEN et al as it is another maintenance
 point.  </div>
<div class=""><br class="">
</div>
<div class="">One option is to look at, is to store a zip in a byte array and modify the cenlen offset(you would want to provide the steps that were used to create the zip/byte array, I can provide you a trivial example if interested) </div>
<div class=""><br class="">
</div>
<div class=""> Best,</div>
<div class="">Lance</div>
<div class="">
<div><br class="">
<blockquote type="cite" class="">
<div class="">On Jan 28, 2023, at 11:10 AM, Eirik Bjørsnøs <<a href="mailto:eirbjo@gmail.com" class="">eirbjo@gmail.com</a>> wrote:</div>
<br class="Apple-interchange-newline">
<div class="">
<div dir="ltr" class="">
<div dir="ltr" class="">On Sat, Jan 28, 2023 at 4:47 PM Alan Bateman <<a href="mailto:Alan.Bateman@oracle.com" class="">Alan.Bateman@oracle.com</a>> wrote:<br class="">
</div>
<div class="gmail_quote">
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
The intention of the test was exercise a multi-GB CEN. So I think it<br class="">
</blockquote>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
would be great if it could be re-written as an automatic test but I <br class="">
think it should be a real ZIP file, make use of sparse files might help.<br class="">
</blockquote>
<div class=""><br class="">
</div>
<div class="">Alan,</div>
<div class=""><br class="">
</div>
<div class="">Yes, this change does exploit some knowledge of the internals of ZipFile. Specifically it assumes that:</div>
<div class=""><br class="">
</div>
<div class="">1: ZipFile seeks to the end of the JAR where it parses the End of central directory header, then seeks backward to parse an optional Zip64 End of central directory record / locator. At this point the CEN size is known.</div>
<div class="">2: That a too-large CEN size (obtained from ZIP64 or the normal end-of-cen record) will be rejected early, before any attempt of reading the CEN or other contents of the ZIP.</div>
<div class="">3: That ZipFIle will treat a ZIP file starting with an End of Central directory (ZIP64 or not) as empty, short-circuiting any checking of invalid CEN sizes.</div>
<div class=""><br class="">
</div>
<div class="">Based on these assumptions, the test knows as a fact that any data up to and including the CEN is never read by ZipFile. It seems a bit wasteful to create multiple GBs of data which we know will never be read?</div>
<div class=""><br class="">
</div>
<div class="">If you still prefer the test to use ZIPs which are valid from top to bottom, I can take a stab at making that faster than the current test.</div>
<div class=""><br class="">
</div>
<div class="">WDYT?</div>
<div class=""><br class="">
</div>
<div class="">Eirik. </div>
<div class=""><br class="">
</div>
<div class=""> </div>
</div>
</div>
</div>
</blockquote>
</div>
<br class="">
<div class=""><span><img apple-inline="yes" id="88EAE715-FFDD-429E-992D-9C515942F991" src="cid:E1C4E2F0-ECD0-4C9D-ADB4-B16CA7BCB7FC@home" class=""></span>
<div dir="auto" style="font-family: Helvetica; font-size: 18px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; text-decoration: none; caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0); word-wrap: break-word; -webkit-nbsp-mode: space; line-break: after-white-space;" class="">
<div><br class="Apple-interchange-newline">
<br class="Apple-interchange-newline">
<br class="Apple-interchange-newline">
<br class="">
<br class="">
<br class="">
Lance Andersen | Principal Member of Technical Staff | +1.781.442.2037</div>
<div>Oracle Java Engineering <br class="">
1 Network Drive <br class="">
Burlington, MA 01803<br class="">
<a href="mailto:Lance.Andersen@oracle.com" class="">Lance.Andersen@oracle.com</a></div>
</div>
<br class="Apple-interchange-newline" style="font-family: Helvetica; font-size: 18px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; text-decoration: none; caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0);">
<br class="Apple-interchange-newline" style="font-family: Helvetica; font-size: 18px; font-style: normal; font-variant-caps: normal; font-weight: 400; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-size-adjust: auto; -webkit-text-stroke-width: 0px; text-decoration: none; caret-color: rgb(0, 0, 0); color: rgb(0, 0, 0);">
</div>
<br class="">
</div>
</body>
</html>