diff options
| author | Anthony Green <green@redhat.com> | 2005-09-16 01:07:20 +0000 |
|---|---|---|
| committer | Anthony Green <green@redhat.com> | 2005-09-16 01:07:20 +0000 |
| commit | 87c07227334ec01b9246e19fb9fc154c034a270e (patch) | |
| tree | d7693e50fc139925ab5a73278795a4317287b970 /java/util/zip/ZipFile.java | |
| parent | 84e0bee4e312043c8878820b446bea74fb9eda70 (diff) | |
| download | classpath-87c07227334ec01b9246e19fb9fc154c034a270e.tar.gz | |
* java/util/zip/ZipFile.java (checkZipFile): Make sure we read the
4 byte magic number.
Diffstat (limited to 'java/util/zip/ZipFile.java')
| -rw-r--r-- | java/util/zip/ZipFile.java | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/java/util/zip/ZipFile.java b/java/util/zip/ZipFile.java index 9191ea7d1..4be845ea7 100644 --- a/java/util/zip/ZipFile.java +++ b/java/util/zip/ZipFile.java @@ -144,9 +144,18 @@ public class ZipFile implements ZipConstants private void checkZipFile() throws IOException, ZipException { byte[] magicBuf = new byte[4]; - raf.read(magicBuf); + boolean validRead = true; - if (readLeInt(magicBuf, 0) != LOCSIG) + try + { + raf.readFully(magicBuf); + } + catch (EOFException eof) + { + validRead = false; + } + + if (validRead == false || readLeInt(magicBuf, 0) != LOCSIG) { raf.close(); throw new ZipException("Not a valid zip file"); |
