8277227: Better identification of OIDs

Reviewed-by: yan
Backport-of: 3ac5f0175356fad40b59f879322fa7d89dfbcaab
This commit is contained in:
Aleksei Voitylov 2022-03-14 14:32:28 +03:00 committed by Andrew Brygin
parent f5a2ce3483
commit ee04280526

View File

@ -409,7 +409,7 @@ class ObjectIdentifier implements Serializable
if ((encoding[i] & 0x80) == 0) {
// one section [fromPos..i]
if (i - fromPos + 1 > 4) {
BigInteger big = new BigInteger(pack(encoding, fromPos, i-fromPos+1, 7, 8));
BigInteger big = new BigInteger(1, pack(encoding, fromPos, i-fromPos+1, 7, 8));
if (fromPos == 0) {
result[which++] = 2;
BigInteger second = big.subtract(BigInteger.valueOf(80));
@ -474,7 +474,7 @@ class ObjectIdentifier implements Serializable
sb.append('.');
}
if (i - fromPos + 1 > 4) { // maybe big integer
BigInteger big = new BigInteger(pack(encoding, fromPos, i-fromPos+1, 7, 8));
BigInteger big = new BigInteger(1, pack(encoding, fromPos, i-fromPos+1, 7, 8));
if (fromPos == 0) {
// first section encoded with more than 4 bytes,
// must be 2.something
@ -711,6 +711,7 @@ class ObjectIdentifier implements Serializable
throw new IOException("ObjectIdentifier encoded length was " +
"negative: " + oidLength);
}
if (oidLength > MAXIMUM_OID_SIZE) {
throw new IOException(
"ObjectIdentifier encoded length exceeds " +