Navigation Menu

Skip to content

Commit

Permalink
Fix leak of PKCS#11 object ID on URI parse failure
Browse files Browse the repository at this point in the history
Spotted by Coverity.

Signed-off-by: David Woodhouse <dwmw2@infradead.org>
  • Loading branch information
dwmw2 committed Oct 9, 2019
1 parent a200362 commit 0f8ebd1
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions openssl-pkcs11.c
Expand Up @@ -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]) {
Expand Down Expand Up @@ -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;
Expand Down

0 comments on commit 0f8ebd1

Please sign in to comment.