Skip to content

Commit 52cd4fe

Browse files
rgithubliPaul Hohensee
authored andcommitted
8311076: RedefineClasses doesn't check for ConstantPool overflow
Backport-of: e33d8a219811930492e684e19a73dadb09590052
1 parent 6f11d32 commit 52cd4fe

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/hotspot/share/prims/jvmtiRedefineClasses.cpp

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2003, 2023, Oracle and/or its affiliates. All rights reserved.
2+
* Copyright (c) 2003, 2024, Oracle and/or its affiliates. All rights reserved.
33
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
44
*
55
* This code is free software; you can redistribute it and/or modify it
@@ -1862,6 +1862,12 @@ jvmtiError VM_RedefineClasses::merge_cp_and_rewrite(
18621862
return JVMTI_ERROR_INTERNAL;
18631863
}
18641864

1865+
// ensure merged constant pool size does not overflow u2
1866+
if (merge_cp_length > 0xFFFF) {
1867+
log_warning(redefine, class, constantpool)("Merged constant pool overflow: %d entries", merge_cp_length);
1868+
return JVMTI_ERROR_INTERNAL;
1869+
}
1870+
18651871
// Set dynamic constants attribute from the original CP.
18661872
if (old_cp->has_dynamic_constant()) {
18671873
scratch_cp->set_has_dynamic_constant();

0 commit comments

Comments
 (0)