CRYPTO: refactor ERR_raise()+ERR_add_error_data() to ERR_raise_data()

This is not done absolutely everywhere, as there are places where
the use of ERR_add_error_data() is quite complex, but at least the
simple cases are done.

Reviewed-by: Paul Dale <paul.dale@oracle.com>
(Merged from https://github.com/openssl/openssl/pull/13318)
This commit is contained in:
Richard Levitte 2020-11-04 16:14:00 +01:00
parent 9311d0c471
commit a150f8e1fc
51 changed files with 273 additions and 366 deletions

View File

@ -2043,8 +2043,8 @@ ASN1_VALUE *app_http_get_asn1(const char *url, const char *proxy,
if (!OSSL_HTTP_parse_url(url, &server, &port, NULL, NULL, &use_ssl)) if (!OSSL_HTTP_parse_url(url, &server, &port, NULL, NULL, &use_ssl))
return NULL; return NULL;
if (use_ssl && ssl_ctx == NULL) { if (use_ssl && ssl_ctx == NULL) {
ERR_raise(ERR_LIB_HTTP, ERR_R_PASSED_NULL_PARAMETER); ERR_raise_data(ERR_LIB_HTTP, ERR_R_PASSED_NULL_PARAMETER,
ERR_add_error_data(1, "missing SSL_CTX"); "missing SSL_CTX");
goto end; goto end;
} }

View File

@ -49,7 +49,6 @@ int ASN1_mbstring_ncopy(ASN1_STRING **out, const unsigned char *in, int len,
ASN1_STRING *dest; ASN1_STRING *dest;
unsigned char *p; unsigned char *p;
int nchar; int nchar;
char strbuf[32];
int (*cpyfunc) (unsigned long, void *) = NULL; int (*cpyfunc) (unsigned long, void *) = NULL;
if (len == -1) if (len == -1)
len = strlen((const char *)in); len = strlen((const char *)in);
@ -95,16 +94,14 @@ int ASN1_mbstring_ncopy(ASN1_STRING **out, const unsigned char *in, int len,
} }
if ((minsize > 0) && (nchar < minsize)) { if ((minsize > 0) && (nchar < minsize)) {
ERR_raise(ERR_LIB_ASN1, ASN1_R_STRING_TOO_SHORT); ERR_raise_data(ERR_LIB_ASN1, ASN1_R_STRING_TOO_SHORT,
BIO_snprintf(strbuf, sizeof(strbuf), "%ld", minsize); "minsize=%ld", minsize);
ERR_add_error_data(2, "minsize=", strbuf);
return -1; return -1;
} }
if ((maxsize > 0) && (nchar > maxsize)) { if ((maxsize > 0) && (nchar > maxsize)) {
ERR_raise(ERR_LIB_ASN1, ASN1_R_STRING_TOO_LONG); ERR_raise_data(ERR_LIB_ASN1, ASN1_R_STRING_TOO_LONG,
BIO_snprintf(strbuf, sizeof(strbuf), "%ld", maxsize); "maxsize=%ld", maxsize);
ERR_add_error_data(2, "maxsize=", strbuf);
return -1; return -1;
} }

View File

@ -263,8 +263,7 @@ static int asn1_cb(const char *elem, int len, void *bitstr)
utype = asn1_str2tag(elem, len); utype = asn1_str2tag(elem, len);
if (utype == -1) { if (utype == -1) {
ERR_raise(ERR_LIB_ASN1, ASN1_R_UNKNOWN_TAG); ERR_raise_data(ERR_LIB_ASN1, ASN1_R_UNKNOWN_TAG, "tag=%s", elem);
ERR_add_error_data(2, "tag=", elem);
return -1; return -1;
} }
@ -347,7 +346,6 @@ static int asn1_cb(const char *elem, int len, void *bitstr)
static int parse_tagging(const char *vstart, int vlen, int *ptag, int *pclass) static int parse_tagging(const char *vstart, int vlen, int *ptag, int *pclass)
{ {
char erch[2];
long tag_num; long tag_num;
char *eptr; char *eptr;
if (!vstart) if (!vstart)
@ -386,10 +384,8 @@ static int parse_tagging(const char *vstart, int vlen, int *ptag, int *pclass)
break; break;
default: default:
erch[0] = *eptr; ERR_raise_data(ERR_LIB_ASN1, ASN1_R_INVALID_MODIFIER,
erch[1] = 0; "Char=%c", *eptr);
ERR_raise(ERR_LIB_ASN1, ASN1_R_INVALID_MODIFIER);
ERR_add_error_data(2, "Char=", erch);
return 0; return 0;
} }

View File

@ -453,8 +453,8 @@ ASN1_VALUE *SMIME_read_ASN1_ex(BIO *bio, BIO **bcont, const ASN1_ITEM *it,
if (strcmp(hdr->value, "application/x-pkcs7-signature") && if (strcmp(hdr->value, "application/x-pkcs7-signature") &&
strcmp(hdr->value, "application/pkcs7-signature")) { strcmp(hdr->value, "application/pkcs7-signature")) {
ERR_raise(ERR_LIB_ASN1, ASN1_R_SIG_INVALID_MIME_TYPE); ERR_raise_data(ERR_LIB_ASN1, ASN1_R_SIG_INVALID_MIME_TYPE,
ERR_add_error_data(2, "type: ", hdr->value); "type: %s", hdr->value);
sk_MIME_HEADER_pop_free(headers, mime_hdr_free); sk_MIME_HEADER_pop_free(headers, mime_hdr_free);
sk_BIO_pop_free(parts, BIO_vfree); sk_BIO_pop_free(parts, BIO_vfree);
return NULL; return NULL;
@ -480,8 +480,8 @@ ASN1_VALUE *SMIME_read_ASN1_ex(BIO *bio, BIO **bcont, const ASN1_ITEM *it,
if (strcmp(hdr->value, "application/x-pkcs7-mime") && if (strcmp(hdr->value, "application/x-pkcs7-mime") &&
strcmp(hdr->value, "application/pkcs7-mime")) { strcmp(hdr->value, "application/pkcs7-mime")) {
ERR_raise(ERR_LIB_ASN1, ASN1_R_INVALID_MIME_TYPE); ERR_raise_data(ERR_LIB_ASN1, ASN1_R_INVALID_MIME_TYPE,
ERR_add_error_data(2, "type: ", hdr->value); "type: %s", hdr->value);
sk_MIME_HEADER_pop_free(headers, mime_hdr_free); sk_MIME_HEADER_pop_free(headers, mime_hdr_free);
return NULL; return NULL;
} }
@ -566,8 +566,8 @@ int SMIME_text(BIO *in, BIO *out)
return 0; return 0;
} }
if (strcmp(hdr->value, "text/plain")) { if (strcmp(hdr->value, "text/plain")) {
ERR_raise(ERR_LIB_ASN1, ASN1_R_INVALID_MIME_TYPE); ERR_raise_data(ERR_LIB_ASN1, ASN1_R_INVALID_MIME_TYPE,
ERR_add_error_data(2, "type: ", hdr->value); "type: %s", hdr->value);
sk_MIME_HEADER_pop_free(headers, mime_hdr_free); sk_MIME_HEADER_pop_free(headers, mime_hdr_free);
return 0; return 0;
} }

View File

@ -96,12 +96,12 @@ static int do_tcreate(const char *value, const char *name)
rv = 1; rv = 1;
err: err:
if (rv == 0) { if (rv == 0) {
ERR_raise(ERR_LIB_ASN1, ASN1_R_INVALID_STRING_TABLE_VALUE);
if (cnf) if (cnf)
ERR_add_error_data(4, "field=", cnf->name, ERR_raise_data(ERR_LIB_ASN1, ASN1_R_INVALID_STRING_TABLE_VALUE,
", value=", cnf->value); "field=%s, value=%s", cnf->name, cnf->value);
else else
ERR_add_error_data(4, "name=", name, ", value=", value); ERR_raise_data(ERR_LIB_ASN1, ASN1_R_INVALID_STRING_TABLE_VALUE,
"name=%s, value=%s", name, value);
} else { } else {
rv = ASN1_STRING_TABLE_add(nid, tbl_min, tbl_max, rv = ASN1_STRING_TABLE_add(nid, tbl_min, tbl_max,
tbl_mask, tbl_flags); tbl_mask, tbl_flags);

View File

@ -213,12 +213,10 @@ static int addr_strings(const BIO_ADDR *ap, int numeric,
if (ret == EAI_SYSTEM) { if (ret == EAI_SYSTEM) {
ERR_raise_data(ERR_LIB_SYS, get_last_socket_error(), ERR_raise_data(ERR_LIB_SYS, get_last_socket_error(),
"calling getnameinfo()"); "calling getnameinfo()");
ERR_raise(ERR_LIB_BIO, ERR_R_SYS_LIB);
} else } else
# endif # endif
{ {
ERR_raise(ERR_LIB_BIO, ERR_R_SYS_LIB); ERR_raise_data(ERR_LIB_BIO, ERR_R_SYS_LIB, gai_strerror(ret));
ERR_add_error_data(1, gai_strerror(ret));
} }
return 0; return 0;
} }
@ -729,8 +727,8 @@ int BIO_lookup_ex(const char *host, const char *service, int lookup_type,
goto retry; goto retry;
} }
# endif # endif
ERR_raise(ERR_LIB_BIO, ERR_R_SYS_LIB); ERR_raise_data(ERR_LIB_BIO, ERR_R_SYS_LIB,
ERR_add_error_data(1, gai_strerror(old_ret ? old_ret : gai_ret)); gai_strerror(old_ret ? old_ret : gai_ret));
break; break;
} }
} else { } else {

View File

@ -156,10 +156,10 @@ static int acpt_state(BIO *b, BIO_ACCEPT *c)
switch (c->state) { switch (c->state) {
case ACPT_S_BEFORE: case ACPT_S_BEFORE:
if (c->param_addr == NULL && c->param_serv == NULL) { if (c->param_addr == NULL && c->param_serv == NULL) {
ERR_raise(ERR_LIB_BIO, BIO_R_NO_ACCEPT_ADDR_OR_SERVICE_SPECIFIED); ERR_raise_data(ERR_LIB_BIO,
ERR_add_error_data(4, BIO_R_NO_ACCEPT_ADDR_OR_SERVICE_SPECIFIED,
"hostname=", c->param_addr, "hostname=%s, service=%s",
" service=", c->param_serv); c->param_addr, c->param_serv);
goto exit_loop; goto exit_loop;
} }

View File

@ -89,10 +89,10 @@ static int conn_state(BIO *b, BIO_CONNECT *c)
switch (c->state) { switch (c->state) {
case BIO_CONN_S_BEFORE: case BIO_CONN_S_BEFORE:
if (c->param_hostname == NULL && c->param_service == NULL) { if (c->param_hostname == NULL && c->param_service == NULL) {
ERR_raise(ERR_LIB_BIO, BIO_R_NO_HOSTNAME_OR_SERVICE_SPECIFIED); ERR_raise_data(ERR_LIB_BIO,
ERR_add_error_data(4, BIO_R_NO_HOSTNAME_OR_SERVICE_SPECIFIED,
"hostname=", c->param_hostname, "hostname=%s service=%s",
" service=", c->param_service); c->param_hostname, c->param_service);
goto exit_loop; goto exit_loop;
} }
c->state = BIO_CONN_S_GET_ADDR; c->state = BIO_CONN_S_GET_ADDR;

View File

@ -843,8 +843,8 @@ BIO *BIO_new_dgram_sctp(int fd, int close_flag)
sizeof(struct sctp_authchunk)); sizeof(struct sctp_authchunk));
if (ret < 0) { if (ret < 0) {
BIO_vfree(bio); BIO_vfree(bio);
ERR_raise(ERR_LIB_BIO, ERR_R_SYS_LIB); ERR_raise_data(ERR_LIB_BIO, ERR_R_SYS_LIB,
ERR_add_error_data(1, "Ensure SCTP AUTH chunks are enabled in kernel"); "Ensure SCTP AUTH chunks are enabled in kernel");
return NULL; return NULL;
} }
auth.sauth_chunk = OPENSSL_SCTP_FORWARD_CUM_TSN_CHUNK_TYPE; auth.sauth_chunk = OPENSSL_SCTP_FORWARD_CUM_TSN_CHUNK_TYPE;
@ -853,8 +853,8 @@ BIO *BIO_new_dgram_sctp(int fd, int close_flag)
sizeof(struct sctp_authchunk)); sizeof(struct sctp_authchunk));
if (ret < 0) { if (ret < 0) {
BIO_vfree(bio); BIO_vfree(bio);
ERR_raise(ERR_LIB_BIO, ERR_R_SYS_LIB); ERR_raise_data(ERR_LIB_BIO, ERR_R_SYS_LIB,
ERR_add_error_data(1, "Ensure SCTP AUTH chunks are enabled in kernel"); "Ensure SCTP AUTH chunks are enabled in kernel");
return NULL; return NULL;
} }
@ -891,10 +891,9 @@ BIO *BIO_new_dgram_sctp(int fd, int close_flag)
if (!auth_data || !auth_forward) { if (!auth_data || !auth_forward) {
BIO_vfree(bio); BIO_vfree(bio);
ERR_raise(ERR_LIB_BIO, ERR_R_SYS_LIB); ERR_raise_data(ERR_LIB_BIO, ERR_R_SYS_LIB,
ERR_add_error_data(1, "Ensure SCTP AUTH chunks are enabled on the "
"Ensure SCTP AUTH chunks are enabled on the " "underlying socket");
"underlying socket");
return NULL; return NULL;
} }

View File

@ -169,9 +169,9 @@ static int send_receive_check(OSSL_CMP_CTX *ctx, const OSSL_CMP_MSG *req,
ctx->msg_timeout = msg_timeout; /* restore original value */ ctx->msg_timeout = msg_timeout; /* restore original value */
if (*rep == NULL) { if (*rep == NULL) {
ERR_raise(ERR_LIB_CMP, CMP_R_TRANSFER_ERROR); /* or receiving response */ ERR_raise_data(ERR_LIB_CMP, CMP_R_TRANSFER_ERROR, /* or receiving response */
ERR_add_error_data(2, "request sent: ", req_type_str); "request sent: %s, expected response: %s",
ERR_add_error_data(2, ", expected response: ", expected_type_str); req_type_str, expected_type_str);
return 0; return 0;
} }
@ -633,11 +633,14 @@ static int cert_response(OSSL_CMP_CTX *ctx, int sleep, int rid,
/* not throwing failure earlier as transfer_cb may call ERR_clear_error() */ /* not throwing failure earlier as transfer_cb may call ERR_clear_error() */
if (fail_info != 0) { if (fail_info != 0) {
ERR_raise(ERR_LIB_CMP, CMP_R_CERTIFICATE_NOT_ACCEPTED); if (txt == NULL)
ERR_add_error_data(2, "rejecting newly enrolled cert with subject: ", ERR_raise_data(ERR_LIB_CMP, CMP_R_CERTIFICATE_NOT_ACCEPTED,
"rejecting newly enrolled cert with subject: %s",
subj); subj);
if (txt != NULL) else
ERR_add_error_txt("; ", txt); ERR_raise_data(ERR_LIB_CMP, CMP_R_CERTIFICATE_NOT_ACCEPTED,
"rejecting newly enrolled cert with subject: %s; %s",
subj, txt);
ret = 0; ret = 0;
} }
OPENSSL_free(subj); OPENSSL_free(subj);

View File

@ -888,14 +888,6 @@ static int suitable_rid(const ASN1_INTEGER *certReqId, int rid)
return rid == trid; return rid == trid;
} }
static void add_expected_rid(int rid)
{
char str[DECIMAL_SIZE(rid) + 1];
BIO_snprintf(str, sizeof(str), "%d", rid);
ERR_add_error_data(2, "expected certReqId = ", str);
}
/* /*
* returns a pointer to the PollResponse with the given CertReqId * returns a pointer to the PollResponse with the given CertReqId
* (or the first one in case -1) inside a PollRepContent * (or the first one in case -1) inside a PollRepContent
@ -917,8 +909,8 @@ ossl_cmp_pollrepcontent_get0_pollrep(const OSSL_CMP_POLLREPCONTENT *prc,
return pollRep; return pollRep;
} }
ERR_raise(ERR_LIB_CMP, CMP_R_CERTRESPONSE_NOT_FOUND); ERR_raise_data(ERR_LIB_CMP, CMP_R_CERTRESPONSE_NOT_FOUND,
add_expected_rid(rid); "expected certReqId = %d", rid);
return NULL; return NULL;
} }
@ -943,8 +935,8 @@ ossl_cmp_certrepmessage_get0_certresponse(const OSSL_CMP_CERTREPMESSAGE *crm,
return crep; return crep;
} }
ERR_raise(ERR_LIB_CMP, CMP_R_CERTRESPONSE_NOT_FOUND); ERR_raise_data(ERR_LIB_CMP, CMP_R_CERTRESPONSE_NOT_FOUND,
add_expected_rid(rid); "expected certReqId = %d", rid);
return NULL; return NULL;
} }

View File

@ -53,13 +53,9 @@ const char *ossl_cmp_PKIStatus_to_string(int status)
case OSSL_CMP_PKISTATUS_keyUpdateWarning: case OSSL_CMP_PKISTATUS_keyUpdateWarning:
return "PKIStatus: key update warning - update already done for the cert"; return "PKIStatus: key update warning - update already done for the cert";
default: default:
{ ERR_raise_data(ERR_LIB_CMP, CMP_R_ERROR_PARSING_PKISTATUS,
char buf[40]; "PKIStatus: invalid=%d", status);
BIO_snprintf(buf, sizeof(buf), "PKIStatus: invalid=%d", status); return NULL;
ERR_raise(ERR_LIB_CMP, CMP_R_ERROR_PARSING_PKISTATUS);
ERR_add_error_data(1, buf);
return NULL;
}
} }
} }

View File

@ -281,10 +281,8 @@ static int cms_signerinfo_verify_cert(CMS_SignerInfo *si,
i = X509_verify_cert(ctx); i = X509_verify_cert(ctx);
if (i <= 0) { if (i <= 0) {
j = X509_STORE_CTX_get_error(ctx); j = X509_STORE_CTX_get_error(ctx);
ERR_raise(ERR_LIB_CMS, ERR_raise_data(ERR_LIB_CMS, CMS_R_CERTIFICATE_VERIFY_ERROR,
CMS_R_CERTIFICATE_VERIFY_ERROR); "Verify error: %s", X509_verify_cert_error_string(j));
ERR_add_error_data(2, "Verify error:",
X509_verify_cert_error_string(j));
goto err; goto err;
} }
r = 1; r = 1;

View File

@ -397,8 +397,8 @@ static int bio_zlib_read(BIO *b, char *out, int outl)
while (zin->avail_in) { while (zin->avail_in) {
ret = inflate(zin, 0); ret = inflate(zin, 0);
if ((ret != Z_OK) && (ret != Z_STREAM_END)) { if ((ret != Z_OK) && (ret != Z_STREAM_END)) {
ERR_raise(ERR_LIB_COMP, COMP_R_ZLIB_INFLATE_ERROR); ERR_raise_data(ERR_LIB_COMP, COMP_R_ZLIB_INFLATE_ERROR,
ERR_add_error_data(2, "zlib error:", zError(ret)); "zlib error: %s", zError(ret));
return 0; return 0;
} }
/* If EOF or we've read everything then return */ /* If EOF or we've read everything then return */
@ -483,8 +483,8 @@ static int bio_zlib_write(BIO *b, const char *in, int inl)
/* Compress some more */ /* Compress some more */
ret = deflate(zout, 0); ret = deflate(zout, 0);
if (ret != Z_OK) { if (ret != Z_OK) {
ERR_raise(ERR_LIB_COMP, COMP_R_ZLIB_DEFLATE_ERROR); ERR_raise_data(ERR_LIB_COMP, COMP_R_ZLIB_DEFLATE_ERROR,
ERR_add_error_data(2, "zlib error:", zError(ret)); "zlib error: %s", zError(ret));
return 0; return 0;
} }
ctx->ocount = ctx->obufsize - zout->avail_out; ctx->ocount = ctx->obufsize - zout->avail_out;
@ -532,8 +532,8 @@ static int bio_zlib_flush(BIO *b)
if (ret == Z_STREAM_END) if (ret == Z_STREAM_END)
ctx->odone = 1; ctx->odone = 1;
else if (ret != Z_OK) { else if (ret != Z_OK) {
ERR_raise(ERR_LIB_COMP, COMP_R_ZLIB_DEFLATE_ERROR); ERR_raise_data(ERR_LIB_COMP, COMP_R_ZLIB_DEFLATE_ERROR,
ERR_add_error_data(2, "zlib error:", zError(ret)); "zlib error: %s", zError(ret));
return 0; return 0;
} }
ctx->ocount = ctx->obufsize - zout->avail_out; ctx->ocount = ctx->obufsize - zout->avail_out;

View File

@ -462,8 +462,8 @@ static int def_load_bio(CONF *conf, BIO *in, long *line)
} }
continue; continue;
} else if (*p != '=') { } else if (*p != '=') {
ERR_raise(ERR_LIB_CONF, CONF_R_MISSING_EQUAL_SIGN); ERR_raise_data(ERR_LIB_CONF, CONF_R_MISSING_EQUAL_SIGN,
ERR_add_error_data(2, "HERE-->", p); "HERE-->%s", p);
goto err; goto err;
} }
*end = '\0'; *end = '\0';
@ -760,9 +760,8 @@ static BIO *process_include(char *include, OPENSSL_DIR_CTX **dirctx,
if (S_ISDIR(st.st_mode)) { if (S_ISDIR(st.st_mode)) {
if (*dirctx != NULL) { if (*dirctx != NULL) {
ERR_raise(ERR_LIB_CONF, ERR_raise_data(ERR_LIB_CONF, CONF_R_RECURSIVE_DIRECTORY_INCLUDE,
CONF_R_RECURSIVE_DIRECTORY_INCLUDE); "%s", include);
ERR_add_error_data(1, include);
return NULL; return NULL;
} }
/* a directory, load its contents */ /* a directory, load its contents */

View File

@ -279,8 +279,8 @@ char *NCONF_get_string(const CONF *conf, const char *group, const char *name)
ERR_raise(ERR_LIB_CONF, CONF_R_NO_CONF_OR_ENVIRONMENT_VARIABLE); ERR_raise(ERR_LIB_CONF, CONF_R_NO_CONF_OR_ENVIRONMENT_VARIABLE);
return NULL; return NULL;
} }
ERR_raise(ERR_LIB_CONF, CONF_R_NO_VALUE); ERR_raise_data(ERR_LIB_CONF, CONF_R_NO_VALUE,
ERR_add_error_data(4, "group=", group, " name=", name); "group=%s name=%s", group, name);
return NULL; return NULL;
} }

View File

@ -121,8 +121,9 @@ int CONF_modules_load(const CONF *cnf, const char *appname,
if (values == NULL) { if (values == NULL) {
if (!(flags & CONF_MFLAGS_SILENT)) { if (!(flags & CONF_MFLAGS_SILENT)) {
ERR_clear_last_mark(); ERR_clear_last_mark();
ERR_raise(ERR_LIB_CONF, CONF_R_OPENSSL_CONF_REFERENCES_MISSING_SECTION); ERR_raise_data(ERR_LIB_CONF,
ERR_add_error_data(2, "openssl_conf=", vsection); CONF_R_OPENSSL_CONF_REFERENCES_MISSING_SECTION,
"openssl_conf=%s", vsection);
} else { } else {
ERR_pop_to_mark(); ERR_pop_to_mark();
} }
@ -228,8 +229,8 @@ static int module_run(const CONF *cnf, const char *name, const char *value,
if (!md) { if (!md) {
if (!(flags & CONF_MFLAGS_SILENT)) { if (!(flags & CONF_MFLAGS_SILENT)) {
ERR_raise(ERR_LIB_CONF, CONF_R_UNKNOWN_MODULE_NAME); ERR_raise_data(ERR_LIB_CONF, CONF_R_UNKNOWN_MODULE_NAME,
ERR_add_error_data(2, "module=", name); "module=%s", name);
} }
return -1; return -1;
} }
@ -237,14 +238,10 @@ static int module_run(const CONF *cnf, const char *name, const char *value,
ret = module_init(md, name, value, cnf); ret = module_init(md, name, value, cnf);
if (ret <= 0) { if (ret <= 0) {
if (!(flags & CONF_MFLAGS_SILENT)) { if (!(flags & CONF_MFLAGS_SILENT))
char rcode[DECIMAL_SIZE(ret) + 1]; ERR_raise_data(ERR_LIB_CONF, CONF_R_MODULE_INITIALIZATION_ERROR,
"module=%s, value=%s retcode=%-8d",
ERR_raise(ERR_LIB_CONF, CONF_R_MODULE_INITIALIZATION_ERROR); name, value, ret);
BIO_snprintf(rcode, sizeof(rcode), "%-8d", ret);
ERR_add_error_data(6, "module=", name, ", value=", value,
", retcode=", rcode);
}
} }
return ret; return ret;
@ -287,8 +284,7 @@ static CONF_MODULE *module_load_dso(const CONF *cnf,
err: err:
DSO_free(dso); DSO_free(dso);
ERR_raise(ERR_LIB_CONF, errcode); ERR_raise_data(ERR_LIB_CONF, errcode, "module=%s, path=%s", name, path);
ERR_add_error_data(4, "module=", name, ", path=", path);
return NULL; return NULL;
} }

View File

@ -68,11 +68,12 @@ static int ssl_module_init(CONF_IMODULE *md, const CONF *cnf)
ssl_conf_section = CONF_imodule_get_value(md); ssl_conf_section = CONF_imodule_get_value(md);
cmd_lists = NCONF_get_section(cnf, ssl_conf_section); cmd_lists = NCONF_get_section(cnf, ssl_conf_section);
if (sk_CONF_VALUE_num(cmd_lists) <= 0) { if (sk_CONF_VALUE_num(cmd_lists) <= 0) {
if (cmd_lists == NULL) int rcode =
ERR_raise(ERR_LIB_CONF, CONF_R_SSL_SECTION_NOT_FOUND); cmd_lists == NULL
else ? CONF_R_SSL_SECTION_NOT_FOUND
ERR_raise(ERR_LIB_CONF, CONF_R_SSL_SECTION_EMPTY); : CONF_R_SSL_SECTION_EMPTY;
ERR_add_error_data(2, "section=", ssl_conf_section);
ERR_raise_data(ERR_LIB_CONF, rcode, "section=%s", ssl_conf_section);
goto err; goto err;
} }
cnt = sk_CONF_VALUE_num(cmd_lists); cnt = sk_CONF_VALUE_num(cmd_lists);
@ -87,13 +88,13 @@ static int ssl_module_init(CONF_IMODULE *md, const CONF *cnf)
STACK_OF(CONF_VALUE) *cmds = NCONF_get_section(cnf, sect->value); STACK_OF(CONF_VALUE) *cmds = NCONF_get_section(cnf, sect->value);
if (sk_CONF_VALUE_num(cmds) <= 0) { if (sk_CONF_VALUE_num(cmds) <= 0) {
if (cmds == NULL) int rcode =
ERR_raise(ERR_LIB_CONF, cmds == NULL
CONF_R_SSL_COMMAND_SECTION_NOT_FOUND); ? CONF_R_SSL_COMMAND_SECTION_NOT_FOUND
else : CONF_R_SSL_COMMAND_SECTION_EMPTY;
ERR_raise(ERR_LIB_CONF,
CONF_R_SSL_COMMAND_SECTION_EMPTY); ERR_raise_data(ERR_LIB_CONF, rcode,
ERR_add_error_data(4, "name=", sect->name, ", value=", sect->value); "name=%s, value=%s", sect->name, sect->value);
goto err; goto err;
} }
ssl_name->name = OPENSSL_strdup(sect->name); ssl_name->name = OPENSSL_strdup(sect->name);

View File

@ -69,9 +69,13 @@ static int dl_load(DSO *dso)
DYNAMIC_PATH), 0L); DYNAMIC_PATH), 0L);
if (ptr == NULL) { if (ptr == NULL) {
char errbuf[160]; char errbuf[160];
ERR_raise(ERR_LIB_DSO, DSO_R_LOAD_FAILED);
if (openssl_strerror_r(errno, errbuf, sizeof(errbuf))) if (openssl_strerror_r(errno, errbuf, sizeof(errbuf)))
ERR_add_error_data(4, "filename(", filename, "): ", errbuf); ERR_raise_data(ERR_LIB_DSO, DSO_R_LOAD_FAILED,
"filename(%s): %s", filename, errbuf);
else
ERR_raise_data(ERR_LIB_DSO, DSO_R_LOAD_FAILED,
"filename(%s): errno %d", filename, errno);
goto err; goto err;
} }
if (!sk_push(dso->meth_data, (char *)ptr)) { if (!sk_push(dso->meth_data, (char *)ptr)) {
@ -135,9 +139,13 @@ static DSO_FUNC_TYPE dl_bind_func(DSO *dso, const char *symname)
} }
if (shl_findsym(&ptr, symname, TYPE_UNDEFINED, &sym) < 0) { if (shl_findsym(&ptr, symname, TYPE_UNDEFINED, &sym) < 0) {
char errbuf[160]; char errbuf[160];
ERR_raise(ERR_LIB_DSO, DSO_R_SYM_FAILURE);
if (openssl_strerror_r(errno, errbuf, sizeof(errbuf))) if (openssl_strerror_r(errno, errbuf, sizeof(errbuf)))
ERR_add_error_data(4, "symname(", symname, "): ", errbuf); ERR_raise_data(ERR_LIB_DSO, DSO_R_SYM_FAILURE,
"symname(%s): %s", symname, errbuf);
else
ERR_raise_data(ERR_LIB_DSO, DSO_R_SYM_FAILURE,
"symname(%s): errno %d", symname, errno);
return NULL; return NULL;
} }
return (DSO_FUNC_TYPE)sym; return (DSO_FUNC_TYPE)sym;

View File

@ -115,8 +115,8 @@ static int dlfcn_load(DSO *dso)
# endif # endif
ptr = dlopen(filename, flags); ptr = dlopen(filename, flags);
if (ptr == NULL) { if (ptr == NULL) {
ERR_raise(ERR_LIB_DSO, DSO_R_LOAD_FAILED); ERR_raise_data(ERR_LIB_DSO, DSO_R_LOAD_FAILED,
ERR_add_error_data(4, "filename(", filename, "): ", dlerror()); "filename(%s): %s", filename, dlerror());
goto err; goto err;
} }
/* /*
@ -185,8 +185,8 @@ static DSO_FUNC_TYPE dlfcn_bind_func(DSO *dso, const char *symname)
} }
u.dlret = dlsym(ptr, symname); u.dlret = dlsym(ptr, symname);
if (u.dlret == NULL) { if (u.dlret == NULL) {
ERR_raise(ERR_LIB_DSO, DSO_R_SYM_FAILURE); ERR_raise_data(ERR_LIB_DSO, DSO_R_SYM_FAILURE,
ERR_add_error_data(4, "symname(", symname, "): ", dlerror()); "symname(%s): %s", symname, dlerror());
return NULL; return NULL;
} }
return u.sym; return u.sym;
@ -437,6 +437,7 @@ static int dlfcn_pathbyaddr(void *addr, char *path, int sz)
return len; return len;
} }
/* TODO: what error report does this attach to? */
ERR_add_error_data(2, "dlfcn_pathbyaddr(): ", dlerror()); ERR_add_error_data(2, "dlfcn_pathbyaddr(): ", dlerror());
# endif # endif
return -1; return -1;

View File

@ -336,17 +336,15 @@ void vms_bind_sym(DSO *dso, const char *symname, void **sym)
else { else {
errstring[length] = '\0'; errstring[length] = '\0';
ERR_raise(ERR_LIB_DSO, DSO_R_SYM_FAILURE);
if (ptr->imagename_dsc.dsc$w_length) if (ptr->imagename_dsc.dsc$w_length)
ERR_add_error_data(9, ERR_raise_data(ERR_LIB_DSO, DSO_R_SYM_FAILURE,
"Symbol ", symname, "Symbol %s in %s (%s): %s",
" in ", ptr->filename, symname, ptr->filename, ptr->imagename,
" (", ptr->imagename, ")", errstring);
": ", errstring);
else else
ERR_add_error_data(6, ERR_raise_data(ERR_LIB_DSO, DSO_R_SYM_FAILURE,
"Symbol ", symname, "Symbol %s in %s: %s",
" in ", ptr->filename, ": ", errstring); symname, ptr->filename, errstring);
} }
return; return;
} }
@ -436,10 +434,9 @@ static char *vms_merger(DSO *dso, const char *filespec1,
else { else {
errstring[length] = '\0'; errstring[length] = '\0';
ERR_raise(ERR_LIB_DSO, DSO_R_FAILURE); ERR_raise_data(ERR_LIB_DSO, DSO_R_FAILURE,
ERR_add_error_data(7, "filespec \"%s\", default \"%s\": %s",
"filespec \"", filespec1, "\", ", filespec1, filespec2, errstring);
"defaults \"", filespec2, "\": ", errstring);
} }
return NULL; return NULL;
} }

View File

@ -105,8 +105,8 @@ static int win32_load(DSO *dso)
} }
h = LoadLibraryA(filename); h = LoadLibraryA(filename);
if (h == NULL) { if (h == NULL) {
ERR_raise(ERR_LIB_DSO, DSO_R_LOAD_FAILED); ERR_raise_data(ERR_LIB_DSO, DSO_R_LOAD_FAILED,
ERR_add_error_data(3, "filename(", filename, ")"); "filename(%s)", filename);
goto err; goto err;
} }
p = OPENSSL_malloc(sizeof(*p)); p = OPENSSL_malloc(sizeof(*p));
@ -181,8 +181,7 @@ static DSO_FUNC_TYPE win32_bind_func(DSO *dso, const char *symname)
} }
sym.f = GetProcAddress(*ptr, symname); sym.f = GetProcAddress(*ptr, symname);
if (sym.p == NULL) { if (sym.p == NULL) {
ERR_raise(ERR_LIB_DSO, DSO_R_SYM_FAILURE); ERR_raise_data(ERR_LIB_DSO, DSO_R_SYM_FAILURE, "symname(%s)", symname);
ERR_add_error_data(3, "symname(", symname, ")");
return NULL; return NULL;
} }
return (DSO_FUNC_TYPE)sym.f; return (DSO_FUNC_TYPE)sym.f;

View File

@ -3298,9 +3298,11 @@ EC_GROUP *EC_GROUP_new_by_curve_name_ex(OSSL_LIB_CTX *libctx, const char *propq,
if ((curve = ec_curve_nid2curve(nid)) == NULL if ((curve = ec_curve_nid2curve(nid)) == NULL
|| (ret = ec_group_new_from_data(libctx, propq, *curve)) == NULL) { || (ret = ec_group_new_from_data(libctx, propq, *curve)) == NULL) {
ERR_raise(ERR_LIB_EC, EC_R_UNKNOWN_GROUP);
#ifndef FIPS_MODULE #ifndef FIPS_MODULE
ERR_add_error_data(2, "name=", OBJ_nid2sn(nid)); ERR_raise_data(ERR_LIB_EC, EC_R_UNKNOWN_GROUP,
"name=%s", OBJ_nid2sn(nid));
#else
ERR_raise(ERR_LIB_EC, EC_R_UNKNOWN_GROUP);
#endif #endif
return NULL; return NULL;
} }

View File

@ -133,12 +133,12 @@ static int int_engine_configure(const char *name, const char *value, const CONF
ret = 1; ret = 1;
err: err:
if (ret != 1) { if (ret != 1) {
ERR_raise(ERR_LIB_ENGINE, if (ecmd == NULL)
ENGINE_R_ENGINE_CONFIGURATION_ERROR); ERR_raise(ERR_LIB_ENGINE, ENGINE_R_ENGINE_CONFIGURATION_ERROR);
if (ecmd) else
ERR_add_error_data(6, "section=", ecmd->section, ERR_raise_data(ERR_LIB_ENGINE, ENGINE_R_ENGINE_CONFIGURATION_ERROR,
", name=", ecmd->name, "section=%s, name=%s, value=%s",
", value=", ecmd->value); ecmd->section, ecmd->name, ecmd->value);
} }
ENGINE_free(e); ENGINE_free(e);
return ret; return ret;

View File

@ -85,9 +85,8 @@ int ENGINE_set_default_string(ENGINE *e, const char *def_list)
{ {
unsigned int flags = 0; unsigned int flags = 0;
if (!CONF_parse_list(def_list, ',', 1, int_def_cb, &flags)) { if (!CONF_parse_list(def_list, ',', 1, int_def_cb, &flags)) {
ERR_raise(ERR_LIB_ENGINE, ERR_raise_data(ERR_LIB_ENGINE, ENGINE_R_INVALID_STRING,
ENGINE_R_INVALID_STRING); "str=%s", def_list);
ERR_add_error_data(2, "str=", def_list);
return 0; return 0;
} }
return ENGINE_set_default(e, flags); return ENGINE_set_default(e, flags);

View File

@ -335,8 +335,7 @@ ENGINE *ENGINE_by_id(const char *id)
} }
notfound: notfound:
ENGINE_free(iterator); ENGINE_free(iterator);
ERR_raise(ERR_LIB_ENGINE, ENGINE_R_NO_SUCH_ENGINE); ERR_raise_data(ERR_LIB_ENGINE, ENGINE_R_NO_SUCH_ENGINE, "id=%s", id);
ERR_add_error_data(2, "id=", id);
return NULL; return NULL;
/* EEK! Experimental code ends */ /* EEK! Experimental code ends */
} }

View File

@ -56,9 +56,8 @@ static int alg_module_init(CONF_IMODULE *md, const CONF *cnf)
return 0; return 0;
} }
} else { } else {
ERR_raise(ERR_LIB_EVP, EVP_R_UNKNOWN_OPTION); ERR_raise_data(ERR_LIB_EVP, EVP_R_UNKNOWN_OPTION,
ERR_add_error_data(4, "name=", oval->name, "name=%s, value=%s", oval->name, oval->value);
", value=", oval->value);
return 0; return 0;
} }

View File

@ -94,12 +94,12 @@ int EVP_PBE_CipherInit(ASN1_OBJECT *pbe_obj, const char *pass, int passlen,
&cipher_nid, &md_nid, &keygen)) { &cipher_nid, &md_nid, &keygen)) {
char obj_tmp[80]; char obj_tmp[80];
ERR_raise(ERR_LIB_EVP, EVP_R_UNKNOWN_PBE_ALGORITHM);
if (pbe_obj == NULL) if (pbe_obj == NULL)
OPENSSL_strlcpy(obj_tmp, "NULL", sizeof(obj_tmp)); OPENSSL_strlcpy(obj_tmp, "NULL", sizeof(obj_tmp));
else else
i2t_ASN1_OBJECT(obj_tmp, sizeof(obj_tmp), pbe_obj); i2t_ASN1_OBJECT(obj_tmp, sizeof(obj_tmp), pbe_obj);
ERR_add_error_data(2, "TYPE=", obj_tmp); ERR_raise_data(ERR_LIB_EVP, EVP_R_UNKNOWN_PBE_ALGORITHM,
"TYPE=%s", obj_tmp);
return 0; return 0;
} }
@ -113,8 +113,8 @@ int EVP_PBE_CipherInit(ASN1_OBJECT *pbe_obj, const char *pass, int passlen,
else { else {
cipher = EVP_get_cipherbynid(cipher_nid); cipher = EVP_get_cipherbynid(cipher_nid);
if (!cipher) { if (!cipher) {
ERR_raise(ERR_LIB_EVP, EVP_R_UNKNOWN_CIPHER); ERR_raise_data(ERR_LIB_EVP, EVP_R_UNKNOWN_CIPHER,
ERR_add_error_data(1, OBJ_nid2sn(cipher_nid)); OBJ_nid2sn(cipher_nid));
return 0; return 0;
} }
} }

View File

@ -36,9 +36,9 @@ EVP_PKEY *EVP_PKCS82PKEY_ex(const PKCS8_PRIV_KEY_INFO *p8, OSSL_LIB_CTX *libctx,
} }
if (!EVP_PKEY_set_type(pkey, OBJ_obj2nid(algoid))) { if (!EVP_PKEY_set_type(pkey, OBJ_obj2nid(algoid))) {
ERR_raise(ERR_LIB_EVP, EVP_R_UNSUPPORTED_PRIVATE_KEY_ALGORITHM);
i2t_ASN1_OBJECT(obj_tmp, 80, algoid); i2t_ASN1_OBJECT(obj_tmp, 80, algoid);
ERR_add_error_data(2, "TYPE=", obj_tmp); ERR_raise_data(ERR_LIB_EVP, EVP_R_UNSUPPORTED_PRIVATE_KEY_ALGORITHM,
"TYPE=%s", obj_tmp);
goto error; goto error;
} }

View File

@ -383,41 +383,26 @@ static int parse_http_line1(char *line)
return retcode; return retcode;
default: default:
if (retcode < 400) if (retcode < 400)
ERR_raise(ERR_LIB_HTTP, HTTP_R_STATUS_CODE_UNSUPPORTED); retcode = HTTP_R_STATUS_CODE_UNSUPPORTED;
else else
ERR_raise(ERR_LIB_HTTP, HTTP_R_RECEIVED_ERROR); retcode = HTTP_R_RECEIVED_ERROR;
if (*reason == '\0') if (*reason == '\0')
ERR_add_error_data(2, "Code=", code); ERR_raise_data(ERR_LIB_HTTP, retcode, "Code=%s", code);
else else
ERR_add_error_data(4, "Code=", code, ",Reason=", reason); ERR_raise_data(ERR_LIB_HTTP, retcode,
"Code=%s, Reason=%s", code, reason);
return 0; return 0;
} }
} }
static int check_set_resp_len(OSSL_HTTP_REQ_CTX *rctx, unsigned long len) static int check_set_resp_len(OSSL_HTTP_REQ_CTX *rctx, unsigned long len)
{ {
const char *tag = NULL; if (len > rctx->max_resp_len)
unsigned long val = 0; ERR_raise_data(ERR_LIB_HTTP, HTTP_R_MAX_RESP_LEN_EXCEEDED,
"length=%lu, max=%lu", len, rctx->max_resp_len);
if (len > rctx->max_resp_len) { if (rctx->resp_len != 0 && rctx->resp_len != len)
ERR_raise(ERR_LIB_HTTP, HTTP_R_MAX_RESP_LEN_EXCEEDED); ERR_raise_data(ERR_LIB_HTTP, HTTP_R_INCONSISTENT_CONTENT_LENGTH,
tag = ",max="; "length=%lu, before=%lu", len, rctx->resp_len);
val = rctx->max_resp_len;
}
if (rctx->resp_len != 0 && rctx->resp_len != len) {
ERR_raise(ERR_LIB_HTTP, HTTP_R_INCONSISTENT_CONTENT_LENGTH);
tag = ",before=";
val = rctx->resp_len;
}
if (tag != NULL) {
char len_str[32];
char str[32];
BIO_snprintf(len_str, sizeof(len_str), "%lu", len);
BIO_snprintf(str, sizeof(str), "%lu", val);
ERR_add_error_data(4, "length=", len_str, tag, str);
return 0;
}
rctx->resp_len = len; rctx->resp_len = len;
return 1; return 1;
} }
@ -585,9 +570,9 @@ int OSSL_HTTP_REQ_CTX_nbio(OSSL_HTTP_REQ_CTX *rctx)
if (rctx->expected_ct != NULL if (rctx->expected_ct != NULL
&& strcasecmp(key, "Content-Type") == 0) { && strcasecmp(key, "Content-Type") == 0) {
if (strcasecmp(rctx->expected_ct, value) != 0) { if (strcasecmp(rctx->expected_ct, value) != 0) {
ERR_raise(ERR_LIB_HTTP, HTTP_R_UNEXPECTED_CONTENT_TYPE); ERR_raise_data(ERR_LIB_HTTP, HTTP_R_UNEXPECTED_CONTENT_TYPE,
ERR_add_error_data(4, "expected=", rctx->expected_ct, "expected=%s, actual=%s",
",actual=", value); rctx->expected_ct, value);
return 0; return 0;
} }
rctx->expected_ct = NULL; /* content-type has been found */ rctx->expected_ct = NULL; /* content-type has been found */
@ -595,8 +580,9 @@ int OSSL_HTTP_REQ_CTX_nbio(OSSL_HTTP_REQ_CTX *rctx)
if (strcasecmp(key, "Content-Length") == 0) { if (strcasecmp(key, "Content-Length") == 0) {
resp_len = strtoul(value, &line_end, 10); resp_len = strtoul(value, &line_end, 10);
if (line_end == value || *line_end != '\0') { if (line_end == value || *line_end != '\0') {
ERR_raise(ERR_LIB_HTTP, HTTP_R_ERROR_PARSING_CONTENT_LENGTH); ERR_raise_data(ERR_LIB_HTTP,
ERR_add_error_data(2, "input=", value); HTTP_R_ERROR_PARSING_CONTENT_LENGTH,
"input=%s", value);
return 0; return 0;
} }
if (!check_set_resp_len(rctx, resp_len)) if (!check_set_resp_len(rctx, resp_len))
@ -613,8 +599,8 @@ int OSSL_HTTP_REQ_CTX_nbio(OSSL_HTTP_REQ_CTX *rctx)
goto next_line; goto next_line;
if (rctx->expected_ct != NULL) { if (rctx->expected_ct != NULL) {
ERR_raise(ERR_LIB_HTTP, HTTP_R_MISSING_CONTENT_TYPE); ERR_raise_data(ERR_LIB_HTTP, HTTP_R_MISSING_CONTENT_TYPE,
ERR_add_error_data(2, "expected=", rctx->expected_ct); "expected=%s", rctx->expected_ct);
return 0; return 0;
} }
if (rctx->state == OHS_REDIRECT) { if (rctx->state == OHS_REDIRECT) {
@ -1244,8 +1230,8 @@ int OSSL_HTTP_proxy_connect(BIO *bio, const char *server, const char *port,
while (read_len > 0 && ossl_isspace(mbuf[read_len - 1])) while (read_len > 0 && ossl_isspace(mbuf[read_len - 1]))
read_len--; read_len--;
mbuf[read_len] = '\0'; mbuf[read_len] = '\0';
ERR_raise(ERR_LIB_HTTP, HTTP_R_CONNECT_FAILURE); ERR_raise_data(ERR_LIB_HTTP, HTTP_R_CONNECT_FAILURE,
ERR_add_error_data(2, "Reason=", mbufp); "Reason=%s", mbufp);
BIO_printf(bio_err, "%s: HTTP CONNECT failed, Reason=%s\n", BIO_printf(bio_err, "%s: HTTP CONNECT failed, Reason=%s\n",
prog, mbufp); prog, mbufp);
goto end; goto end;

View File

@ -60,9 +60,8 @@ static int ocsp_verify_signer(X509 *signer, int response,
ret = X509_verify_cert(ctx); ret = X509_verify_cert(ctx);
if (ret <= 0) { if (ret <= 0) {
ret = X509_STORE_CTX_get_error(ctx); ret = X509_STORE_CTX_get_error(ctx);
ERR_raise(ERR_LIB_OCSP, OCSP_R_CERTIFICATE_VERIFY_ERROR); ERR_raise_data(ERR_LIB_OCSP, OCSP_R_CERTIFICATE_VERIFY_ERROR,
ERR_add_error_data(2, "Verify error:", "Verify error: %s", X509_verify_cert_error_string(ret));
X509_verify_cert_error_string(ret));
goto end; goto end;
} }
if (chain != NULL) if (chain != NULL)

View File

@ -290,9 +290,9 @@ int PKCS7_verify(PKCS7 *p7, STACK_OF(X509) *certs, X509_STORE *store,
j = X509_STORE_CTX_get_error(cert_ctx); j = X509_STORE_CTX_get_error(cert_ctx);
X509_STORE_CTX_cleanup(cert_ctx); X509_STORE_CTX_cleanup(cert_ctx);
if (i <= 0) { if (i <= 0) {
ERR_raise(ERR_LIB_PKCS7, PKCS7_R_CERTIFICATE_VERIFY_ERROR); ERR_raise_data(ERR_LIB_PKCS7, PKCS7_R_CERTIFICATE_VERIFY_ERROR,
ERR_add_error_data(2, "Verify error:", "Verify error: %s",
X509_verify_cert_error_string(j)); X509_verify_cert_error_string(j));
goto err; goto err;
} }
/* Check for revocation status here */ /* Check for revocation status here */

View File

@ -87,8 +87,8 @@ static int provider_conf_load(OSSL_LIB_CTX *libctx, const char *name,
ecmds = NCONF_get_section(cnf, value); ecmds = NCONF_get_section(cnf, value);
if (!ecmds) { if (!ecmds) {
ERR_raise(ERR_LIB_CRYPTO, CRYPTO_R_PROVIDER_SECTION_ERROR); ERR_raise_data(ERR_LIB_CRYPTO, CRYPTO_R_PROVIDER_SECTION_ERROR,
ERR_add_error_data(3, "section=", value, " not found"); "section=%s not found", value);
return 0; return 0;
} }

View File

@ -645,8 +645,9 @@ static int random_conf_init(CONF_IMODULE *md, const CONF *cnf)
if (!random_set_string(&dgbl->rng_propq, cval->value)) if (!random_set_string(&dgbl->rng_propq, cval->value))
return 0; return 0;
} else { } else {
ERR_raise(ERR_LIB_CRYPTO, CRYPTO_R_UNKNOWN_NAME_IN_RANDOM_SECTION); ERR_raise_data(ERR_LIB_CRYPTO,
ERR_add_error_data(4, "name=", cval->name, ", value=", cval->value); CRYPTO_R_UNKNOWN_NAME_IN_RANDOM_SECTION,
"name=%s, value=%s", cval->name, cval->value);
r = 0; r = 0;
} }
} }

View File

@ -94,15 +94,15 @@ int RAND_load_file(const char *file, long bytes)
return 0; return 0;
if ((in = openssl_fopen(file, "rb")) == NULL) { if ((in = openssl_fopen(file, "rb")) == NULL) {
ERR_raise(ERR_LIB_RAND, RAND_R_CANNOT_OPEN_FILE); ERR_raise_data(ERR_LIB_RAND, RAND_R_CANNOT_OPEN_FILE,
ERR_add_error_data(2, "Filename=", file); "Filename=%s", file);
return -1; return -1;
} }
#ifndef OPENSSL_NO_POSIX_IO #ifndef OPENSSL_NO_POSIX_IO
if (fstat(fileno(in), &sb) < 0) { if (fstat(fileno(in), &sb) < 0) {
ERR_raise(ERR_LIB_RAND, RAND_R_INTERNAL_ERROR); ERR_raise_data(ERR_LIB_RAND, RAND_R_INTERNAL_ERROR,
ERR_add_error_data(2, "Filename=", file); "Filename=%s", file);
fclose(in); fclose(in);
return -1; return -1;
} }
@ -162,8 +162,7 @@ int RAND_load_file(const char *file, long bytes)
OPENSSL_cleanse(buf, sizeof(buf)); OPENSSL_cleanse(buf, sizeof(buf));
fclose(in); fclose(in);
if (!RAND_status()) { if (!RAND_status()) {
ERR_raise(ERR_LIB_RAND, RAND_R_RESEED_ERROR); ERR_raise_data(ERR_LIB_RAND, RAND_R_RESEED_ERROR, "Filename=%s", file);
ERR_add_error_data(2, "Filename=", file);
return -1; return -1;
} }
@ -179,8 +178,8 @@ int RAND_write_file(const char *file)
struct stat sb; struct stat sb;
if (stat(file, &sb) >= 0 && !S_ISREG(sb.st_mode)) { if (stat(file, &sb) >= 0 && !S_ISREG(sb.st_mode)) {
ERR_raise(ERR_LIB_RAND, RAND_R_NOT_A_REGULAR_FILE); ERR_raise_data(ERR_LIB_RAND, RAND_R_NOT_A_REGULAR_FILE,
ERR_add_error_data(2, "Filename=", file); "Filename=%s", file);
return -1; return -1;
} }
#endif #endif
@ -229,8 +228,8 @@ int RAND_write_file(const char *file)
if (out == NULL) if (out == NULL)
out = openssl_fopen(file, "wb"); out = openssl_fopen(file, "wb");
if (out == NULL) { if (out == NULL) {
ERR_raise(ERR_LIB_RAND, RAND_R_CANNOT_OPEN_FILE); ERR_raise_data(ERR_LIB_RAND, RAND_R_CANNOT_OPEN_FILE,
ERR_add_error_data(2, "Filename=", file); "Filename=%s", file);
return -1; return -1;
} }

View File

@ -112,14 +112,12 @@ EVP_PKEY *TS_CONF_load_key(const char *file, const char *pass)
static void ts_CONF_lookup_fail(const char *name, const char *tag) static void ts_CONF_lookup_fail(const char *name, const char *tag)
{ {
ERR_raise(ERR_LIB_TS, TS_R_VAR_LOOKUP_FAILURE); ERR_raise_data(ERR_LIB_TS, TS_R_VAR_LOOKUP_FAILURE, "%s::%s", name, tag);
ERR_add_error_data(3, name, "::", tag);
} }
static void ts_CONF_invalid(const char *name, const char *tag) static void ts_CONF_invalid(const char *name, const char *tag)
{ {
ERR_raise(ERR_LIB_TS, TS_R_VAR_BAD_VALUE); ERR_raise_data(ERR_LIB_TS, TS_R_VAR_BAD_VALUE, "%s::%s", name, tag);
ERR_add_error_data(3, name, "::", tag);
} }
const char *TS_CONF_get_tsa_section(CONF *conf, const char *section) const char *TS_CONF_get_tsa_section(CONF *conf, const char *section)
@ -184,10 +182,9 @@ int TS_CONF_set_default_engine(const char *name)
ret = 1; ret = 1;
err: err:
if (!ret) { if (!ret)
ERR_raise(ERR_LIB_TS, TS_R_COULD_NOT_SET_ENGINE); ERR_raise_data(ERR_LIB_TS, TS_R_COULD_NOT_SET_ENGINE,
ERR_add_error_data(2, "engine:", name); "engine:%s", name);
}
ENGINE_free(e); ENGINE_free(e);
return ret; return ret;
} }

View File

@ -178,9 +178,8 @@ static int ts_verify_cert(X509_STORE *store, STACK_OF(X509) *untrusted,
i = X509_verify_cert(cert_ctx); i = X509_verify_cert(cert_ctx);
if (i <= 0) { if (i <= 0) {
int j = X509_STORE_CTX_get_error(cert_ctx); int j = X509_STORE_CTX_get_error(cert_ctx);
ERR_raise(ERR_LIB_TS, TS_R_CERTIFICATE_VERIFY_ERROR); ERR_raise_data(ERR_LIB_TS, TS_R_CERTIFICATE_VERIFY_ERROR,
ERR_add_error_data(2, "Verify error:", "Verify error:%s", X509_verify_cert_error_string(j));
X509_verify_cert_error_string(j));
goto err; goto err;
} }
*chain = X509_STORE_CTX_get1_chain(cert_ctx); *chain = X509_STORE_CTX_get1_chain(cert_ctx);
@ -400,12 +399,11 @@ static int ts_check_status_info(TS_RESP *response)
if (failure_text[0] == '\0') if (failure_text[0] == '\0')
strcpy(failure_text, "unspecified"); strcpy(failure_text, "unspecified");
ERR_raise(ERR_LIB_TS, TS_R_NO_TIME_STAMP_TOKEN); ERR_raise_data(ERR_LIB_TS, TS_R_NO_TIME_STAMP_TOKEN,
ERR_add_error_data(6, "status code: %s, status text: %s, failure codes: %s",
"status code: ", status_text, status_text,
", status text: ", embedded_status_text ? embedded_status_text ? embedded_status_text : "unspecified",
embedded_status_text : "unspecified", failure_text);
", failure codes: ", failure_text);
OPENSSL_free(embedded_status_text); OPENSSL_free(embedded_status_text);
return 0; return 0;

View File

@ -540,10 +540,8 @@ int UI_process(UI *ui)
ok = -1; ok = -1;
} }
if (ok == -1) { if (ok == -1)
ERR_raise(ERR_LIB_UI, UI_R_PROCESSING_ERROR); ERR_raise_data(ERR_LIB_UI, UI_R_PROCESSING_ERROR, "while %s", state);
ERR_add_error_data(2, "while ", state);
}
return ok; return ok;
} }
@ -881,29 +879,21 @@ int UI_set_result_ex(UI *ui, UI_STRING *uis, const char *result, int len)
switch (uis->type) { switch (uis->type) {
case UIT_PROMPT: case UIT_PROMPT:
case UIT_VERIFY: case UIT_VERIFY:
{ if (len < uis->_.string_data.result_minsize) {
char number1[DECIMAL_SIZE(uis->_.string_data.result_minsize) + 1]; ui->flags |= UI_FLAG_REDOABLE;
char number2[DECIMAL_SIZE(uis->_.string_data.result_maxsize) + 1]; ERR_raise_data(ERR_LIB_UI, UI_R_RESULT_TOO_SMALL,
"You must type in %d to %d characters",
BIO_snprintf(number1, sizeof(number1), "%d", uis->_.string_data.result_minsize,
uis->_.string_data.result_minsize); uis->_.string_data.result_maxsize);
BIO_snprintf(number2, sizeof(number2), "%d", return -1;
uis->_.string_data.result_maxsize); }
if (len > uis->_.string_data.result_maxsize) {
if (len < uis->_.string_data.result_minsize) { ui->flags |= UI_FLAG_REDOABLE;
ui->flags |= UI_FLAG_REDOABLE; ERR_raise_data(ERR_LIB_UI, UI_R_RESULT_TOO_LARGE,
ERR_raise(ERR_LIB_UI, UI_R_RESULT_TOO_SMALL); "You must type in %d to %d characters",
ERR_add_error_data(5, "You must type in ", uis->_.string_data.result_minsize,
number1, " to ", number2, " characters"); uis->_.string_data.result_maxsize);
return -1; return -1;
}
if (len > uis->_.string_data.result_maxsize) {
ui->flags |= UI_FLAG_REDOABLE;
ERR_raise(ERR_LIB_UI, UI_R_RESULT_TOO_LARGE);
ERR_add_error_data(5, "You must type in ",
number1, " to ", number2, " characters");
return -1;
}
} }
if (uis->result_buf == NULL) { if (uis->result_buf == NULL) {

View File

@ -451,15 +451,12 @@ static int open_console(UI *ui)
* which seems appropriate. * which seems appropriate.
*/ */
if (errno == ENODEV) if (errno == ENODEV)
is_a_tty = 0; is_a_tty = 0;
else else
# endif # endif
{ {
char tmp_num[10]; ERR_raise_data(ERR_LIB_UI, UI_R_UNKNOWN_TTYGET_ERRNO_VALUE,
BIO_snprintf(tmp_num, sizeof(tmp_num) - 1, "%d", errno); "errno=%d", errno);
ERR_raise(ERR_LIB_UI, UI_R_UNKNOWN_TTYGET_ERRNO_VALUE);
ERR_add_error_data(2, "errno=", tmp_num);
return 0; return 0;
} }
} }
@ -469,11 +466,8 @@ static int open_console(UI *ui)
/* if there isn't a TT device, something is very wrong */ /* if there isn't a TT device, something is very wrong */
if (status != SS$_NORMAL) { if (status != SS$_NORMAL) {
char tmp_num[12]; ERR_raise_data(ERR_LIB_UI, UI_R_SYSASSIGN_ERROR,
"status=%%X%08X", status);
BIO_snprintf(tmp_num, sizeof(tmp_num) - 1, "%%X%08X", status);
ERR_raise(ERR_LIB_UI, UI_R_SYSASSIGN_ERROR);
ERR_add_error_data(2, "status=", tmp_num);
return 0; return 0;
} }
@ -506,15 +500,9 @@ static int noecho_console(UI *ui)
status = sys$qiow(0, channel, IO$_SETMODE, &iosb, 0, 0, tty_new, 12, status = sys$qiow(0, channel, IO$_SETMODE, &iosb, 0, 0, tty_new, 12,
0, 0, 0, 0); 0, 0, 0, 0);
if ((status != SS$_NORMAL) || (iosb.iosb$w_value != SS$_NORMAL)) { if ((status != SS$_NORMAL) || (iosb.iosb$w_value != SS$_NORMAL)) {
char tmp_num[2][12]; ERR_raise_data(ERR_LIB_UI, UI_R_SYSQIOW_ERROR,
"status=%%X%08X, iosb.iosb$w_value=%%X%08X",
BIO_snprintf(tmp_num[0], sizeof(tmp_num[0]) - 1, "%%X%08X", status, iosb.iosb$w_value);
status);
BIO_snprintf(tmp_num[1], sizeof(tmp_num[1]) - 1, "%%X%08X",
iosb.iosb$w_value);
ERR_raise(ERR_LIB_UI, UI_R_SYSQIOW_ERROR);
ERR_add_error_data(5, "status=", tmp_num[0],
",", "iosb.iosb$w_value=", tmp_num[1]);
return 0; return 0;
} }
} }
@ -544,15 +532,9 @@ static int echo_console(UI *ui)
status = sys$qiow(0, channel, IO$_SETMODE, &iosb, 0, 0, tty_new, 12, status = sys$qiow(0, channel, IO$_SETMODE, &iosb, 0, 0, tty_new, 12,
0, 0, 0, 0); 0, 0, 0, 0);
if ((status != SS$_NORMAL) || (iosb.iosb$w_value != SS$_NORMAL)) { if ((status != SS$_NORMAL) || (iosb.iosb$w_value != SS$_NORMAL)) {
char tmp_num[2][12]; ERR_raise_data(ERR_LIB_UI, UI_R_SYSQIOW_ERROR,
"status=%%X%08X, iosb.iosb$w_value=%%X%08X",
BIO_snprintf(tmp_num[0], sizeof(tmp_num[0]) - 1, "%%X%08X", status, iosb.iosb$w_value);
status);
BIO_snprintf(tmp_num[1], sizeof(tmp_num[1]) - 1, "%%X%08X",
iosb.iosb$w_value);
ERR_raise(ERR_LIB_UI, UI_R_SYSQIOW_ERROR);
ERR_add_error_data(5, "status=", tmp_num[0],
",", "iosb.iosb$w_value=", tmp_num[1]);
return 0; return 0;
} }
} }
@ -575,11 +557,8 @@ static int close_console(UI *ui)
# ifdef OPENSSL_SYS_VMS # ifdef OPENSSL_SYS_VMS
status = sys$dassgn(channel); status = sys$dassgn(channel);
if (status != SS$_NORMAL) { if (status != SS$_NORMAL) {
char tmp_num[12]; ERR_raise_data(ERR_LIB_UI, UI_R_SYSDASSGN_ERROR,
"status=%%X%08X", status);
BIO_snprintf(tmp_num, sizeof(tmp_num) - 1, "%%X%08X", status);
ERR_raise(ERR_LIB_UI, UI_R_SYSDASSGN_ERROR);
ERR_add_error_data(2, "status=", tmp_num);
return 0; return 0;
} }
# endif # endif

View File

@ -919,9 +919,8 @@ static void *v2i_IPAddrBlocks(const struct v3_ext_method *method,
afi = IANA_AFI_IPV6; afi = IANA_AFI_IPV6;
safi = &safi_; safi = &safi_;
} else { } else {
ERR_raise(ERR_LIB_X509V3, ERR_raise_data(ERR_LIB_X509V3, X509V3_R_EXTENSION_NAME_ERROR,
X509V3_R_EXTENSION_NAME_ERROR); "%s", val->name);
ERR_add_error_data(1, val->name);
goto err; goto err;
} }

View File

@ -100,8 +100,8 @@ static AUTHORITY_KEYID *v2i_AUTHORITY_KEYID(X509V3_EXT_METHOD *method,
if (cnf->value && strcmp(cnf->value, "always") == 0) if (cnf->value && strcmp(cnf->value, "always") == 0)
issuer = 2; issuer = 2;
} else { } else {
ERR_raise(ERR_LIB_X509V3, X509V3_R_UNKNOWN_OPTION); ERR_raise_data(ERR_LIB_X509V3, X509V3_R_UNKNOWN_OPTION,
ERR_add_error_data(2, "name=", cnf->name); "name=%s", cnf->name);
return NULL; return NULL;
} }
} }

View File

@ -524,8 +524,8 @@ GENERAL_NAME *a2i_GENERAL_NAME(GENERAL_NAME *out,
{ {
ASN1_OBJECT *obj; ASN1_OBJECT *obj;
if ((obj = OBJ_txt2obj(value, 0)) == NULL) { if ((obj = OBJ_txt2obj(value, 0)) == NULL) {
ERR_raise(ERR_LIB_X509V3, X509V3_R_BAD_OBJECT); ERR_raise_data(ERR_LIB_X509V3, X509V3_R_BAD_OBJECT,
ERR_add_error_data(2, "value=", value); "value=%s", value);
goto err; goto err;
} }
gen->d.rid = obj; gen->d.rid = obj;
@ -538,8 +538,8 @@ GENERAL_NAME *a2i_GENERAL_NAME(GENERAL_NAME *out,
else else
gen->d.ip = a2i_IPADDRESS(value); gen->d.ip = a2i_IPADDRESS(value);
if (gen->d.ip == NULL) { if (gen->d.ip == NULL) {
ERR_raise(ERR_LIB_X509V3, X509V3_R_BAD_IP_ADDRESS); ERR_raise_data(ERR_LIB_X509V3, X509V3_R_BAD_IP_ADDRESS,
ERR_add_error_data(2, "value=", value); "value=%s", value);
goto err; goto err;
} }
break; break;
@ -612,8 +612,8 @@ GENERAL_NAME *v2i_GENERAL_NAME_ex(GENERAL_NAME *out,
else if (!v3_name_cmp(name, "otherName")) else if (!v3_name_cmp(name, "otherName"))
type = GEN_OTHERNAME; type = GEN_OTHERNAME;
else { else {
ERR_raise(ERR_LIB_X509V3, X509V3_R_UNSUPPORTED_OPTION); ERR_raise_data(ERR_LIB_X509V3, X509V3_R_UNSUPPORTED_OPTION,
ERR_add_error_data(2, "name=", name); "name=%s", name);
return NULL; return NULL;
} }
@ -658,8 +658,8 @@ static int do_dirname(GENERAL_NAME *gen, const char *value, X509V3_CTX *ctx)
goto err; goto err;
sk = X509V3_get_section(ctx, value); sk = X509V3_get_section(ctx, value);
if (!sk) { if (!sk) {
ERR_raise(ERR_LIB_X509V3, X509V3_R_SECTION_NOT_FOUND); ERR_raise_data(ERR_LIB_X509V3, X509V3_R_SECTION_NOT_FOUND,
ERR_add_error_data(2, "section=", value); "section=%s", value);
goto err; goto err;
} }
/* FIXME: should allow other character types... */ /* FIXME: should allow other character types... */

View File

@ -81,9 +81,8 @@ ASN1_BIT_STRING *v2i_ASN1_BIT_STRING(X509V3_EXT_METHOD *method,
} }
} }
if (!bnam->lname) { if (!bnam->lname) {
ERR_raise(ERR_LIB_X509V3, ERR_raise_data(ERR_LIB_X509V3, X509V3_R_UNKNOWN_BIT_STRING_ARGUMENT,
X509V3_R_UNKNOWN_BIT_STRING_ARGUMENT); "%s", val->name);
ERR_add_error_data(1, val->name);
ASN1_BIT_STRING_free(bs); ASN1_BIT_STRING_free(bs);
return NULL; return NULL;
} }

View File

@ -44,12 +44,13 @@ static X509_EXTENSION *X509V3_EXT_nconf_int(CONF *conf, X509V3_CTX *ctx,
return v3_generic_extension(name, value, crit, ext_type, ctx); return v3_generic_extension(name, value, crit, ext_type, ctx);
ret = do_ext_nconf(conf, ctx, OBJ_sn2nid(name), crit, value); ret = do_ext_nconf(conf, ctx, OBJ_sn2nid(name), crit, value);
if (!ret) { if (!ret) {
ERR_raise(ERR_LIB_X509V3, X509V3_R_ERROR_IN_EXTENSION);
if (section != NULL) if (section != NULL)
ERR_add_error_data(6, "section=", section, ERR_raise_data(ERR_LIB_X509V3, X509V3_R_ERROR_IN_EXTENSION,
", name=", name, ", value=", value); "section=%s, name=%s, value=%s",
section, name, value);
else else
ERR_add_error_data(4, "name=", name, ", value=", value); ERR_raise_data(ERR_LIB_X509V3, X509V3_R_ERROR_IN_EXTENSION,
"name=%s, value=%s", name, value);
} }
return ret; return ret;
} }
@ -98,10 +99,8 @@ static X509_EXTENSION *do_ext_nconf(CONF *conf, X509V3_CTX *ctx, int ext_nid,
else else
nval = X509V3_parse_list(value); nval = X509V3_parse_list(value);
if (nval == NULL || sk_CONF_VALUE_num(nval) <= 0) { if (nval == NULL || sk_CONF_VALUE_num(nval) <= 0) {
ERR_raise(ERR_LIB_X509V3, ERR_raise_data(ERR_LIB_X509V3, X509V3_R_INVALID_EXTENSION_STRING,
X509V3_R_INVALID_EXTENSION_STRING); "name=%s,section=%s", OBJ_nid2sn(ext_nid), value);
ERR_add_error_data(4, "name=", OBJ_nid2sn(ext_nid), ",section=",
value);
if (*value != '@') if (*value != '@')
sk_CONF_VALUE_pop_free(nval, X509V3_conf_free); sk_CONF_VALUE_pop_free(nval, X509V3_conf_free);
return NULL; return NULL;
@ -122,9 +121,8 @@ static X509_EXTENSION *do_ext_nconf(CONF *conf, X509V3_CTX *ctx, int ext_nid,
if ((ext_struc = method->r2i(method, ctx, value)) == NULL) if ((ext_struc = method->r2i(method, ctx, value)) == NULL)
return NULL; return NULL;
} else { } else {
ERR_raise(ERR_LIB_X509V3, ERR_raise_data(ERR_LIB_X509V3, X509V3_R_EXTENSION_SETTING_NOT_SUPPORTED,
X509V3_R_EXTENSION_SETTING_NOT_SUPPORTED); "name=%s", OBJ_nid2sn(ext_nid));
ERR_add_error_data(2, "name=", OBJ_nid2sn(ext_nid));
return NULL; return NULL;
} }
@ -242,9 +240,8 @@ static X509_EXTENSION *v3_generic_extension(const char *ext, const char *value,
X509_EXTENSION *extension = NULL; X509_EXTENSION *extension = NULL;
if ((obj = OBJ_txt2obj(ext, 0)) == NULL) { if ((obj = OBJ_txt2obj(ext, 0)) == NULL) {
ERR_raise(ERR_LIB_X509V3, ERR_raise_data(ERR_LIB_X509V3, X509V3_R_EXTENSION_NAME_ERROR,
X509V3_R_EXTENSION_NAME_ERROR); "name=%s", ext);
ERR_add_error_data(2, "name=", ext);
goto err; goto err;
} }
@ -254,9 +251,8 @@ static X509_EXTENSION *v3_generic_extension(const char *ext, const char *value,
ext_der = generic_asn1(value, ctx, &ext_len); ext_der = generic_asn1(value, ctx, &ext_len);
if (ext_der == NULL) { if (ext_der == NULL) {
ERR_raise(ERR_LIB_X509V3, ERR_raise_data(ERR_LIB_X509V3, X509V3_R_EXTENSION_VALUE_ERROR,
X509V3_R_EXTENSION_VALUE_ERROR); "value=%s", value);
ERR_add_error_data(2, "value=", value);
goto err; goto err;
} }

View File

@ -126,8 +126,8 @@ static STACK_OF(POLICYINFO) *r2i_certpol(X509V3_EXT_METHOD *method,
polsect = X509V3_get_section(ctx, pstr + 1); polsect = X509V3_get_section(ctx, pstr + 1);
if (polsect == NULL) { if (polsect == NULL) {
ERR_raise(ERR_LIB_X509V3, X509V3_R_INVALID_SECTION); ERR_raise_data(ERR_LIB_X509V3, X509V3_R_INVALID_SECTION,
ERR_add_error_data(1, cnf->name); "%s", cnf->name);
goto err; goto err;
} }
pol = policy_section(ctx, polsect, ia5org); pol = policy_section(ctx, polsect, ia5org);
@ -136,9 +136,9 @@ static STACK_OF(POLICYINFO) *r2i_certpol(X509V3_EXT_METHOD *method,
goto err; goto err;
} else { } else {
if ((pobj = OBJ_txt2obj(cnf->name, 0)) == NULL) { if ((pobj = OBJ_txt2obj(cnf->name, 0)) == NULL) {
ERR_raise(ERR_LIB_X509V3, ERR_raise_data(ERR_LIB_X509V3,
X509V3_R_INVALID_OBJECT_IDENTIFIER); X509V3_R_INVALID_OBJECT_IDENTIFIER,
ERR_add_error_data(1, cnf->name); "%s", cnf->name);
goto err; goto err;
} }
pol = POLICYINFO_new(); pol = POLICYINFO_new();

View File

@ -92,9 +92,8 @@ static void *v2i_EXTENDED_KEY_USAGE(const X509V3_EXT_METHOD *method,
extval = val->name; extval = val->name;
if ((objtmp = OBJ_txt2obj(extval, 0)) == NULL) { if ((objtmp = OBJ_txt2obj(extval, 0)) == NULL) {
sk_ASN1_OBJECT_pop_free(extku, ASN1_OBJECT_free); sk_ASN1_OBJECT_pop_free(extku, ASN1_OBJECT_free);
ERR_raise(ERR_LIB_X509V3, ERR_raise_data(ERR_LIB_X509V3, X509V3_R_INVALID_OBJECT_IDENTIFIER,
X509V3_R_INVALID_OBJECT_IDENTIFIER); "%s", extval);
ERR_add_error_data(1, extval);
return NULL; return NULL;
} }
sk_ASN1_OBJECT_push(extku, objtmp); /* no failure as it was reserved */ sk_ASN1_OBJECT_push(extku, objtmp); /* no failure as it was reserved */

View File

@ -106,9 +106,9 @@ static AUTHORITY_INFO_ACCESS *v2i_AUTHORITY_INFO_ACCESS(X509V3_EXT_METHOD
AUTHORITY_INFO_ACCESS *ainfo = NULL; AUTHORITY_INFO_ACCESS *ainfo = NULL;
CONF_VALUE *cnf, ctmp; CONF_VALUE *cnf, ctmp;
ACCESS_DESCRIPTION *acc; ACCESS_DESCRIPTION *acc;
int i, objlen; int i;
const int num = sk_CONF_VALUE_num(nval); const int num = sk_CONF_VALUE_num(nval);
char *objtmp, *ptmp; char *ptmp;
if ((ainfo = sk_ACCESS_DESCRIPTION_new_reserve(NULL, num)) == NULL) { if ((ainfo = sk_ACCESS_DESCRIPTION_new_reserve(NULL, num)) == NULL) {
ERR_raise(ERR_LIB_X509V3, ERR_R_MALLOC_FAILURE); ERR_raise(ERR_LIB_X509V3, ERR_R_MALLOC_FAILURE);
@ -126,26 +126,16 @@ static AUTHORITY_INFO_ACCESS *v2i_AUTHORITY_INFO_ACCESS(X509V3_EXT_METHOD
ERR_raise(ERR_LIB_X509V3, X509V3_R_INVALID_SYNTAX); ERR_raise(ERR_LIB_X509V3, X509V3_R_INVALID_SYNTAX);
goto err; goto err;
} }
objlen = ptmp - cnf->name;
ctmp.name = ptmp + 1; ctmp.name = ptmp + 1;
ctmp.value = cnf->value; ctmp.value = cnf->value;
if (!v2i_GENERAL_NAME_ex(acc->location, method, ctx, &ctmp, 0)) if (!v2i_GENERAL_NAME_ex(acc->location, method, ctx, &ctmp, 0))
goto err; goto err;
if ((objtmp = OPENSSL_strndup(cnf->name, objlen)) == NULL) { acc->method = OBJ_txt2obj(cnf->value, 0);
ERR_raise(ERR_LIB_X509V3,
ERR_R_MALLOC_FAILURE);
goto err;
}
acc->method = OBJ_txt2obj(objtmp, 0);
if (!acc->method) { if (!acc->method) {
ERR_raise(ERR_LIB_X509V3, ERR_raise_data(ERR_LIB_X509V3, X509V3_R_BAD_OBJECT,
X509V3_R_BAD_OBJECT); "value=%s", cnf->value);
ERR_add_error_data(2, "value=", objtmp);
OPENSSL_free(objtmp);
goto err; goto err;
} }
OPENSSL_free(objtmp);
} }
return ainfo; return ainfo;
err: err:

View File

@ -73,8 +73,8 @@ static void *v2i_POLICY_CONSTRAINTS(const X509V3_EXT_METHOD *method,
if (!X509V3_get_value_int(val, &pcons->inhibitPolicyMapping)) if (!X509V3_get_value_int(val, &pcons->inhibitPolicyMapping))
goto err; goto err;
} else { } else {
ERR_raise(ERR_LIB_X509V3, X509V3_R_INVALID_NAME); ERR_raise_data(ERR_LIB_X509V3, X509V3_R_INVALID_NAME,
ERR_add_error_data(1, val->name); "%s", val->name);
goto err; goto err;
} }
} }

View File

@ -80,17 +80,15 @@ static void *v2i_POLICY_MAPPINGS(const X509V3_EXT_METHOD *method,
for (i = 0; i < num; i++) { for (i = 0; i < num; i++) {
val = sk_CONF_VALUE_value(nval, i); val = sk_CONF_VALUE_value(nval, i);
if (!val->value || !val->name) { if (!val->value || !val->name) {
ERR_raise(ERR_LIB_X509V3, ERR_raise_data(ERR_LIB_X509V3, X509V3_R_INVALID_OBJECT_IDENTIFIER,
X509V3_R_INVALID_OBJECT_IDENTIFIER); "%s", val->name);
ERR_add_error_data(1, val->name);
goto err; goto err;
} }
obj1 = OBJ_txt2obj(val->name, 0); obj1 = OBJ_txt2obj(val->name, 0);
obj2 = OBJ_txt2obj(val->value, 0); obj2 = OBJ_txt2obj(val->value, 0);
if (!obj1 || !obj2) { if (!obj1 || !obj2) {
ERR_raise(ERR_LIB_X509V3, ERR_raise_data(ERR_LIB_X509V3, X509V3_R_INVALID_OBJECT_IDENTIFIER,
X509V3_R_INVALID_OBJECT_IDENTIFIER); "%s", val->name);
ERR_add_error_data(1, val->name);
goto err; goto err;
} }
pmap = POLICY_MAPPING_new(); pmap = POLICY_MAPPING_new();

View File

@ -222,9 +222,8 @@ X509_ATTRIBUTE *X509_ATTRIBUTE_create_by_txt(X509_ATTRIBUTE **attr,
obj = OBJ_txt2obj(atrname, 0); obj = OBJ_txt2obj(atrname, 0);
if (obj == NULL) { if (obj == NULL) {
ERR_raise(ERR_LIB_X509, ERR_raise_data(ERR_LIB_X509, X509_R_INVALID_FIELD_NAME,
X509_R_INVALID_FIELD_NAME); "name=%s", atrname);
ERR_add_error_data(2, "name=", atrname);
return NULL; return NULL;
} }
nattr = X509_ATTRIBUTE_create_by_OBJ(attr, obj, type, bytes, len); nattr = X509_ATTRIBUTE_create_by_OBJ(attr, obj, type, bytes, len);

View File

@ -246,9 +246,8 @@ X509_NAME_ENTRY *X509_NAME_ENTRY_create_by_txt(X509_NAME_ENTRY **ne,
obj = OBJ_txt2obj(field, 0); obj = OBJ_txt2obj(field, 0);
if (obj == NULL) { if (obj == NULL) {
ERR_raise(ERR_LIB_X509, ERR_raise_data(ERR_LIB_X509, X509_R_INVALID_FIELD_NAME,
X509_R_INVALID_FIELD_NAME); "name=%s", field);
ERR_add_error_data(2, "name=", field);
return NULL; return NULL;
} }
nentry = X509_NAME_ENTRY_create_by_OBJ(ne, obj, type, bytes, len); nentry = X509_NAME_ENTRY_create_by_OBJ(ne, obj, type, bytes, len);