knox-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Sandeep More (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (KNOX-748) Fix Resource Leak in X509CertificateUtil.writeCertificateToJKS
Date Thu, 01 Sep 2016 16:03:20 GMT

    [ https://issues.apache.org/jira/browse/KNOX-748?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=15455860#comment-15455860
] 

Sandeep More commented on KNOX-748:
-----------------------------------

I'll pick this one up, looks like resource "fos" needs to be closed in finally. 

> Fix Resource Leak in X509CertificateUtil.writeCertificateToJKS
> --------------------------------------------------------------
>
>                 Key: KNOX-748
>                 URL: https://issues.apache.org/jira/browse/KNOX-748
>             Project: Apache Knox
>          Issue Type: Bug
>          Components: Server
>            Reporter: Larry McCay
>             Fix For: 0.10.0
>
>
> New defect(s) Reported-by: Coverity Scan
> Showing 1 of 1 defect(s)
> ** CID 1361992:  Exceptional resource leaks  (RESOURCE_LEAK)
> /gateway-spi/src/main/java/org/apache/hadoop/gateway/services/security/impl/X509CertificateUtil.java:
299 in org.apache.hadoop.gateway.services.security.impl.X509CertificateUtil.writeCertificateToJKS(java.security.cert.Certificate,
java.io.File)()
> ________________________________________________________________________________________________________
> *** CID 1361992:  Exceptional resource leaks  (RESOURCE_LEAK)
> /gateway-spi/src/main/java/org/apache/hadoop/gateway/services/security/impl/X509CertificateUtil.java:
299 in org.apache.hadoop.gateway.services.security.impl.X509CertificateUtil.writeCertificateToJKS(java.security.cert.Certificate,
java.io.File)()
> 293     
> 294         char[] password = "changeme".toCharArray();
> 295         ks.load(null, password);
> 296         ks.setCertificateEntry("gateway-identity", cert);
> 297     
> 298         FileOutputStream fos = new FileOutputStream(file);
>    CID 1361992:  Exceptional resource leaks  (RESOURCE_LEAK)
>    Variable "fos" going out of scope leaks the resource it refers to.
> 299         ks.store(fos, password);
> 300         fos.close();
> 301       }



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Mime
View raw message