8255199: Catching a few NumberFormatExceptions in xmldsig

Reviewed-by: rhalade
This commit is contained in:
Weijun Wang 2020-10-23 13:00:08 +00:00 committed by Henry Jen
parent a5367cbb7a
commit 62eab50582
2 changed files with 11 additions and 3 deletions

View File

@ -281,9 +281,13 @@ public class RFC2253Parser {
&& (c2 >= 48 && c2 <= 57
|| c2 >= 65 && c2 <= 70
|| c2 >= 97 && c2 <= 102)) {
char ch = (char) Byte.parseByte("" + c1 + c2, 16);
try {
char ch = (char) Byte.parseByte("" + c1 + c2, 16);
sb.append(ch);
sb.append(ch);
} catch (NumberFormatException ex) {
throw new IOException(ex);
}
} else {
sb.append(c1);
sb.append(c2);

View File

@ -125,7 +125,11 @@ public abstract class DOMHMACSignatureMethod extends AbstractDOMSignatureMethod
SignatureMethodParameterSpec unmarshalParams(Element paramsElem)
throws MarshalException
{
outputLength = Integer.parseInt(paramsElem.getFirstChild().getNodeValue());
try {
outputLength = Integer.parseInt(paramsElem.getFirstChild().getNodeValue());
} catch (NumberFormatException ex) {
throw new MarshalException("Invalid output length supplied: " + paramsElem.getFirstChild().getNodeValue());
}
outputLengthSet = true;
LOG.debug("unmarshalled outputLength: {}", outputLength);
return new HMACParameterSpec(outputLength);