From 4be02d31554b8d3bb84789923cf64a7dc4707eff Mon Sep 17 00:00:00 2001 From: Harold Seigel Date: Thu, 2 Sep 2021 18:09:33 +0000 Subject: [PATCH] 8271987: Manifest improved manifest entries Reviewed-by: rhalade, dholmes --- src/hotspot/share/classfile/classLoader.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/hotspot/share/classfile/classLoader.cpp b/src/hotspot/share/classfile/classLoader.cpp index d5ac1c308fd..f42b1fe4751 100644 --- a/src/hotspot/share/classfile/classLoader.cpp +++ b/src/hotspot/share/classfile/classLoader.cpp @@ -303,13 +303,19 @@ u1* ClassPathZipEntry::open_entry(JavaThread* current, const char* name, jint* f } // read contents into resource array - int size = (*filesize) + ((nul_terminate) ? 1 : 0); + size_t size = (uint32_t)(*filesize); + if (nul_terminate) { + if (sizeof(size) == sizeof(uint32_t) && size == UINT_MAX) { + return NULL; // 32-bit integer overflow will occur. + } + size++; + } buffer = NEW_RESOURCE_ARRAY(u1, size); if (!(*ReadEntry)(_zip, entry, buffer, filename)) return NULL; // return result if (nul_terminate) { - buffer[*filesize] = 0; + buffer[size - 1] = 0; } return buffer; }