]> git.ipfire.org Git - thirdparty/openssl.git/commit
x509: Handle ossl_policy_level_add_node errors
authorClemens Lang <cllang@redhat.com>
Wed, 24 May 2023 11:12:54 +0000 (13:12 +0200)
committerTomas Mraz <tomas@openssl.org>
Mon, 29 May 2023 12:57:47 +0000 (14:57 +0200)
commit3cc6933555a0c66328ec659b5bb86c57b6402e1e
tree65b569d16e8bd6565ae1c6b749c6f084fd0b6d00
parentb1cc84e82d41ab669bf804ea519f5332c48a3d77
x509: Handle ossl_policy_level_add_node errors

The invocation of ossl_policy_level_add_node in tree_calculate_user_set
did not have any error handling. Add it to prevent a memory leak for the
allocated extra policy data.

Also add error handling to sk_X509_POLICY_NODE_push to ensure that if
a new node was allocated, but could not be added to the stack, it is
freed correctly.

Fix error handling if tree->user_policies cannot be allocated by
returning 0, indicating failure, rather than 1.

Signed-off-by: Clemens Lang <cllang@redhat.com>
Reviewed-by: Dmitry Belyavskiy <beldmit@gmail.com>
Reviewed-by: Matt Caswell <matt@openssl.org>
Reviewed-by: Bernd Edlinger <bernd.edlinger@hotmail.de>
Reviewed-by: Tomas Mraz <tomas@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/21066)
crypto/x509v3/pcy_tree.c