sync code with last improvements from OpenBSD

This commit is contained in:
purplerain 2023-08-23 09:28:13 +00:00
parent c346c8d04f
commit ab8d6e7bca
Signed by: purplerain
GPG key ID: F42C07F07E2E35B7
7 changed files with 44 additions and 42 deletions

View file

@ -1,4 +1,4 @@
/* $OpenBSD: cms_lib.c,v 1.19 2023/07/28 10:28:02 tb Exp $ */
/* $OpenBSD: cms_lib.c,v 1.21 2023/08/22 08:59:44 tb Exp $ */
/*
* Written by Dr Stephen N Henson (steve@openssl.org) for the OpenSSL
* project.
@ -144,46 +144,43 @@ cms_content_bio(CMS_ContentInfo *cms)
BIO *
CMS_dataInit(CMS_ContentInfo *cms, BIO *icont)
{
BIO *cmsbio, *cont;
BIO *cmsbio = NULL, *cont = NULL;
if (icont)
cont = icont;
else
if ((cont = icont) == NULL)
cont = cms_content_bio(cms);
if (!cont) {
if (cont == NULL) {
CMSerror(CMS_R_NO_CONTENT);
return NULL;
goto err;
}
switch (OBJ_obj2nid(cms->contentType)) {
switch (OBJ_obj2nid(cms->contentType)) {
case NID_pkcs7_data:
return cont;
case NID_pkcs7_signed:
cmsbio = cms_SignedData_init_bio(cms);
if ((cmsbio = cms_SignedData_init_bio(cms)) == NULL)
goto err;
break;
case NID_pkcs7_digest:
cmsbio = cms_DigestedData_init_bio(cms);
if ((cmsbio = cms_DigestedData_init_bio(cms)) == NULL)
goto err;
break;
case NID_pkcs7_encrypted:
cmsbio = cms_EncryptedData_init_bio(cms);
if ((cmsbio = cms_EncryptedData_init_bio(cms)) == NULL)
goto err;
break;
case NID_pkcs7_enveloped:
cmsbio = cms_EnvelopedData_init_bio(cms);
if ((cmsbio = cms_EnvelopedData_init_bio(cms)) == NULL)
goto err;
break;
default:
CMSerror(CMS_R_UNSUPPORTED_TYPE);
return NULL;
goto err;
}
if (cmsbio)
return BIO_push(cmsbio, cont);
return BIO_push(cmsbio, cont);
if (!icont)
err:
if (cont != icont)
BIO_free(cont);
return NULL;

View file

@ -1,4 +1,4 @@
/* $OpenBSD: ts_rsp_sign.c,v 1.31 2023/07/07 07:25:21 beck Exp $ */
/* $OpenBSD: ts_rsp_sign.c,v 1.32 2023/08/22 08:09:36 tb Exp $ */
/* Written by Zoltan Glozik (zglozik@stones.com) for the OpenSSL
* project 2002.
*/
@ -98,18 +98,21 @@ static ASN1_GENERALIZEDTIME *TS_RESP_set_genTime_with_precision(
static ASN1_INTEGER *
def_serial_cb(struct TS_resp_ctx *ctx, void *data)
{
ASN1_INTEGER *serial = ASN1_INTEGER_new();
ASN1_INTEGER *serial;
if (!serial)
if ((serial = ASN1_INTEGER_new()) == NULL)
goto err;
if (!ASN1_INTEGER_set(serial, 1))
goto err;
return serial;
err:
err:
ASN1_INTEGER_free(serial);
TSerror(ERR_R_MALLOC_FAILURE);
TS_RESP_CTX_set_status_info(ctx, TS_STATUS_REJECTION,
"Error during serial number generation.");
return NULL;
}