Skip to content
Permalink
Browse files
Fix leak of PKCS#11 object ID on URI parse failure
Spotted by Coverity.

Signed-off-by: David Woodhouse <dwmw2@infradead.org>
  • Loading branch information
dwmw2 committed Oct 9, 2019
1 parent a200362 commit 0f8ebd15c365a6151696a8e75210a29d6de0bdb1
Showing with 4 additions and 0 deletions.
  1. +4 −0 openssl-pkcs11.c
@@ -115,6 +115,8 @@ static int parse_pkcs11_uri(const char *uri, PKCS11_TOKEN **p_tok,
return -ENOMEM;
}

*id = NULL;

/* We are only ever invoked if the string starts with 'pkcs11:' */
end = uri + 6;
while (!ret && end[0] && end[1]) {
@@ -172,6 +174,8 @@ static int parse_pkcs11_uri(const char *uri, PKCS11_TOKEN **p_tok,
free(tok);
tok = NULL;
free(newlabel);
free(*id);
*id = NULL;
}

return ret;

0 comments on commit 0f8ebd1

Please sign in to comment.