diff options
author | schwarze <> | 2021-11-26 13:17:09 +0000 |
---|---|---|
committer | schwarze <> | 2021-11-26 13:17:09 +0000 |
commit | d32ec31a7cdba9039a7bc50e7a4add51f70b429e (patch) | |
tree | 18a74bab6653e74260da07f52a2ac7c285cd1391 /src/lib | |
parent | 3d037e20c2808ea3d7e462325f59a3134ffd19f3 (diff) | |
download | openbsd-d32ec31a7cdba9039a7bc50e7a4add51f70b429e.tar.gz openbsd-d32ec31a7cdba9039a7bc50e7a4add51f70b429e.tar.bz2 openbsd-d32ec31a7cdba9039a7bc50e7a4add51f70b429e.zip |
Bugfix in X509_get_pubkey_parameters(3):
If EVP_PKEY_copy_parameters(3) fails - among other reasons, this
may happen when out of memory - the pkey argument and/or the chain
argument will not contain all the desired parameters after returning.
Consequently, report the failure to the caller rather than silently
ignoring it.
OK tb@
Diffstat (limited to 'src/lib')
-rw-r--r-- | src/lib/libcrypto/x509/x509_vfy.c | 8 |
1 files changed, 5 insertions, 3 deletions
diff --git a/src/lib/libcrypto/x509/x509_vfy.c b/src/lib/libcrypto/x509/x509_vfy.c index 93dac74c7b..cf92c10299 100644 --- a/src/lib/libcrypto/x509/x509_vfy.c +++ b/src/lib/libcrypto/x509/x509_vfy.c | |||
@@ -1,4 +1,4 @@ | |||
1 | /* $OpenBSD: x509_vfy.c,v 1.99 2021/11/26 13:05:03 schwarze Exp $ */ | 1 | /* $OpenBSD: x509_vfy.c,v 1.100 2021/11/26 13:17:09 schwarze Exp $ */ |
2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) | 2 | /* Copyright (C) 1995-1998 Eric Young (eay@cryptsoft.com) |
3 | * All rights reserved. | 3 | * All rights reserved. |
4 | * | 4 | * |
@@ -2097,11 +2097,13 @@ X509_get_pubkey_parameters(EVP_PKEY *pkey, STACK_OF(X509) *chain) | |||
2097 | /* first, populate the other certs */ | 2097 | /* first, populate the other certs */ |
2098 | for (j = i - 1; j >= 0; j--) { | 2098 | for (j = i - 1; j >= 0; j--) { |
2099 | ktmp2 = X509_get0_pubkey(sk_X509_value(chain, j)); | 2099 | ktmp2 = X509_get0_pubkey(sk_X509_value(chain, j)); |
2100 | EVP_PKEY_copy_parameters(ktmp2, ktmp); | 2100 | if (!EVP_PKEY_copy_parameters(ktmp2, ktmp)) |
2101 | return 0; | ||
2101 | } | 2102 | } |
2102 | 2103 | ||
2103 | if (pkey != NULL) | 2104 | if (pkey != NULL) |
2104 | EVP_PKEY_copy_parameters(pkey, ktmp); | 2105 | if (!EVP_PKEY_copy_parameters(pkey, ktmp)) |
2106 | return 0; | ||
2105 | return 1; | 2107 | return 1; |
2106 | } | 2108 | } |
2107 | 2109 | ||