8160090: Better signature handling in pack200

Reviewed-by: jrose, mschoene
This commit is contained in:
Kumar Srinivasan 2016-07-05 13:08:37 -07:00
parent 8da66ad674
commit 4e9407c775

View File

@ -174,7 +174,10 @@ struct entry {
const char* utf8String() {
assert(tagMatches(CONSTANT_Utf8));
assert(value.b.len == strlen((const char*)value.b.ptr));
if (value.b.len != strlen((const char*)value.b.ptr)) {
unpack_abort("bad utf8 encoding");
// and fall through
}
return (const char*)value.b.ptr;
}
@ -1319,10 +1322,10 @@ void unpacker::read_signature_values(entry* cpMap, int len) {
CHECK;
int nc = 0;
for ( const char* ncp = form.utf8String() ; *ncp; ncp++) {
if (*ncp == 'L') nc++;
for (int j = 0; j < (int)form.value.b.len; j++) {
int c = form.value.b.ptr[j];
if (c == 'L') nc++;
}
ncTotal += nc;
e.refs = U_NEW(entry*, cpMap[i].nrefs = 1 + nc);
CHECK;
@ -4028,8 +4031,8 @@ uint unpacker::to_bci(uint bii) {
uint* map = (uint*) bcimap.base();
assert(len > 0); // must be initialized before using to_bci
if (len == 0) {
abort("bad bcimap");
return 0;
abort("bad bcimap");
return 0;
}
if (bii < len)
return map[bii];
@ -5051,6 +5054,7 @@ unpacker::file* unpacker::get_next_file() {
entry* e = file_name.getRef();
CHECK_0;
cur_file.name = e->utf8String();
CHECK_0;
bool haveLongSize = (testBit(archive_options, AO_HAVE_FILE_SIZE_HI));
cur_file.size = file_size_hi.getLong(file_size_lo, haveLongSize);
if (testBit(archive_options, AO_HAVE_FILE_MODTIME))