Skip to content

Commit

Permalink
8255559: Leak File Descriptors Because of ResolverLocalFilesystem#eng…
Browse files Browse the repository at this point in the history
…ineResolveURI()

Reviewed-by: weijun
  • Loading branch information
Prajwal Kumaraswamy committed Nov 11, 2020
1 parent cd32158 commit d530722
Showing 1 changed file with 33 additions and 27 deletions.
Expand Up @@ -500,38 +500,44 @@ private byte[] transform(Data dereferencedData,
}

boolean secVal = Utils.secureValidation(context);
xi.setSecureValidation(secVal);
if (context instanceof XMLSignContext && c14n11
&& !xi.isOctetStream() && !xi.isOutputStreamSet()) {
TransformService spi = null;
if (provider == null) {
spi = TransformService.getInstance(c14nalg, "DOM");
} else {
try {
spi = TransformService.getInstance(c14nalg, "DOM", provider);
} catch (NoSuchAlgorithmException nsae) {
try {
xi.setSecureValidation(secVal);
if (context instanceof XMLSignContext && c14n11
&& !xi.isOctetStream() && !xi.isOutputStreamSet()) {
TransformService spi = null;
if (provider == null) {
spi = TransformService.getInstance(c14nalg, "DOM");
} else {
try {
spi = TransformService.getInstance(c14nalg, "DOM", provider);
} catch (NoSuchAlgorithmException nsae) {
spi = TransformService.getInstance(c14nalg, "DOM");
}
}
}

DOMTransform t = new DOMTransform(spi);
Element transformsElem = null;
String dsPrefix = DOMUtils.getSignaturePrefix(context);
if (allTransforms.isEmpty()) {
transformsElem = DOMUtils.createElement(
refElem.getOwnerDocument(),
"Transforms", XMLSignature.XMLNS, dsPrefix);
refElem.insertBefore(transformsElem,
DOMUtils.getFirstChildElement(refElem));
DOMTransform t = new DOMTransform(spi);
Element transformsElem = null;
String dsPrefix = DOMUtils.getSignaturePrefix(context);
if (allTransforms.isEmpty()) {
transformsElem = DOMUtils.createElement(
refElem.getOwnerDocument(),
"Transforms", XMLSignature.XMLNS, dsPrefix);
refElem.insertBefore(transformsElem,
DOMUtils.getFirstChildElement(refElem));
} else {
transformsElem = DOMUtils.getFirstChildElement(refElem);
}
t.marshal(transformsElem, dsPrefix,
(DOMCryptoContext) context);
allTransforms.add(t);
xi.updateOutputStream(os, true);
} else {
transformsElem = DOMUtils.getFirstChildElement(refElem);
xi.updateOutputStream(os);
}
} finally {
if(xi.getOctetStreamReal() != null) {
xi.getOctetStreamReal().close();
}
t.marshal(transformsElem, dsPrefix,
(DOMCryptoContext)context);
allTransforms.add(t);
xi.updateOutputStream(os, true);
} else {
xi.updateOutputStream(os);
}
}
os.flush();
Expand Down

0 comments on commit d530722

Please sign in to comment.