diff options
| author | tb <> | 2025-11-28 06:03:40 +0000 |
|---|---|---|
| committer | tb <> | 2025-11-28 06:03:40 +0000 |
| commit | 5a7c0586b3d725c15633e7c157ad00803fe62cd4 (patch) | |
| tree | a079f2de2441af48d47c346406d9b8acea1e4e52 | |
| parent | a0443a8283b1ea5aa04375cf3487285eb68d97f7 (diff) | |
| download | openbsd-5a7c0586b3d725c15633e7c157ad00803fe62cd4.tar.gz openbsd-5a7c0586b3d725c15633e7c157ad00803fe62cd4.tar.bz2 openbsd-5a7c0586b3d725c15633e7c157ad00803fe62cd4.zip | |
Fix double free in certificate policies configuration
In nref_nos(), nnums must not be freed on error because in the caller it
is not->noticeref->noticenos and hangs off the POLICYQUALINFO qual which
is freed as part of POLICYQUALINFO_free() in the error path.
ok jsing kenjiro
| -rw-r--r-- | src/lib/libcrypto/x509/x509_cpols.c | 19 |
1 files changed, 7 insertions, 12 deletions
diff --git a/src/lib/libcrypto/x509/x509_cpols.c b/src/lib/libcrypto/x509/x509_cpols.c index e075f462ad..25a40b0739 100644 --- a/src/lib/libcrypto/x509/x509_cpols.c +++ b/src/lib/libcrypto/x509/x509_cpols.c | |||
| @@ -1,4 +1,4 @@ | |||
| 1 | /* $OpenBSD: x509_cpols.c,v 1.19 2025/11/03 16:36:15 tb Exp $ */ | 1 | /* $OpenBSD: x509_cpols.c,v 1.20 2025/11/28 06:03:40 tb Exp $ */ |
| 2 | /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL | 2 | /* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL |
| 3 | * project 1999. | 3 | * project 1999. |
| 4 | */ | 4 | */ |
| @@ -676,23 +676,18 @@ nref_nos(STACK_OF(ASN1_INTEGER) *nnums, STACK_OF(CONF_VALUE) *nos) | |||
| 676 | 676 | ||
| 677 | for (i = 0; i < sk_CONF_VALUE_num(nos); i++) { | 677 | for (i = 0; i < sk_CONF_VALUE_num(nos); i++) { |
| 678 | cnf = sk_CONF_VALUE_value(nos, i); | 678 | cnf = sk_CONF_VALUE_value(nos, i); |
| 679 | if (!(aint = s2i_ASN1_INTEGER(NULL, cnf->name))) { | 679 | if ((aint = s2i_ASN1_INTEGER(NULL, cnf->name)) == NULL) { |
| 680 | X509V3error(X509V3_R_INVALID_NUMBER); | 680 | X509V3error(X509V3_R_INVALID_NUMBER); |
| 681 | goto err; | 681 | return 0; |
| 682 | } | 682 | } |
| 683 | if (!sk_ASN1_INTEGER_push(nnums, aint)) { | 683 | if (sk_ASN1_INTEGER_push(nnums, aint) <= 0) { |
| 684 | X509V3error(ERR_R_MALLOC_FAILURE); | ||
| 684 | ASN1_INTEGER_free(aint); | 685 | ASN1_INTEGER_free(aint); |
| 685 | goto merr; | 686 | return 0; |
| 686 | } | 687 | } |
| 687 | } | 688 | } |
| 688 | return 1; | ||
| 689 | |||
| 690 | merr: | ||
| 691 | X509V3error(ERR_R_MALLOC_FAILURE); | ||
| 692 | 689 | ||
| 693 | err: | 690 | return 1; |
| 694 | sk_ASN1_INTEGER_pop_free(nnums, ASN1_INTEGER_free); | ||
| 695 | return 0; | ||
| 696 | } | 691 | } |
| 697 | 692 | ||
| 698 | static int | 693 | static int |
