summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortb <>2023-08-22 08:44:15 +0000
committertb <>2023-08-22 08:44:15 +0000
commit6f647f01da60740c9de510f278e9ff9907b61702 (patch)
tree567d9bb3ea6971340d4debbf4f70a137f960ee44
parent0248400d600d4e2c95f3f0963dad756361f1735b (diff)
downloadopenbsd-6f647f01da60740c9de510f278e9ff9907b61702.tar.gz
openbsd-6f647f01da60740c9de510f278e9ff9907b61702.tar.bz2
openbsd-6f647f01da60740c9de510f278e9ff9907b61702.zip
Plug a leak of cont in CMS_dataInit()
This and ts/ts_rsp_sign.c r1.32 were part of OpenSSL 309e73df. ok jsing
-rw-r--r--src/lib/libcrypto/cms/cms_lib.c23
1 files changed, 12 insertions, 11 deletions
diff --git a/src/lib/libcrypto/cms/cms_lib.c b/src/lib/libcrypto/cms/cms_lib.c
index 37a11ba007..9f8e13d36f 100644
--- a/src/lib/libcrypto/cms/cms_lib.c
+++ b/src/lib/libcrypto/cms/cms_lib.c
@@ -1,4 +1,4 @@
1/* $OpenBSD: cms_lib.c,v 1.19 2023/07/28 10:28:02 tb Exp $ */ 1/* $OpenBSD: cms_lib.c,v 1.20 2023/08/22 08:44:15 tb Exp $ */
2/* 2/*
3 * Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL 3 * Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
4 * project. 4 * project.
@@ -144,15 +144,13 @@ cms_content_bio(CMS_ContentInfo *cms)
144BIO * 144BIO *
145CMS_dataInit(CMS_ContentInfo *cms, BIO *icont) 145CMS_dataInit(CMS_ContentInfo *cms, BIO *icont)
146{ 146{
147 BIO *cmsbio, *cont; 147 BIO *cmsbio = NULL, *cont = NULL;
148 148
149 if (icont) 149 if ((cont = icont) == NULL)
150 cont = icont;
151 else
152 cont = cms_content_bio(cms); 150 cont = cms_content_bio(cms);
153 if (!cont) { 151 if (cont == NULL) {
154 CMSerror(CMS_R_NO_CONTENT); 152 CMSerror(CMS_R_NO_CONTENT);
155 return NULL; 153 goto err;
156 } 154 }
157 switch (OBJ_obj2nid(cms->contentType)) { 155 switch (OBJ_obj2nid(cms->contentType)) {
158 156
@@ -177,13 +175,16 @@ CMS_dataInit(CMS_ContentInfo *cms, BIO *icont)
177 175
178 default: 176 default:
179 CMSerror(CMS_R_UNSUPPORTED_TYPE); 177 CMSerror(CMS_R_UNSUPPORTED_TYPE);
180 return NULL; 178 goto err;
181 } 179 }
182 180
183 if (cmsbio) 181 if (cmsbio == NULL)
184 return BIO_push(cmsbio, cont); 182 goto err;
183
184 return BIO_push(cmsbio, cont);
185 185
186 if (!icont) 186 err:
187 if (cont != icont)
187 BIO_free(cont); 188 BIO_free(cont);
188 189
189 return NULL; 190 return NULL;