8280404: Unexpected exception thrown when CEN file entry comment length is not valid

Reviewed-by: alanb
This commit is contained in:
Lance Andersen 2022-03-07 16:10:31 +00:00
parent 8e70f4c3dc
commit f0995abe62
2 changed files with 355 additions and 1 deletions

View file

@ -1206,8 +1206,17 @@ public class ZipFile implements ZipConstants, Closeable {
entries[index++] = hash;
entries[index++] = next;
entries[index ] = pos;
// Validate comment if it exists
// if the bytes representing the comment cannot be converted to
// a String via zcp.toString, an Exception will be thrown
int clen = CENCOM(cen, pos);
if (clen > 0) {
int elen = CENEXT(cen, pos);
int start = entryPos + nlen + elen;
zcp.toString(cen, start, clen);
}
} catch (Exception e) {
zerror("invalid CEN header (bad entry name)");
zerror("invalid CEN header (bad entry name or comment)");
}
return nlen;
}