classpath-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [cp-patches] Patch: minor ZipFile improvement


From: Tom Tromey
Subject: Re: [cp-patches] Patch: minor ZipFile improvement
Date: 15 Sep 2005 07:27:07 -0600
User-agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.3.50

>>>>> "Anthony" == Anthony Green <address@hidden> writes:

Anthony>    private void checkZipFile() throws IOException, ZipException
Anthony>    {
Anthony>      byte[] magicBuf = new byte[4];
Anthony> -    raf.read(magicBuf);
Anthony> -    if (readLeInt(magicBuf, 0) != LOCSIG)
Anthony> +    if (raf.read(magicBuf) != 4
Anthony> +      || readLeInt(magicBuf, 0) != LOCSIG)
Anthony>        {
Anthony>        raf.close();
Anthony>        throw new ZipException("Not a valid zip file");

Actually we ought to try reading until we get all 4 bytes or see EOF.
A short read is valid and not an error.

Tom




reply via email to

[Prev in Thread] Current Thread [Next in Thread]