Skip to content

Commit 4be02d3

Browse files
Harold Seigelslowhog
Harold Seigel
authored andcommittedJan 18, 2022
8271987: Manifest improved manifest entries
Reviewed-by: rhalade, dholmes
1 parent 5832a34 commit 4be02d3

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed
 

‎src/hotspot/share/classfile/classLoader.cpp

+8-2
Original file line numberDiff line numberDiff line change
@@ -303,13 +303,19 @@ u1* ClassPathZipEntry::open_entry(JavaThread* current, const char* name, jint* f
303303
}
304304

305305
// read contents into resource array
306-
int size = (*filesize) + ((nul_terminate) ? 1 : 0);
306+
size_t size = (uint32_t)(*filesize);
307+
if (nul_terminate) {
308+
if (sizeof(size) == sizeof(uint32_t) && size == UINT_MAX) {
309+
return NULL; // 32-bit integer overflow will occur.
310+
}
311+
size++;
312+
}
307313
buffer = NEW_RESOURCE_ARRAY(u1, size);
308314
if (!(*ReadEntry)(_zip, entry, buffer, filename)) return NULL;
309315

310316
// return result
311317
if (nul_terminate) {
312-
buffer[*filesize] = 0;
318+
buffer[size - 1] = 0;
313319
}
314320
return buffer;
315321
}

0 commit comments

Comments
 (0)
Please sign in to comment.