提交 aff987a7 编写于 作者: J jnimeh

8219775: Certificate validation improvements

Reviewed-by: ascarpino, ssahoo, skoivu
上级 ddd4bb09
...@@ -92,37 +92,41 @@ class DerIndefLenConverter { ...@@ -92,37 +92,41 @@ class DerIndefLenConverter {
private void parseTag() throws IOException { private void parseTag() throws IOException {
if (dataPos == dataSize) if (dataPos == dataSize)
return; return;
if (isEOC(data[dataPos]) && (data[dataPos + 1] == 0)) { try {
int numOfEncapsulatedLenBytes = 0; if (isEOC(data[dataPos]) && (data[dataPos + 1] == 0)) {
Object elem = null; int numOfEncapsulatedLenBytes = 0;
int index; Object elem = null;
for (index = ndefsList.size()-1; index >= 0; index--) { int index;
// Determine the first element in the vector that does not for (index = ndefsList.size()-1; index >= 0; index--) {
// have a matching EOC // Determine the first element in the vector that does not
elem = ndefsList.get(index); // have a matching EOC
if (elem instanceof Integer) { elem = ndefsList.get(index);
break; if (elem instanceof Integer) {
} else { break;
numOfEncapsulatedLenBytes += ((byte[])elem).length - 3; } else {
numOfEncapsulatedLenBytes += ((byte[])elem).length - 3;
}
} }
if (index < 0) {
throw new IOException("EOC does not have matching " +
"indefinite-length tag");
}
int sectionLen = dataPos - ((Integer)elem).intValue() +
numOfEncapsulatedLenBytes;
byte[] sectionLenBytes = getLengthBytes(sectionLen);
ndefsList.set(index, sectionLenBytes);
unresolved--;
// Add the number of bytes required to represent this section
// to the total number of length bytes,
// and subtract the indefinite-length tag (1 byte) and
// EOC bytes (2 bytes) for this section
numOfTotalLenBytes += (sectionLenBytes.length - 3);
} }
if (index < 0) { dataPos++;
throw new IOException("EOC does not have matching " + } catch (IndexOutOfBoundsException iobe) {
"indefinite-length tag"); throw new IOException(iobe);
}
int sectionLen = dataPos - ((Integer)elem).intValue() +
numOfEncapsulatedLenBytes;
byte[] sectionLenBytes = getLengthBytes(sectionLen);
ndefsList.set(index, sectionLenBytes);
unresolved--;
// Add the number of bytes required to represent this section
// to the total number of length bytes,
// and subtract the indefinite-length tag (1 byte) and
// EOC bytes (2 bytes) for this section
numOfTotalLenBytes += (sectionLenBytes.length - 3);
} }
dataPos++;
} }
/** /**
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册