Mercurial > hg > graal-jvmci-8
comparison src/share/vm/classfile/classFileParser.cpp @ 1881:6412b3805cd6
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
author | kamg |
---|---|
date | Tue, 26 Oct 2010 14:08:49 -0400 |
parents | a932f331ef90 |
children | 5caa30ea147b |
comparison
equal
deleted
inserted
replaced
1879:a312a67b32ef | 1881:6412b3805cd6 |
---|---|
4307 throwIllegalSignature("Method", name, signature, CHECK_0); | 4307 throwIllegalSignature("Method", name, signature, CHECK_0); |
4308 return 0; | 4308 return 0; |
4309 } | 4309 } |
4310 | 4310 |
4311 | 4311 |
4312 // Unqualified names may not contain the characters '.', ';', or '/'. | 4312 // Unqualified names may not contain the characters '.', ';', '[', or '/'. |
4313 // Method names also may not contain the characters '<' or '>', unless <init> or <clinit>. | 4313 // Method names also may not contain the characters '<' or '>', unless <init> |
4314 // Note that method names may not be <init> or <clinit> in this method. | 4314 // or <clinit>. Note that method names may not be <init> or <clinit> in this |
4315 // Because these names have been checked as special cases before calling this method | 4315 // method. Because these names have been checked as special cases before |
4316 // in verify_legal_method_name. | 4316 // calling this method in verify_legal_method_name. |
4317 bool ClassFileParser::verify_unqualified_name(char* name, unsigned int length, int type) { | 4317 bool ClassFileParser::verify_unqualified_name( |
4318 char* name, unsigned int length, int type) { | |
4318 jchar ch; | 4319 jchar ch; |
4319 | 4320 |
4320 for (char* p = name; p != name + length; ) { | 4321 for (char* p = name; p != name + length; ) { |
4321 ch = *p; | 4322 ch = *p; |
4322 if (ch < 128) { | 4323 if (ch < 128) { |
4323 p++; | 4324 p++; |
4324 if (ch == '.' || ch == ';') { | 4325 if (ch == '.' || ch == ';' || ch == '[' ) { |
4325 return false; // do not permit '.' or ';' | 4326 return false; // do not permit '.', ';', or '[' |
4326 } | 4327 } |
4327 if (type != LegalClass && ch == '/') { | 4328 if (type != LegalClass && ch == '/') { |
4328 return false; // do not permit '/' unless it's class name | 4329 return false; // do not permit '/' unless it's class name |
4329 } | 4330 } |
4330 if (type == LegalMethod && (ch == '<' || ch == '>')) { | 4331 if (type == LegalMethod && (ch == '<' || ch == '>')) { |