8368097: [asan] heap-buffer-overflow reported in ClassFileParser::skip_over_field_signature

Reviewed-by: dholmes, mbaesken
This commit is contained in:
Johan Sjölen 2025-10-06 07:48:45 +00:00
parent 85877e2022
commit 069c569a71

View File

@ -4678,11 +4678,15 @@ const char* ClassFileParser::skip_over_field_signature(const char* signature,
return signature + 1;
case JVM_SIGNATURE_CLASS: {
if (_major_version < JAVA_1_5_VERSION) {
signature++;
length--;
// Skip over the class name if one is there
const char* const p = skip_over_field_name(signature + 1, true, --length);
const char* const p = skip_over_field_name(signature, true, length);
assert(p == nullptr || p > signature, "must parse one character at least");
// The next character better be a semicolon
if (p && (p - signature) > 1 && p[0] == JVM_SIGNATURE_ENDCLASS) {
if (p != nullptr && // Parse of field name succeeded.
p - signature < static_cast<int>(length) && // There is at least one character left to parse.
p[0] == JVM_SIGNATURE_ENDCLASS) {
return p + 1;
}
}