8146431: j.u.z.ZipFile.getEntry("") throws AIOOBE
Reviewed-by: lancea
This commit is contained in:
parent
3da2de846c
commit
9b77da0f46
@ -1251,7 +1251,7 @@ class ZipFile implements ZipConstants, Closeable {
|
|||||||
idx = getEntryNext(idx);
|
idx = getEntryNext(idx);
|
||||||
}
|
}
|
||||||
/* If not addSlash, or slash is already there, we are done */
|
/* If not addSlash, or slash is already there, we are done */
|
||||||
if (!addSlash || name[name.length - 1] == '/') {
|
if (!addSlash || name.length == 0 || name[name.length - 1] == '/') {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
/* Add slash and try once more */
|
/* Add slash and try once more */
|
||||||
|
@ -23,7 +23,7 @@
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* @test
|
* @test
|
||||||
* @bug 8142508
|
* @bug 8142508 8146431
|
||||||
* @summary Tests various ZipFile apis
|
* @summary Tests various ZipFile apis
|
||||||
* @run main/manual TestZipFile
|
* @run main/manual TestZipFile
|
||||||
*/
|
*/
|
||||||
@ -216,6 +216,13 @@ public class TestZipFile {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static void doTest0(Zip zip, ZipFile zf) throws Throwable {
|
static void doTest0(Zip zip, ZipFile zf) throws Throwable {
|
||||||
|
// (0) check zero-length entry name, no AIOOBE
|
||||||
|
try {
|
||||||
|
check(zf.getEntry("") == null);;
|
||||||
|
} catch (Throwable t) {
|
||||||
|
unexpected(t);
|
||||||
|
}
|
||||||
|
|
||||||
List<ZipEntry> list = new ArrayList(zip.entries.keySet());
|
List<ZipEntry> list = new ArrayList(zip.entries.keySet());
|
||||||
// (1) check entry list, in expected order
|
// (1) check entry list, in expected order
|
||||||
if (!check(Arrays.equals(
|
if (!check(Arrays.equals(
|
||||||
|
Loading…
Reference in New Issue
Block a user