1 Star 0 Fork 82

佛系少年中二/openjdk-1.8.0

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
add-8146431-j.u.z.ZipFile.getEntry-throws-AIOOBE.patch 1.91 KB
一键复制 编辑 原始数据 按行查看 历史
DXwangg 提交于 2023-09-26 09:10 . Add feature and bug fix for 8u382
From b6a24b666a1c7536e35afaba4057cc8eac6fe48f Mon Sep 17 00:00:00 2001
Date: Thu, 21 Sep 2023 15:25:03 +0800
Subject: add 8146431-j.u.z.ZipFile.getEntry-throws-AIOOBE
---
jdk/src/share/classes/java/util/zip/ZipFile.java | 2 +-
jdk/test/java/util/zip/ZipFile/TestZipFile.java | 9 ++++++++-
2 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/jdk/src/share/classes/java/util/zip/ZipFile.java b/jdk/src/share/classes/java/util/zip/ZipFile.java
index 38b642bdc..36135a9c0 100644
--- a/jdk/src/share/classes/java/util/zip/ZipFile.java
+++ b/jdk/src/share/classes/java/util/zip/ZipFile.java
@@ -1313,7 +1313,7 @@ class ZipFile implements ZipConstants, Closeable {
idx = getEntryNext(idx);
}
/* 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;
}
// Add a slash to the hash code
diff --git a/jdk/test/java/util/zip/ZipFile/TestZipFile.java b/jdk/test/java/util/zip/ZipFile/TestZipFile.java
index 30bae3bb9..773f47558 100644
--- a/jdk/test/java/util/zip/ZipFile/TestZipFile.java
+++ b/jdk/test/java/util/zip/ZipFile/TestZipFile.java
@@ -24,7 +24,7 @@
/*
* @test
- * @bug 8142508
+ * @bug 8142508 8146431
* @summary Tests various ZipFile apis
* @run main/manual TestZipFile
*/
@@ -230,6 +230,13 @@ public class TestZipFile {
}
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());
// (1) check entry list, in expected order
if (!check(Arrays.equals(
--
2.22.0
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/Autistic_boyya/openjdk-1.8.0.git
git@gitee.com:Autistic_boyya/openjdk-1.8.0.git
Autistic_boyya
openjdk-1.8.0
openjdk-1.8.0
master

搜索帮助