Bug (old?) in ZipEntry?
Martin Egholm Nielsen
martin@egholm-nielsen.dk
Tue Sep 13 13:55:00 GMT 2005
>>>I think I have found the problem. The "fromzip.zip" archive
>>>contains an additional timestamp entry for "ZipDates.java":
>>>
>>>Current Location part 1 offset 43
>>> extra field 0x5455 (universal time), 4 header and 9 data bytes:
>>> 03 90 5d 21 43 f6 5d 21 43 ..]!C.]!C
>>> extra field 0x7855 (Unix UID/GID), 4 header and 4 data bytes:
>>> 20 02 11 29 ..)
>>>
>>>The modification timestamp is "1126260112" which is *seconds*
>>>since *the standard UNIX epoch* (i.e., it is *not* a dostime).
>
> [...]
>
>>>Our ZipEntry code (both in libgcj/classpath) treats it as a
>>>dostime, leading to the error that you have noticed.
>
> This part is wrong - I misread the code.
>
>>>Please file a bug report against classpath, including a link to
>>>this message, if possible.
>>
>>Hereby done!
>
> If I patch GCJ's java/util/zip/ZipEntry.java as shown later, I get:
>
> ~/tmp/men > mygij ZipDates fromzip.zip
> ZipDates.java date: 1126260112000 Fri Sep 09 15:31:52 GMT+05:30 2005
>
> ~/tmp/men > java ZipDates fromzip.zip
> ZipDates.java date: 1126247512000 Fri Sep 09 12:01:52 IST 2005
>
> Note that GCJ still seems off by 3.5 hours.
> However, according to the
> docs, the given timestamp is seconds from epoch *UTC*, which *does*
> translate to the time shown by GCJ. To confuse things further, the ZIP's
> "normal" entry for "ZipDates.java" (not the 0x5455 extension entry
> shown earlier) says it is the time reported by the JDK. (What is your
> timezone? Is it GMT+02:00?)
Yes! So the 3.5h offset is the difference between you and me.
I created the file 12:01:52 GMT+02:00 (so it's really 10:01 UTC), the
time JDK reports for you, however, in your timezone (so it thinks it has
time 06:31 UTC - JDK error).
So, actually GCJ/Classpath does it correctly, since 15:31:52 GMT+05:30
is 10:31 UTC - the actual time of the file.
(Messy written - I know)
> So either the JDK is showing only the "normal" entry without taking
> the extension entry into account or the reference document that I
> cited earlier has it wrong (unlikely). Either ways, your original
> archiver program (the one that created the "fromzip.zip" archive)
> is lying about the modification time in one of the entries.
Yes, I think my archiver puts the time in plus the timezone offset...
> The patch I was talking of was:
I'm doing a new libgcj as we speak - looking forward to try it!
Thanks Ranjit!
// Martin
> - ------------------------------- 8< -------------------------------
> Index: java/util/zip/ZipEntry.java
> ===================================================================
> - --- java/util/zip/ZipEntry.java 2005-09-13 13:40:41.000000000 +0530
> +++ java/util/zip/ZipEntry.java 2005-09-13 15:43:40.000000000 +0530
> @@ -168,5 +168,5 @@ public class ZipEntry implements ZipCons
> synchronized (cal)
> {
> - - cal.setTime(new Date(time));
> + cal.setTimeInMillis(time);
> dostime = (cal.get(Calendar.YEAR) - 1980 & 0x7f) << 25
> | (cal.get(Calendar.MONTH) + 1) << 21
> @@ -337,5 +337,5 @@ public class ZipEntry implements ZipCons
> | (extra[pos+3] & 0xff) << 16
> | (extra[pos+4] & 0xff) << 24);
> - - setTime(time);
> + setTime(time*1000);
> }
> }
> - ------------------------------- 8< -------------------------------
>
> Ranjit.
>
> - --
> Ranjit Mathew Email: rmathew AT gmail DOT com
>
> Bangalore, INDIA. Web: http://ranjitmathew.hostingzero.com/
>
>
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.2 (MingW32)
> Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org
>
> iD8DBQFDJq8rYb1hx2wRS48RAsgEAJwOuoDs1RVvhj/GO7DRY6LixsPHaACeN+GW
> E2iucXRl4mRLmTiHAA9c+zg=
> =LpSq
> -----END PGP SIGNATURE-----
>
More information about the Java
mailing list