提交 16bb31c3 编写于 作者: K kamg

6891959: HotSpot should not throw ClassFormatError if a class has a field with...

6891959: HotSpot should not throw ClassFormatError if a class has a field with '>' and/or '<' in its name
Summary: Class file parser needs to look for and disallow '[' in names.
Reviewed-by: coleenp, never
上级 e1af249a
...@@ -4309,20 +4309,21 @@ int ClassFileParser::verify_legal_method_signature(symbolHandle name, symbolHand ...@@ -4309,20 +4309,21 @@ int ClassFileParser::verify_legal_method_signature(symbolHandle name, symbolHand
} }
// Unqualified names may not contain the characters '.', ';', or '/'. // Unqualified names may not contain the characters '.', ';', '[', or '/'.
// Method names also may not contain the characters '<' or '>', unless <init> or <clinit>. // Method names also may not contain the characters '<' or '>', unless <init>
// Note that method names may not be <init> or <clinit> in this method. // or <clinit>. Note that method names may not be <init> or <clinit> in this
// Because these names have been checked as special cases before calling this method // method. Because these names have been checked as special cases before
// in verify_legal_method_name. // calling this method in verify_legal_method_name.
bool ClassFileParser::verify_unqualified_name(char* name, unsigned int length, int type) { bool ClassFileParser::verify_unqualified_name(
char* name, unsigned int length, int type) {
jchar ch; jchar ch;
for (char* p = name; p != name + length; ) { for (char* p = name; p != name + length; ) {
ch = *p; ch = *p;
if (ch < 128) { if (ch < 128) {
p++; p++;
if (ch == '.' || ch == ';') { if (ch == '.' || ch == ';' || ch == '[' ) {
return false; // do not permit '.' or ';' return false; // do not permit '.', ';', or '['
} }
if (type != LegalClass && ch == '/') { if (type != LegalClass && ch == '/') {
return false; // do not permit '/' unless it's class name return false; // do not permit '/' unless it's class name
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册