diff options
author | Richard Levitte <levitte@openssl.org> | 2020-11-04 16:14:00 +0100 |
---|---|---|
committer | Richard Levitte <levitte@openssl.org> | 2020-11-13 09:35:31 +0100 |
commit | a150f8e1fcc38752fef4d7c75d765d8efc7d46d6 (patch) | |
tree | f7f62c9a5d8407d8b17820fbef67378aa7b9ddbb | |
parent | 9311d0c471ca2eaa259e8c1bbbeb7c46394c7ba2 (diff) | |
download | openssl-new-a150f8e1fcc38752fef4d7c75d765d8efc7d46d6.tar.gz |
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)
51 files changed, 273 insertions, 366 deletions
diff --git a/apps/lib/apps.c b/apps/lib/apps.c index 8125dd1160..ab76ed8e7a 100644 --- a/apps/lib/apps.c +++ b/apps/lib/apps.c @@ -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)) return NULL; if (use_ssl && ssl_ctx == NULL) { - ERR_raise(ERR_LIB_HTTP, ERR_R_PASSED_NULL_PARAMETER); - ERR_add_error_data(1, "missing SSL_CTX"); + ERR_raise_data(ERR_LIB_HTTP, ERR_R_PASSED_NULL_PARAMETER, + "missing SSL_CTX"); goto end; } diff --git a/crypto/asn1/a_mbstr.c b/crypto/asn1/a_mbstr.c index 9b307dbb9d..7279133c2a 100644 --- a/crypto/asn1/a_mbstr.c +++ b/crypto/asn1/a_mbstr.c @@ -49,7 +49,6 @@ int ASN1_mbstring_ncopy(ASN1_STRING **out, const unsigned char *in, int len, ASN1_STRING *dest; unsigned char *p; int nchar; - char strbuf[32]; int (*cpyfunc) (unsigned long, void *) = NULL; if (len == -1) 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)) { - ERR_raise(ERR_LIB_ASN1, ASN1_R_STRING_TOO_SHORT); - BIO_snprintf(strbuf, sizeof(strbuf), "%ld", minsize); - ERR_add_error_data(2, "minsize=", strbuf); + ERR_raise_data(ERR_LIB_ASN1, ASN1_R_STRING_TOO_SHORT, + "minsize=%ld", minsize); return -1; } if ((maxsize > 0) && (nchar > maxsize)) { - ERR_raise(ERR_LIB_ASN1, ASN1_R_STRING_TOO_LONG); - BIO_snprintf(strbuf, sizeof(strbuf), "%ld", maxsize); - ERR_add_error_data(2, "maxsize=", strbuf); + ERR_raise_data(ERR_LIB_ASN1, ASN1_R_STRING_TOO_LONG, + "maxsize=%ld", maxsize); return -1; } diff --git a/crypto/asn1/asn1_gen.c b/crypto/asn1/asn1_gen.c index e717a93653..3c003ee103 100644 --- a/crypto/asn1/asn1_gen.c +++ b/crypto/asn1/asn1_gen.c @@ -263,8 +263,7 @@ static int asn1_cb(const char *elem, int len, void *bitstr) utype = asn1_str2tag(elem, len); if (utype == -1) { - ERR_raise(ERR_LIB_ASN1, ASN1_R_UNKNOWN_TAG); - ERR_add_error_data(2, "tag=", elem); + ERR_raise_data(ERR_LIB_ASN1, ASN1_R_UNKNOWN_TAG, "tag=%s", elem); 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) { - char erch[2]; long tag_num; char *eptr; if (!vstart) @@ -386,10 +384,8 @@ static int parse_tagging(const char *vstart, int vlen, int *ptag, int *pclass) break; default: - erch[0] = *eptr; - erch[1] = 0; - ERR_raise(ERR_LIB_ASN1, ASN1_R_INVALID_MODIFIER); - ERR_add_error_data(2, "Char=", erch); + ERR_raise_data(ERR_LIB_ASN1, ASN1_R_INVALID_MODIFIER, + "Char=%c", *eptr); return 0; } diff --git a/crypto/asn1/asn_mime.c b/crypto/asn1/asn_mime.c index 1e952734d0..8ee0970dc6 100644 --- a/crypto/asn1/asn_mime.c +++ b/crypto/asn1/asn_mime.c @@ -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") && strcmp(hdr->value, "application/pkcs7-signature")) { - ERR_raise(ERR_LIB_ASN1, ASN1_R_SIG_INVALID_MIME_TYPE); - ERR_add_error_data(2, "type: ", hdr->value); + ERR_raise_data(ERR_LIB_ASN1, ASN1_R_SIG_INVALID_MIME_TYPE, + "type: %s", hdr->value); sk_MIME_HEADER_pop_free(headers, mime_hdr_free); sk_BIO_pop_free(parts, BIO_vfree); 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") && strcmp(hdr->value, "application/pkcs7-mime")) { - ERR_raise(ERR_LIB_ASN1, ASN1_R_INVALID_MIME_TYPE); - ERR_add_error_data(2, "type: ", hdr->value); + ERR_raise_data(ERR_LIB_ASN1, ASN1_R_INVALID_MIME_TYPE, + "type: %s", hdr->value); sk_MIME_HEADER_pop_free(headers, mime_hdr_free); return NULL; } @@ -566,8 +566,8 @@ int SMIME_text(BIO *in, BIO *out) return 0; } if (strcmp(hdr->value, "text/plain")) { - ERR_raise(ERR_LIB_ASN1, ASN1_R_INVALID_MIME_TYPE); - ERR_add_error_data(2, "type: ", hdr->value); + ERR_raise_data(ERR_LIB_ASN1, ASN1_R_INVALID_MIME_TYPE, + "type: %s", hdr->value); sk_MIME_HEADER_pop_free(headers, mime_hdr_free); return 0; } diff --git a/crypto/asn1/asn_mstbl.c b/crypto/asn1/asn_mstbl.c index 3992468a01..3543cd2256 100644 --- a/crypto/asn1/asn_mstbl.c +++ b/crypto/asn1/asn_mstbl.c @@ -96,12 +96,12 @@ static int do_tcreate(const char *value, const char *name) rv = 1; err: if (rv == 0) { - ERR_raise(ERR_LIB_ASN1, ASN1_R_INVALID_STRING_TABLE_VALUE); if (cnf) - ERR_add_error_data(4, "field=", cnf->name, - ", value=", cnf->value); + ERR_raise_data(ERR_LIB_ASN1, ASN1_R_INVALID_STRING_TABLE_VALUE, + "field=%s, value=%s", cnf->name, cnf->value); 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 { rv = ASN1_STRING_TABLE_add(nid, tbl_min, tbl_max, tbl_mask, tbl_flags); diff --git a/crypto/bio/b_addr.c b/crypto/bio/b_addr.c index 7a8ac6fb9c..7515cf264b 100644 --- a/crypto/bio/b_addr.c +++ b/crypto/bio/b_addr.c @@ -213,12 +213,10 @@ static int addr_strings(const BIO_ADDR *ap, int numeric, if (ret == EAI_SYSTEM) { ERR_raise_data(ERR_LIB_SYS, get_last_socket_error(), "calling getnameinfo()"); - ERR_raise(ERR_LIB_BIO, ERR_R_SYS_LIB); } else # endif { - ERR_raise(ERR_LIB_BIO, ERR_R_SYS_LIB); - ERR_add_error_data(1, gai_strerror(ret)); + ERR_raise_data(ERR_LIB_BIO, ERR_R_SYS_LIB, gai_strerror(ret)); } return 0; } @@ -729,8 +727,8 @@ int BIO_lookup_ex(const char *host, const char *service, int lookup_type, goto retry; } # endif - ERR_raise(ERR_LIB_BIO, ERR_R_SYS_LIB); - ERR_add_error_data(1, gai_strerror(old_ret ? old_ret : gai_ret)); + ERR_raise_data(ERR_LIB_BIO, ERR_R_SYS_LIB, + gai_strerror(old_ret ? old_ret : gai_ret)); break; } } else { diff --git a/crypto/bio/bss_acpt.c b/crypto/bio/bss_acpt.c index 3b5c7f1c19..5b776224d6 100644 --- a/crypto/bio/bss_acpt.c +++ b/crypto/bio/bss_acpt.c @@ -156,10 +156,10 @@ static int acpt_state(BIO *b, BIO_ACCEPT *c) switch (c->state) { case ACPT_S_BEFORE: if (c->param_addr == NULL && c->param_serv == NULL) { - ERR_raise(ERR_LIB_BIO, BIO_R_NO_ACCEPT_ADDR_OR_SERVICE_SPECIFIED); - ERR_add_error_data(4, - "hostname=", c->param_addr, - " service=", c->param_serv); + ERR_raise_data(ERR_LIB_BIO, + BIO_R_NO_ACCEPT_ADDR_OR_SERVICE_SPECIFIED, + "hostname=%s, service=%s", + c->param_addr, c->param_serv); goto exit_loop; } diff --git a/crypto/bio/bss_conn.c b/crypto/bio/bss_conn.c index a88d1ce61b..c7bd0a329f 100644 --- a/crypto/bio/bss_conn.c +++ b/crypto/bio/bss_conn.c @@ -89,10 +89,10 @@ static int conn_state(BIO *b, BIO_CONNECT *c) switch (c->state) { case BIO_CONN_S_BEFORE: if (c->param_hostname == NULL && c->param_service == NULL) { - ERR_raise(ERR_LIB_BIO, BIO_R_NO_HOSTNAME_OR_SERVICE_SPECIFIED); - ERR_add_error_data(4, - "hostname=", c->param_hostname, - " service=", c->param_service); + ERR_raise_data(ERR_LIB_BIO, + BIO_R_NO_HOSTNAME_OR_SERVICE_SPECIFIED, + "hostname=%s service=%s", + c->param_hostname, c->param_service); goto exit_loop; } c->state = BIO_CONN_S_GET_ADDR; diff --git a/crypto/bio/bss_dgram.c b/crypto/bio/bss_dgram.c index 39b69572f9..45981ab27b 100644 --- a/crypto/bio/bss_dgram.c +++ b/crypto/bio/bss_dgram.c @@ -843,8 +843,8 @@ BIO *BIO_new_dgram_sctp(int fd, int close_flag) sizeof(struct sctp_authchunk)); if (ret < 0) { BIO_vfree(bio); - ERR_raise(ERR_LIB_BIO, ERR_R_SYS_LIB); - ERR_add_error_data(1, "Ensure SCTP AUTH chunks are enabled in kernel"); + ERR_raise_data(ERR_LIB_BIO, ERR_R_SYS_LIB, + "Ensure SCTP AUTH chunks are enabled in kernel"); return NULL; } 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)); if (ret < 0) { BIO_vfree(bio); - ERR_raise(ERR_LIB_BIO, ERR_R_SYS_LIB); - ERR_add_error_data(1, "Ensure SCTP AUTH chunks are enabled in kernel"); + ERR_raise_data(ERR_LIB_BIO, ERR_R_SYS_LIB, + "Ensure SCTP AUTH chunks are enabled in kernel"); return NULL; } @@ -891,10 +891,9 @@ BIO *BIO_new_dgram_sctp(int fd, int close_flag) if (!auth_data || !auth_forward) { BIO_vfree(bio); - ERR_raise(ERR_LIB_BIO, ERR_R_SYS_LIB); - ERR_add_error_data(1, - "Ensure SCTP AUTH chunks are enabled on the " - "underlying socket"); + ERR_raise_data(ERR_LIB_BIO, ERR_R_SYS_LIB, + "Ensure SCTP AUTH chunks are enabled on the " + "underlying socket"); return NULL; } diff --git a/crypto/cmp/cmp_client.c b/crypto/cmp/cmp_client.c index dd974413c0..c19eea818f 100644 --- a/crypto/cmp/cmp_client.c +++ b/crypto/cmp/cmp_client.c @@ -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 */ if (*rep == NULL) { - ERR_raise(ERR_LIB_CMP, CMP_R_TRANSFER_ERROR); /* or receiving response */ - ERR_add_error_data(2, "request sent: ", req_type_str); - ERR_add_error_data(2, ", expected response: ", expected_type_str); + ERR_raise_data(ERR_LIB_CMP, CMP_R_TRANSFER_ERROR, /* or receiving response */ + "request sent: %s, expected response: %s", + req_type_str, expected_type_str); 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() */ if (fail_info != 0) { - ERR_raise(ERR_LIB_CMP, CMP_R_CERTIFICATE_NOT_ACCEPTED); - ERR_add_error_data(2, "rejecting newly enrolled cert with subject: ", + if (txt == NULL) + ERR_raise_data(ERR_LIB_CMP, CMP_R_CERTIFICATE_NOT_ACCEPTED, + "rejecting newly enrolled cert with subject: %s", subj); - if (txt != NULL) - ERR_add_error_txt("; ", txt); + else + ERR_raise_data(ERR_LIB_CMP, CMP_R_CERTIFICATE_NOT_ACCEPTED, + "rejecting newly enrolled cert with subject: %s; %s", + subj, txt); ret = 0; } OPENSSL_free(subj); diff --git a/crypto/cmp/cmp_msg.c b/crypto/cmp/cmp_msg.c index eff093c6b5..1a4a873168 100644 --- a/crypto/cmp/cmp_msg.c +++ b/crypto/cmp/cmp_msg.c @@ -888,14 +888,6 @@ static int suitable_rid(const ASN1_INTEGER *certReqId, int rid) 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 * (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; } - ERR_raise(ERR_LIB_CMP, CMP_R_CERTRESPONSE_NOT_FOUND); - add_expected_rid(rid); + ERR_raise_data(ERR_LIB_CMP, CMP_R_CERTRESPONSE_NOT_FOUND, + "expected certReqId = %d", rid); return NULL; } @@ -943,8 +935,8 @@ ossl_cmp_certrepmessage_get0_certresponse(const OSSL_CMP_CERTREPMESSAGE *crm, return crep; } - ERR_raise(ERR_LIB_CMP, CMP_R_CERTRESPONSE_NOT_FOUND); - add_expected_rid(rid); + ERR_raise_data(ERR_LIB_CMP, CMP_R_CERTRESPONSE_NOT_FOUND, + "expected certReqId = %d", rid); return NULL; } diff --git a/crypto/cmp/cmp_status.c b/crypto/cmp/cmp_status.c index 1660906753..dc14f754de 100644 --- a/crypto/cmp/cmp_status.c +++ b/crypto/cmp/cmp_status.c @@ -53,13 +53,9 @@ const char *ossl_cmp_PKIStatus_to_string(int status) case OSSL_CMP_PKISTATUS_keyUpdateWarning: return "PKIStatus: key update warning - update already done for the cert"; default: - { - char buf[40]; - BIO_snprintf(buf, sizeof(buf), "PKIStatus: invalid=%d", status); - ERR_raise(ERR_LIB_CMP, CMP_R_ERROR_PARSING_PKISTATUS); - ERR_add_error_data(1, buf); - return NULL; - } + ERR_raise_data(ERR_LIB_CMP, CMP_R_ERROR_PARSING_PKISTATUS, + "PKIStatus: invalid=%d", status); + return NULL; } } diff --git a/crypto/cms/cms_smime.c b/crypto/cms/cms_smime.c index 84cd27afea..5c903f204b 100644 --- a/crypto/cms/cms_smime.c +++ b/crypto/cms/cms_smime.c @@ -281,10 +281,8 @@ static int cms_signerinfo_verify_cert(CMS_SignerInfo *si, i = X509_verify_cert(ctx); if (i <= 0) { j = X509_STORE_CTX_get_error(ctx); - ERR_raise(ERR_LIB_CMS, - CMS_R_CERTIFICATE_VERIFY_ERROR); - ERR_add_error_data(2, "Verify error:", - X509_verify_cert_error_string(j)); + ERR_raise_data(ERR_LIB_CMS, CMS_R_CERTIFICATE_VERIFY_ERROR, + "Verify error: %s", X509_verify_cert_error_string(j)); goto err; } r = 1; diff --git a/crypto/comp/c_zlib.c b/crypto/comp/c_zlib.c index 0211da9b91..5d69dc96d2 100644 --- a/crypto/comp/c_zlib.c +++ b/crypto/comp/c_zlib.c @@ -397,8 +397,8 @@ static int bio_zlib_read(BIO *b, char *out, int outl) while (zin->avail_in) { ret = inflate(zin, 0); if ((ret != Z_OK) && (ret != Z_STREAM_END)) { - ERR_raise(ERR_LIB_COMP, COMP_R_ZLIB_INFLATE_ERROR); - ERR_add_error_data(2, "zlib error:", zError(ret)); + ERR_raise_data(ERR_LIB_COMP, COMP_R_ZLIB_INFLATE_ERROR, + "zlib error: %s", zError(ret)); return 0; } /* 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 */ ret = deflate(zout, 0); if (ret != Z_OK) { - ERR_raise(ERR_LIB_COMP, COMP_R_ZLIB_DEFLATE_ERROR); - ERR_add_error_data(2, "zlib error:", zError(ret)); + ERR_raise_data(ERR_LIB_COMP, COMP_R_ZLIB_DEFLATE_ERROR, + "zlib error: %s", zError(ret)); return 0; } ctx->ocount = ctx->obufsize - zout->avail_out; @@ -532,8 +532,8 @@ static int bio_zlib_flush(BIO *b) if (ret == Z_STREAM_END) ctx->odone = 1; else if (ret != Z_OK) { - ERR_raise(ERR_LIB_COMP, COMP_R_ZLIB_DEFLATE_ERROR); - ERR_add_error_data(2, "zlib error:", zError(ret)); + ERR_raise_data(ERR_LIB_COMP, COMP_R_ZLIB_DEFLATE_ERROR, + "zlib error: %s", zError(ret)); return 0; } ctx->ocount = ctx->obufsize - zout->avail_out; diff --git a/crypto/conf/conf_def.c b/crypto/conf/conf_def.c index 5923f88212..2637e17fd8 100644 --- a/crypto/conf/conf_def.c +++ b/crypto/conf/conf_def.c @@ -462,8 +462,8 @@ static int def_load_bio(CONF *conf, BIO *in, long *line) } continue; } else if (*p != '=') { - ERR_raise(ERR_LIB_CONF, CONF_R_MISSING_EQUAL_SIGN); - ERR_add_error_data(2, "HERE-->", p); + ERR_raise_data(ERR_LIB_CONF, CONF_R_MISSING_EQUAL_SIGN, + "HERE-->%s", p); goto err; } *end = '\0'; @@ -760,9 +760,8 @@ static BIO *process_include(char *include, OPENSSL_DIR_CTX **dirctx, if (S_ISDIR(st.st_mode)) { if (*dirctx != NULL) { - ERR_raise(ERR_LIB_CONF, - CONF_R_RECURSIVE_DIRECTORY_INCLUDE); - ERR_add_error_data(1, include); + ERR_raise_data(ERR_LIB_CONF, CONF_R_RECURSIVE_DIRECTORY_INCLUDE, + "%s", include); return NULL; } /* a directory, load its contents */ diff --git a/crypto/conf/conf_lib.c b/crypto/conf/conf_lib.c index d100d5ed5c..1f106d8c07 100644 --- a/crypto/conf/conf_lib.c +++ b/crypto/conf/conf_lib.c @@ -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); return NULL; } - ERR_raise(ERR_LIB_CONF, CONF_R_NO_VALUE); - ERR_add_error_data(4, "group=", group, " name=", name); + ERR_raise_data(ERR_LIB_CONF, CONF_R_NO_VALUE, + "group=%s name=%s", group, name); return NULL; } diff --git a/crypto/conf/conf_mod.c b/crypto/conf/conf_mod.c index 9a07beb6b6..cb1bf7cd3c 100644 --- a/crypto/conf/conf_mod.c +++ b/crypto/conf/conf_mod.c @@ -121,8 +121,9 @@ int CONF_modules_load(const CONF *cnf, const char *appname, if (values == NULL) { if (!(flags & CONF_MFLAGS_SILENT)) { ERR_clear_last_mark(); - ERR_raise(ERR_LIB_CONF, CONF_R_OPENSSL_CONF_REFERENCES_MISSING_SECTION); - ERR_add_error_data(2, "openssl_conf=", vsection); + ERR_raise_data(ERR_LIB_CONF, + CONF_R_OPENSSL_CONF_REFERENCES_MISSING_SECTION, + "openssl_conf=%s", vsection); } else { ERR_pop_to_mark(); } @@ -228,8 +229,8 @@ static int module_run(const CONF *cnf, const char *name, const char *value, if (!md) { if (!(flags & CONF_MFLAGS_SILENT)) { - ERR_raise(ERR_LIB_CONF, CONF_R_UNKNOWN_MODULE_NAME); - ERR_add_error_data(2, "module=", name); + ERR_raise_data(ERR_LIB_CONF, CONF_R_UNKNOWN_MODULE_NAME, + "module=%s", name); } 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); if (ret <= 0) { - if (!(flags & CONF_MFLAGS_SILENT)) { - char rcode[DECIMAL_SIZE(ret) + 1]; - - ERR_raise(ERR_LIB_CONF, CONF_R_MODULE_INITIALIZATION_ERROR); - BIO_snprintf(rcode, sizeof(rcode), "%-8d", ret); - ERR_add_error_data(6, "module=", name, ", value=", value, - ", retcode=", rcode); - } + if (!(flags & CONF_MFLAGS_SILENT)) + ERR_raise_data(ERR_LIB_CONF, CONF_R_MODULE_INITIALIZATION_ERROR, + "module=%s, value=%s retcode=%-8d", + name, value, ret); } return ret; @@ -287,8 +284,7 @@ static CONF_MODULE *module_load_dso(const CONF *cnf, err: DSO_free(dso); - ERR_raise(ERR_LIB_CONF, errcode); - ERR_add_error_data(4, "module=", name, ", path=", path); + ERR_raise_data(ERR_LIB_CONF, errcode, "module=%s, path=%s", name, path); return NULL; } diff --git a/crypto/conf/conf_ssl.c b/crypto/conf/conf_ssl.c index 6512dda132..a4b35bab99 100644 --- a/crypto/conf/conf_ssl.c +++ b/crypto/conf/conf_ssl.c @@ -68,11 +68,12 @@ static int ssl_module_init(CONF_IMODULE *md, const CONF *cnf) ssl_conf_section = CONF_imodule_get_value(md); cmd_lists = NCONF_get_section(cnf, ssl_conf_section); if (sk_CONF_VALUE_num(cmd_lists) <= 0) { - if (cmd_lists == NULL) - ERR_raise(ERR_LIB_CONF, CONF_R_SSL_SECTION_NOT_FOUND); - else - ERR_raise(ERR_LIB_CONF, CONF_R_SSL_SECTION_EMPTY); - ERR_add_error_data(2, "section=", ssl_conf_section); + int rcode = + cmd_lists == NULL + ? CONF_R_SSL_SECTION_NOT_FOUND + : CONF_R_SSL_SECTION_EMPTY; + + ERR_raise_data(ERR_LIB_CONF, rcode, "section=%s", ssl_conf_section); goto err; } 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); if (sk_CONF_VALUE_num(cmds) <= 0) { - if (cmds == NULL) - ERR_raise(ERR_LIB_CONF, - CONF_R_SSL_COMMAND_SECTION_NOT_FOUND); - else - ERR_raise(ERR_LIB_CONF, - CONF_R_SSL_COMMAND_SECTION_EMPTY); - ERR_add_error_data(4, "name=", sect->name, ", value=", sect->value); + int rcode = + cmds == NULL + ? CONF_R_SSL_COMMAND_SECTION_NOT_FOUND + : CONF_R_SSL_COMMAND_SECTION_EMPTY; + + ERR_raise_data(ERR_LIB_CONF, rcode, + "name=%s, value=%s", sect->name, sect->value); goto err; } ssl_name->name = OPENSSL_strdup(sect->name); diff --git a/crypto/dso/dso_dl.c b/crypto/dso/dso_dl.c index 721fb14c83..36dcf1d73d 100644 --- a/crypto/dso/dso_dl.c +++ b/crypto/dso/dso_dl.c @@ -69,9 +69,13 @@ static int dl_load(DSO *dso) DYNAMIC_PATH), 0L); if (ptr == NULL) { char errbuf[160]; - ERR_raise(ERR_LIB_DSO, DSO_R_LOAD_FAILED); + 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; } 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) { char errbuf[160]; - ERR_raise(ERR_LIB_DSO, DSO_R_SYM_FAILURE); + 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 (DSO_FUNC_TYPE)sym; diff --git a/crypto/dso/dso_dlfcn.c b/crypto/dso/dso_dlfcn.c index 4137d7d9f8..76bc6055bc 100644 --- a/crypto/dso/dso_dlfcn.c +++ b/crypto/dso/dso_dlfcn.c @@ -115,8 +115,8 @@ static int dlfcn_load(DSO *dso) # endif ptr = dlopen(filename, flags); if (ptr == NULL) { - ERR_raise(ERR_LIB_DSO, DSO_R_LOAD_FAILED); - ERR_add_error_data(4, "filename(", filename, "): ", dlerror()); + ERR_raise_data(ERR_LIB_DSO, DSO_R_LOAD_FAILED, + "filename(%s): %s", filename, dlerror()); goto err; } /* @@ -185,8 +185,8 @@ static DSO_FUNC_TYPE dlfcn_bind_func(DSO *dso, const char *symname) } u.dlret = dlsym(ptr, symname); if (u.dlret == NULL) { - ERR_raise(ERR_LIB_DSO, DSO_R_SYM_FAILURE); - ERR_add_error_data(4, "symname(", symname, "): ", dlerror()); + ERR_raise_data(ERR_LIB_DSO, DSO_R_SYM_FAILURE, + "symname(%s): %s", symname, dlerror()); return NULL; } return u.sym; @@ -437,6 +437,7 @@ static int dlfcn_pathbyaddr(void *addr, char *path, int sz) return len; } + /* TODO: what error report does this attach to? */ ERR_add_error_data(2, "dlfcn_pathbyaddr(): ", dlerror()); # endif return -1; diff --git a/crypto/dso/dso_vms.c b/crypto/dso/dso_vms.c index 90b94992b4..03abcc0d73 100644 --- a/crypto/dso/dso_vms.c +++ b/crypto/dso/dso_vms.c @@ -336,17 +336,15 @@ void vms_bind_sym(DSO *dso, const char *symname, void **sym) else { errstring[length] = '\0'; - ERR_raise(ERR_LIB_DSO, DSO_R_SYM_FAILURE); if (ptr->imagename_dsc.dsc$w_length) - ERR_add_error_data(9, - "Symbol ", symname, - " in ", ptr->filename, - " (", ptr->imagename, ")", - ": ", errstring); + ERR_raise_data(ERR_LIB_DSO, DSO_R_SYM_FAILURE, + "Symbol %s in %s (%s): %s", + symname, ptr->filename, ptr->imagename, + errstring); else - ERR_add_error_data(6, - "Symbol ", symname, - " in ", ptr->filename, ": ", errstring); + ERR_raise_data(ERR_LIB_DSO, DSO_R_SYM_FAILURE, + "Symbol %s in %s: %s", + symname, ptr->filename, errstring); } return; } @@ -436,10 +434,9 @@ static char *vms_merger(DSO *dso, const char *filespec1, else { errstring[length] = '\0'; - ERR_raise(ERR_LIB_DSO, DSO_R_FAILURE); - ERR_add_error_data(7, - "filespec \"", filespec1, "\", ", - "defaults \"", filespec2, "\": ", errstring); + ERR_raise_data(ERR_LIB_DSO, DSO_R_FAILURE, + "filespec \"%s\", default \"%s\": %s", + filespec1, filespec2, errstring); } return NULL; } diff --git a/crypto/dso/dso_win32.c b/crypto/dso/dso_win32.c index 3b4d596220..4d3059d438 100644 --- a/crypto/dso/dso_win32.c +++ b/crypto/dso/dso_win32.c @@ -105,8 +105,8 @@ static int win32_load(DSO *dso) } h = LoadLibraryA(filename); if (h == NULL) { - ERR_raise(ERR_LIB_DSO, DSO_R_LOAD_FAILED); - ERR_add_error_data(3, "filename(", filename, ")"); + ERR_raise_data(ERR_LIB_DSO, DSO_R_LOAD_FAILED, + "filename(%s)", filename); goto err; } 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); if (sym.p == NULL) { - ERR_raise(ERR_LIB_DSO, DSO_R_SYM_FAILURE); - ERR_add_error_data(3, "symname(", symname, ")"); + ERR_raise_data(ERR_LIB_DSO, DSO_R_SYM_FAILURE, "symname(%s)", symname); return NULL; } return (DSO_FUNC_TYPE)sym.f; diff --git a/crypto/ec/ec_curve.c b/crypto/ec/ec_curve.c index 0c7597ad9f..051d3fe181 100644 --- a/crypto/ec/ec_curve.c +++ b/crypto/ec/ec_curve.c @@ -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 || (ret = ec_group_new_from_data(libctx, propq, *curve)) == NULL) { - ERR_raise(ERR_LIB_EC, EC_R_UNKNOWN_GROUP); #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 return NULL; } diff --git a/crypto/engine/eng_cnf.c b/crypto/engine/eng_cnf.c index 4a14400a04..14744bb7f5 100644 --- a/crypto/engine/eng_cnf.c +++ b/crypto/engine/eng_cnf.c @@ -133,12 +133,12 @@ static int int_engine_configure(const char *name, const char *value, const CONF ret = 1; err: if (ret != 1) { - ERR_raise(ERR_LIB_ENGINE, - ENGINE_R_ENGINE_CONFIGURATION_ERROR); - if (ecmd) - ERR_add_error_data(6, "section=", ecmd->section, - ", name=", ecmd->name, - ", value=", ecmd->value); + if (ecmd == NULL) + ERR_raise(ERR_LIB_ENGINE, ENGINE_R_ENGINE_CONFIGURATION_ERROR); + else + ERR_raise_data(ERR_LIB_ENGINE, ENGINE_R_ENGINE_CONFIGURATION_ERROR, + "section=%s, name=%s, value=%s", + ecmd->section, ecmd->name, ecmd->value); } ENGINE_free(e); return ret; diff --git a/crypto/engine/eng_fat.c b/crypto/engine/eng_fat.c index 7b971678fd..78537057b7 100644 --- a/crypto/engine/eng_fat.c +++ b/crypto/engine/eng_fat.c @@ -85,9 +85,8 @@ int ENGINE_set_default_string(ENGINE *e, const char *def_list) { unsigned int flags = 0; if (!CONF_parse_list(def_list, ',', 1, int_def_cb, &flags)) { - ERR_raise(ERR_LIB_ENGINE, - ENGINE_R_INVALID_STRING); - ERR_add_error_data(2, "str=", def_list); + ERR_raise_data(ERR_LIB_ENGINE, ENGINE_R_INVALID_STRING, + "str=%s", def_list); return 0; } return ENGINE_set_default(e, flags); diff --git a/crypto/engine/eng_list.c b/crypto/engine/eng_list.c index 3008384d3f..de3475fe22 100644 --- a/crypto/engine/eng_list.c +++ b/crypto/engine/eng_list.c @@ -335,8 +335,7 @@ ENGINE *ENGINE_by_id(const char *id) } notfound: ENGINE_free(iterator); - ERR_raise(ERR_LIB_ENGINE, ENGINE_R_NO_SUCH_ENGINE); - ERR_add_error_data(2, "id=", id); + ERR_raise_data(ERR_LIB_ENGINE, ENGINE_R_NO_SUCH_ENGINE, "id=%s", id); return NULL; /* EEK! Experimental code ends */ } diff --git a/crypto/evp/evp_cnf.c b/crypto/evp/evp_cnf.c index 7da71dddb3..7c2301d26c 100644 --- a/crypto/evp/evp_cnf.c +++ b/crypto/evp/evp_cnf.c @@ -56,9 +56,8 @@ static int alg_module_init(CONF_IMODULE *md, const CONF *cnf) return 0; } } else { - ERR_raise(ERR_LIB_EVP, EVP_R_UNKNOWN_OPTION); - ERR_add_error_data(4, "name=", oval->name, - ", value=", oval->value); + ERR_raise_data(ERR_LIB_EVP, EVP_R_UNKNOWN_OPTION, + "name=%s, value=%s", oval->name, oval->value); return 0; } diff --git a/crypto/evp/evp_pbe.c b/crypto/evp/evp_pbe.c index e6bd33259d..d9d51e0d78 100644 --- a/crypto/evp/evp_pbe.c +++ b/crypto/evp/evp_pbe.c @@ -94,12 +94,12 @@ int EVP_PBE_CipherInit(ASN1_OBJECT *pbe_obj, const char *pass, int passlen, &cipher_nid, &md_nid, &keygen)) { char obj_tmp[80]; - ERR_raise(ERR_LIB_EVP, EVP_R_UNKNOWN_PBE_ALGORITHM); if (pbe_obj == NULL) OPENSSL_strlcpy(obj_tmp, "NULL", sizeof(obj_tmp)); else 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; } @@ -113,8 +113,8 @@ int EVP_PBE_CipherInit(ASN1_OBJECT *pbe_obj, const char *pass, int passlen, else { cipher = EVP_get_cipherbynid(cipher_nid); if (!cipher) { - ERR_raise(ERR_LIB_EVP, EVP_R_UNKNOWN_CIPHER); - ERR_add_error_data(1, OBJ_nid2sn(cipher_nid)); + ERR_raise_data(ERR_LIB_EVP, EVP_R_UNKNOWN_CIPHER, + OBJ_nid2sn(cipher_nid)); return 0; } } diff --git a/crypto/evp/evp_pkey.c b/crypto/evp/evp_pkey.c index c92605d50a..b049420d0b 100644 --- a/crypto/evp/evp_pkey.c +++ b/crypto/evp/evp_pkey.c @@ -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))) { - ERR_raise(ERR_LIB_EVP, EVP_R_UNSUPPORTED_PRIVATE_KEY_ALGORITHM); 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; } diff --git a/crypto/http/http_client.c b/crypto/http/http_client.c index ef23b889aa..d8a6bdec31 100644 --- a/crypto/http/http_client.c +++ b/crypto/http/http_client.c @@ -383,41 +383,26 @@ static int parse_http_line1(char *line) return retcode; default: if (retcode < 400) - ERR_raise(ERR_LIB_HTTP, HTTP_R_STATUS_CODE_UNSUPPORTED); + retcode = HTTP_R_STATUS_CODE_UNSUPPORTED; else - ERR_raise(ERR_LIB_HTTP, HTTP_R_RECEIVED_ERROR); + retcode = HTTP_R_RECEIVED_ERROR; if (*reason == '\0') - ERR_add_error_data(2, "Code=", code); + ERR_raise_data(ERR_LIB_HTTP, retcode, "Code=%s", code); 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; } } static int check_set_resp_len(OSSL_HTTP_REQ_CTX *rctx, unsigned long len) { - const char *tag = NULL; - unsigned long val = 0; - - if (len > rctx->max_resp_len) { - ERR_raise(ERR_LIB_HTTP, HTTP_R_MAX_RESP_LEN_EXCEEDED); - tag = ",max="; - 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; - } + if (len > rctx->max_resp_len) + ERR_raise_data(ERR_LIB_HTTP, HTTP_R_MAX_RESP_LEN_EXCEEDED, + "length=%lu, max=%lu", len, rctx->max_resp_len); + if (rctx->resp_len != 0 && rctx->resp_len != len) + ERR_raise_data(ERR_LIB_HTTP, HTTP_R_INCONSISTENT_CONTENT_LENGTH, + "length=%lu, before=%lu", len, rctx->resp_len); rctx->resp_len = len; return 1; } @@ -585,9 +570,9 @@ int OSSL_HTTP_REQ_CTX_nbio(OSSL_HTTP_REQ_CTX *rctx) if (rctx->expected_ct != NULL && strcasecmp(key, "Content-Type") == 0) { if (strcasecmp(rctx->expected_ct, value) != 0) { - ERR_raise(ERR_LIB_HTTP, HTTP_R_UNEXPECTED_CONTENT_TYPE); - ERR_add_error_data(4, "expected=", rctx->expected_ct, - ",actual=", value); + ERR_raise_data(ERR_LIB_HTTP, HTTP_R_UNEXPECTED_CONTENT_TYPE, + "expected=%s, actual=%s", + rctx->expected_ct, value); return 0; } 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) { resp_len = strtoul(value, &line_end, 10); if (line_end == value || *line_end != '\0') { - ERR_raise(ERR_LIB_HTTP, HTTP_R_ERROR_PARSING_CONTENT_LENGTH); - ERR_add_error_data(2, "input=", value); + ERR_raise_data(ERR_LIB_HTTP, + HTTP_R_ERROR_PARSING_CONTENT_LENGTH, + "input=%s", value); return 0; } 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; if (rctx->expected_ct != NULL) { - ERR_raise(ERR_LIB_HTTP, HTTP_R_MISSING_CONTENT_TYPE); - ERR_add_error_data(2, "expected=", rctx->expected_ct); + ERR_raise_data(ERR_LIB_HTTP, HTTP_R_MISSING_CONTENT_TYPE, + "expected=%s", rctx->expected_ct); return 0; } 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])) read_len--; mbuf[read_len] = '\0'; - ERR_raise(ERR_LIB_HTTP, HTTP_R_CONNECT_FAILURE); - ERR_add_error_data(2, "Reason=", mbufp); + ERR_raise_data(ERR_LIB_HTTP, HTTP_R_CONNECT_FAILURE, + "Reason=%s", mbufp); BIO_printf(bio_err, "%s: HTTP CONNECT failed, Reason=%s\n", prog, mbufp); goto end; diff --git a/crypto/ocsp/ocsp_vfy.c b/crypto/ocsp/ocsp_vfy.c index 1b8b3e3060..f49f651007 100644 --- a/crypto/ocsp/ocsp_vfy.c +++ b/crypto/ocsp/ocsp_vfy.c @@ -60,9 +60,8 @@ static int ocsp_verify_signer(X509 *signer, int response, ret = X509_verify_cert(ctx); if (ret <= 0) { ret = X509_STORE_CTX_get_error(ctx); - ERR_raise(ERR_LIB_OCSP, OCSP_R_CERTIFICATE_VERIFY_ERROR); - ERR_add_error_data(2, "Verify error:", - X509_verify_cert_error_string(ret)); + ERR_raise_data(ERR_LIB_OCSP, OCSP_R_CERTIFICATE_VERIFY_ERROR, + "Verify error: %s", X509_verify_cert_error_string(ret)); goto end; } if (chain != NULL) diff --git a/crypto/pkcs7/pk7_smime.c b/crypto/pkcs7/pk7_smime.c index f3e6ac1ce9..770534d9f6 100644 --- a/crypto/pkcs7/pk7_smime.c +++ b/crypto/pkcs7/pk7_smime.c @@ -290,9 +290,9 @@ int PKCS7_verify(PKCS7 *p7, STACK_OF(X509) *certs, X509_STORE *store, j = X509_STORE_CTX_get_error(cert_ctx); X509_STORE_CTX_cleanup(cert_ctx); if (i <= 0) { - ERR_raise(ERR_LIB_PKCS7, PKCS7_R_CERTIFICATE_VERIFY_ERROR); - ERR_add_error_data(2, "Verify error:", - X509_verify_cert_error_string(j)); + ERR_raise_data(ERR_LIB_PKCS7, PKCS7_R_CERTIFICATE_VERIFY_ERROR, + "Verify error: %s", + X509_verify_cert_error_string(j)); goto err; } /* Check for revocation status here */ diff --git a/crypto/provider_conf.c b/crypto/provider_conf.c index 22b4116f88..709e7a1c51 100644 --- a/crypto/provider_conf.c +++ b/crypto/provider_conf.c @@ -87,8 +87,8 @@ static int provider_conf_load(OSSL_LIB_CTX *libctx, const char *name, ecmds = NCONF_get_section(cnf, value); if (!ecmds) { - ERR_raise(ERR_LIB_CRYPTO, CRYPTO_R_PROVIDER_SECTION_ERROR); - ERR_add_error_data(3, "section=", value, " not found"); + ERR_raise_data(ERR_LIB_CRYPTO, CRYPTO_R_PROVIDER_SECTION_ERROR, + "section=%s not found", value); return 0; } diff --git a/crypto/rand/rand_lib.c b/crypto/rand/rand_lib.c index fdce6711ed..211f4f3f51 100644 --- a/crypto/rand/rand_lib.c +++ b/crypto/rand/rand_lib.c @@ -645,8 +645,9 @@ static int random_conf_init(CONF_IMODULE *md, const CONF *cnf) if (!random_set_string(&dgbl->rng_propq, cval->value)) return 0; } else { - ERR_raise(ERR_LIB_CRYPTO, CRYPTO_R_UNKNOWN_NAME_IN_RANDOM_SECTION); - ERR_add_error_data(4, "name=", cval->name, ", value=", cval->value); + ERR_raise_data(ERR_LIB_CRYPTO, + CRYPTO_R_UNKNOWN_NAME_IN_RANDOM_SECTION, + "name=%s, value=%s", cval->name, cval->value); r = 0; } } diff --git a/crypto/rand/randfile.c b/crypto/rand/randfile.c index b104895e3a..655dc71b06 100644 --- a/crypto/rand/randfile.c +++ b/crypto/rand/randfile.c @@ -94,15 +94,15 @@ int RAND_load_file(const char *file, long bytes) return 0; if ((in = openssl_fopen(file, "rb")) == NULL) { - ERR_raise(ERR_LIB_RAND, RAND_R_CANNOT_OPEN_FILE); - ERR_add_error_data(2, "Filename=", file); + ERR_raise_data(ERR_LIB_RAND, RAND_R_CANNOT_OPEN_FILE, + "Filename=%s", file); return -1; } #ifndef OPENSSL_NO_POSIX_IO if (fstat(fileno(in), &sb) < 0) { - ERR_raise(ERR_LIB_RAND, RAND_R_INTERNAL_ERROR); - ERR_add_error_data(2, "Filename=", file); + ERR_raise_data(ERR_LIB_RAND, RAND_R_INTERNAL_ERROR, + "Filename=%s", file); fclose(in); return -1; } @@ -162,8 +162,7 @@ int RAND_load_file(const char *file, long bytes) OPENSSL_cleanse(buf, sizeof(buf)); fclose(in); if (!RAND_status()) { - ERR_raise(ERR_LIB_RAND, RAND_R_RESEED_ERROR); - ERR_add_error_data(2, "Filename=", file); + ERR_raise_data(ERR_LIB_RAND, RAND_R_RESEED_ERROR, "Filename=%s", file); return -1; } @@ -179,8 +178,8 @@ int RAND_write_file(const char *file) struct stat sb; if (stat(file, &sb) >= 0 && !S_ISREG(sb.st_mode)) { - ERR_raise(ERR_LIB_RAND, RAND_R_NOT_A_REGULAR_FILE); - ERR_add_error_data(2, "Filename=", file); + ERR_raise_data(ERR_LIB_RAND, RAND_R_NOT_A_REGULAR_FILE, + "Filename=%s", file); return -1; } #endif @@ -229,8 +228,8 @@ int RAND_write_file(const char *file) if (out == NULL) out = openssl_fopen(file, "wb"); if (out == NULL) { - ERR_raise(ERR_LIB_RAND, RAND_R_CANNOT_OPEN_FILE); - ERR_add_error_data(2, "Filename=", file); + ERR_raise_data(ERR_LIB_RAND, RAND_R_CANNOT_OPEN_FILE, + "Filename=%s", file); return -1; } diff --git a/crypto/ts/ts_conf.c b/crypto/ts/ts_conf.c index 6fb8e49661..fd2ad90754 100644 --- a/crypto/ts/ts_conf.c +++ b/crypto/ts/ts_conf.c @@ -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) { - ERR_raise(ERR_LIB_TS, TS_R_VAR_LOOKUP_FAILURE); - ERR_add_error_data(3, name, "::", tag); + ERR_raise_data(ERR_LIB_TS, TS_R_VAR_LOOKUP_FAILURE, "%s::%s", name, tag); } static void ts_CONF_invalid(const char *name, const char *tag) { - ERR_raise(ERR_LIB_TS, TS_R_VAR_BAD_VALUE); - ERR_add_error_data(3, name, "::", tag); + ERR_raise_data(ERR_LIB_TS, TS_R_VAR_BAD_VALUE, "%s::%s", name, tag); } 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; err: - if (!ret) { - ERR_raise(ERR_LIB_TS, TS_R_COULD_NOT_SET_ENGINE); - ERR_add_error_data(2, "engine:", name); - } + if (!ret) + ERR_raise_data(ERR_LIB_TS, TS_R_COULD_NOT_SET_ENGINE, + "engine:%s", name); ENGINE_free(e); return ret; } diff --git a/crypto/ts/ts_rsp_verify.c b/crypto/ts/ts_rsp_verify.c index b0bcba7917..8e097a3336 100644 --- a/crypto/ts/ts_rsp_verify.c +++ b/crypto/ts/ts_rsp_verify.c @@ -178,9 +178,8 @@ static int ts_verify_cert(X509_STORE *store, STACK_OF(X509) *untrusted, i = X509_verify_cert(cert_ctx); if (i <= 0) { int j = X509_STORE_CTX_get_error(cert_ctx); - ERR_raise(ERR_LIB_TS, TS_R_CERTIFICATE_VERIFY_ERROR); - ERR_add_error_data(2, "Verify error:", - X509_verify_cert_error_string(j)); + ERR_raise_data(ERR_LIB_TS, TS_R_CERTIFICATE_VERIFY_ERROR, + "Verify error:%s", X509_verify_cert_error_string(j)); goto err; } *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') strcpy(failure_text, "unspecified"); - ERR_raise(ERR_LIB_TS, TS_R_NO_TIME_STAMP_TOKEN); - ERR_add_error_data(6, - "status code: ", status_text, - ", status text: ", embedded_status_text ? - embedded_status_text : "unspecified", - ", failure codes: ", failure_text); + ERR_raise_data(ERR_LIB_TS, TS_R_NO_TIME_STAMP_TOKEN, + "status code: %s, status text: %s, failure codes: %s", + status_text, + embedded_status_text ? embedded_status_text : "unspecified", + failure_text); OPENSSL_free(embedded_status_text); return 0; diff --git a/crypto/ui/ui_lib.c b/crypto/ui/ui_lib.c index 4c74546612..fd03dc6cd0 100644 --- a/crypto/ui/ui_lib.c +++ b/crypto/ui/ui_lib.c @@ -540,10 +540,8 @@ int UI_process(UI *ui) ok = -1; } - if (ok == -1) { - ERR_raise(ERR_LIB_UI, UI_R_PROCESSING_ERROR); - ERR_add_error_data(2, "while ", state); - } + if (ok == -1) + ERR_raise_data(ERR_LIB_UI, UI_R_PROCESSING_ERROR, "while %s", state); return ok; } @@ -881,29 +879,21 @@ int UI_set_result_ex(UI *ui, UI_STRING *uis, const char *result, int len) switch (uis->type) { case UIT_PROMPT: case UIT_VERIFY: - { - char number1[DECIMAL_SIZE(uis->_.string_data.result_minsize) + 1]; - char number2[DECIMAL_SIZE(uis->_.string_data.result_maxsize) + 1]; - - BIO_snprintf(number1, sizeof(number1), "%d", - uis->_.string_data.result_minsize); - BIO_snprintf(number2, sizeof(number2), "%d", - uis->_.string_data.result_maxsize); - - if (len < uis->_.string_data.result_minsize) { - ui->flags |= UI_FLAG_REDOABLE; - ERR_raise(ERR_LIB_UI, UI_R_RESULT_TOO_SMALL); - ERR_add_error_data(5, "You must type in ", - number1, " to ", number2, " characters"); - 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 (len < uis->_.string_data.result_minsize) { + ui->flags |= UI_FLAG_REDOABLE; + ERR_raise_data(ERR_LIB_UI, UI_R_RESULT_TOO_SMALL, + "You must type in %d to %d characters", + uis->_.string_data.result_minsize, + uis->_.string_data.result_maxsize); + return -1; + } + if (len > uis->_.string_data.result_maxsize) { + ui->flags |= UI_FLAG_REDOABLE; + ERR_raise_data(ERR_LIB_UI, UI_R_RESULT_TOO_LARGE, + "You must type in %d to %d characters", + uis->_.string_data.result_minsize, + uis->_.string_data.result_maxsize); + return -1; } if (uis->result_buf == NULL) { diff --git a/crypto/ui/ui_openssl.c b/crypto/ui/ui_openssl.c index dc7e9cc56a..0a38658c72 100644 --- a/crypto/ui/ui_openssl.c +++ b/crypto/ui/ui_openssl.c @@ -451,15 +451,12 @@ static int open_console(UI *ui) * which seems appropriate. */ if (errno == ENODEV) - is_a_tty = 0; + is_a_tty = 0; else # endif { - char tmp_num[10]; - BIO_snprintf(tmp_num, sizeof(tmp_num) - 1, "%d", errno); - ERR_raise(ERR_LIB_UI, UI_R_UNKNOWN_TTYGET_ERRNO_VALUE); - ERR_add_error_data(2, "errno=", tmp_num); - + ERR_raise_data(ERR_LIB_UI, UI_R_UNKNOWN_TTYGET_ERRNO_VALUE, + "errno=%d", errno); return 0; } } @@ -469,11 +466,8 @@ static int open_console(UI *ui) /* if there isn't a TT device, something is very wrong */ if (status != SS$_NORMAL) { - char tmp_num[12]; - - 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); + ERR_raise_data(ERR_LIB_UI, UI_R_SYSASSIGN_ERROR, + "status=%%X%08X", status); 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, 0, 0, 0, 0); if ((status != SS$_NORMAL) || (iosb.iosb$w_value != SS$_NORMAL)) { - char tmp_num[2][12]; - - BIO_snprintf(tmp_num[0], sizeof(tmp_num[0]) - 1, "%%X%08X", - 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]); + ERR_raise_data(ERR_LIB_UI, UI_R_SYSQIOW_ERROR, + "status=%%X%08X, iosb.iosb$w_value=%%X%08X", + status, iosb.iosb$w_value); 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, 0, 0, 0, 0); if ((status != SS$_NORMAL) || (iosb.iosb$w_value != SS$_NORMAL)) { - char tmp_num[2][12]; - - BIO_snprintf(tmp_num[0], sizeof(tmp_num[0]) - 1, "%%X%08X", - 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]); + ERR_raise_data(ERR_LIB_UI, UI_R_SYSQIOW_ERROR, + "status=%%X%08X, iosb.iosb$w_value=%%X%08X", + status, iosb.iosb$w_value); return 0; } } @@ -575,11 +557,8 @@ static int close_console(UI *ui) # ifdef OPENSSL_SYS_VMS status = sys$dassgn(channel); if (status != SS$_NORMAL) { - char tmp_num[12]; - - 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); + ERR_raise_data(ERR_LIB_UI, UI_R_SYSDASSGN_ERROR, + "status=%%X%08X", status); return 0; } # endif diff --git a/crypto/x509/v3_addr.c b/crypto/x509/v3_addr.c index ae4978409b..b7dd889087 100644 --- a/crypto/x509/v3_addr.c +++ b/crypto/x509/v3_addr.c @@ -919,9 +919,8 @@ static void *v2i_IPAddrBlocks(const struct v3_ext_method *method, afi = IANA_AFI_IPV6; safi = &safi_; } else { - ERR_raise(ERR_LIB_X509V3, - X509V3_R_EXTENSION_NAME_ERROR); - ERR_add_error_data(1, val->name); + ERR_raise_data(ERR_LIB_X509V3, X509V3_R_EXTENSION_NAME_ERROR, + "%s", val->name); goto err; } diff --git a/crypto/x509/v3_akey.c b/crypto/x509/v3_akey.c index 529dddf664..21ea1e4c75 100644 --- a/crypto/x509/v3_akey.c +++ b/crypto/x509/v3_akey.c @@ -100,8 +100,8 @@ static AUTHORITY_KEYID *v2i_AUTHORITY_KEYID(X509V3_EXT_METHOD *method, if (cnf->value && strcmp(cnf->value, "always") == 0) issuer = 2; } else { - ERR_raise(ERR_LIB_X509V3, X509V3_R_UNKNOWN_OPTION); - ERR_add_error_data(2, "name=", cnf->name); + ERR_raise_data(ERR_LIB_X509V3, X509V3_R_UNKNOWN_OPTION, + "name=%s", cnf->name); return NULL; } } diff --git a/crypto/x509/v3_alt.c b/crypto/x509/v3_alt.c index 9d40304037..2344c554fa 100644 --- a/crypto/x509/v3_alt.c +++ b/crypto/x509/v3_alt.c @@ -524,8 +524,8 @@ GENERAL_NAME *a2i_GENERAL_NAME(GENERAL_NAME *out, { ASN1_OBJECT *obj; if ((obj = OBJ_txt2obj(value, 0)) == NULL) { - ERR_raise(ERR_LIB_X509V3, X509V3_R_BAD_OBJECT); - ERR_add_error_data(2, "value=", value); + ERR_raise_data(ERR_LIB_X509V3, X509V3_R_BAD_OBJECT, + "value=%s", value); goto err; } gen->d.rid = obj; @@ -538,8 +538,8 @@ GENERAL_NAME *a2i_GENERAL_NAME(GENERAL_NAME *out, else gen->d.ip = a2i_IPADDRESS(value); if (gen->d.ip == NULL) { - ERR_raise(ERR_LIB_X509V3, X509V3_R_BAD_IP_ADDRESS); - ERR_add_error_data(2, "value=", value); + ERR_raise_data(ERR_LIB_X509V3, X509V3_R_BAD_IP_ADDRESS, + "value=%s", value); goto err; } break; @@ -612,8 +612,8 @@ GENERAL_NAME *v2i_GENERAL_NAME_ex(GENERAL_NAME *out, else if (!v3_name_cmp(name, "otherName")) type = GEN_OTHERNAME; else { - ERR_raise(ERR_LIB_X509V3, X509V3_R_UNSUPPORTED_OPTION); - ERR_add_error_data(2, "name=", name); + ERR_raise_data(ERR_LIB_X509V3, X509V3_R_UNSUPPORTED_OPTION, + "name=%s", name); return NULL; } @@ -658,8 +658,8 @@ static int do_dirname(GENERAL_NAME *gen, const char *value, X509V3_CTX *ctx) goto err; sk = X509V3_get_section(ctx, value); if (!sk) { - ERR_raise(ERR_LIB_X509V3, X509V3_R_SECTION_NOT_FOUND); - ERR_add_error_data(2, "section=", value); + ERR_raise_data(ERR_LIB_X509V3, X509V3_R_SECTION_NOT_FOUND, + "section=%s", value); goto err; } /* FIXME: should allow other character types... */ diff --git a/crypto/x509/v3_bitst.c b/crypto/x509/v3_bitst.c index 68369fb3ef..0caa338ff0 100644 --- a/crypto/x509/v3_bitst.c +++ b/crypto/x509/v3_bitst.c @@ -81,9 +81,8 @@ ASN1_BIT_STRING *v2i_ASN1_BIT_STRING(X509V3_EXT_METHOD *method, } } if (!bnam->lname) { - ERR_raise(ERR_LIB_X509V3, - X509V3_R_UNKNOWN_BIT_STRING_ARGUMENT); - ERR_add_error_data(1, val->name); + ERR_raise_data(ERR_LIB_X509V3, X509V3_R_UNKNOWN_BIT_STRING_ARGUMENT, + "%s", val->name); ASN1_BIT_STRING_free(bs); return NULL; } diff --git a/crypto/x509/v3_conf.c b/crypto/x509/v3_conf.c index 984f118075..47b626659c 100644 --- a/crypto/x509/v3_conf.c +++ b/crypto/x509/v3_conf.c @@ -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); ret = do_ext_nconf(conf, ctx, OBJ_sn2nid(name), crit, value); if (!ret) { - ERR_raise(ERR_LIB_X509V3, X509V3_R_ERROR_IN_EXTENSION); if (section != NULL) - ERR_add_error_data(6, "section=", section, - ", name=", name, ", value=", value); + ERR_raise_data(ERR_LIB_X509V3, X509V3_R_ERROR_IN_EXTENSION, + "section=%s, name=%s, value=%s", + section, name, value); 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; } @@ -98,10 +99,8 @@ static X509_EXTENSION *do_ext_nconf(CONF *conf, X509V3_CTX *ctx, int ext_nid, else nval = X509V3_parse_list(value); if (nval == NULL || sk_CONF_VALUE_num(nval) <= 0) { - ERR_raise(ERR_LIB_X509V3, - X509V3_R_INVALID_EXTENSION_STRING); - ERR_add_error_data(4, "name=", OBJ_nid2sn(ext_nid), ",section=", - value); + ERR_raise_data(ERR_LIB_X509V3, X509V3_R_INVALID_EXTENSION_STRING, + "name=%s,section=%s", OBJ_nid2sn(ext_nid), value); if (*value != '@') sk_CONF_VALUE_pop_free(nval, X509V3_conf_free); 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) return NULL; } else { - ERR_raise(ERR_LIB_X509V3, - X509V3_R_EXTENSION_SETTING_NOT_SUPPORTED); - ERR_add_error_data(2, "name=", OBJ_nid2sn(ext_nid)); + ERR_raise_data(ERR_LIB_X509V3, X509V3_R_EXTENSION_SETTING_NOT_SUPPORTED, + "name=%s", OBJ_nid2sn(ext_nid)); return NULL; } @@ -242,9 +240,8 @@ static X509_EXTENSION *v3_generic_extension(const char *ext, const char *value, X509_EXTENSION *extension = NULL; if ((obj = OBJ_txt2obj(ext, 0)) == NULL) { - ERR_raise(ERR_LIB_X509V3, - X509V3_R_EXTENSION_NAME_ERROR); - ERR_add_error_data(2, "name=", ext); + ERR_raise_data(ERR_LIB_X509V3, X509V3_R_EXTENSION_NAME_ERROR, + "name=%s", ext); 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); if (ext_der == NULL) { - ERR_raise(ERR_LIB_X509V3, - X509V3_R_EXTENSION_VALUE_ERROR); - ERR_add_error_data(2, "value=", value); + ERR_raise_data(ERR_LIB_X509V3, X509V3_R_EXTENSION_VALUE_ERROR, + "value=%s", value); goto err; } diff --git a/crypto/x509/v3_cpols.c b/crypto/x509/v3_cpols.c index 7d27c1f225..55aa5cac05 100644 --- a/crypto/x509/v3_cpols.c +++ b/crypto/x509/v3_cpols.c @@ -126,8 +126,8 @@ static STACK_OF(POLICYINFO) *r2i_certpol(X509V3_EXT_METHOD *method, polsect = X509V3_get_section(ctx, pstr + 1); if (polsect == NULL) { - ERR_raise(ERR_LIB_X509V3, X509V3_R_INVALID_SECTION); - ERR_add_error_data(1, cnf->name); + ERR_raise_data(ERR_LIB_X509V3, X509V3_R_INVALID_SECTION, + "%s", cnf->name); goto err; } pol = policy_section(ctx, polsect, ia5org); @@ -136,9 +136,9 @@ static STACK_OF(POLICYINFO) *r2i_certpol(X509V3_EXT_METHOD *method, goto err; } else { if ((pobj = OBJ_txt2obj(cnf->name, 0)) == NULL) { - ERR_raise(ERR_LIB_X509V3, - X509V3_R_INVALID_OBJECT_IDENTIFIER); - ERR_add_error_data(1, cnf->name); + ERR_raise_data(ERR_LIB_X509V3, + X509V3_R_INVALID_OBJECT_IDENTIFIER, + "%s", cnf->name); goto err; } pol = POLICYINFO_new(); diff --git a/crypto/x509/v3_extku.c b/crypto/x509/v3_extku.c index 9aabfe1656..753733323e 100644 --- a/crypto/x509/v3_extku.c +++ b/crypto/x509/v3_extku.c @@ -92,9 +92,8 @@ static void *v2i_EXTENDED_KEY_USAGE(const X509V3_EXT_METHOD *method, extval = val->name; if ((objtmp = OBJ_txt2obj(extval, 0)) == NULL) { sk_ASN1_OBJECT_pop_free(extku, ASN1_OBJECT_free); - ERR_raise(ERR_LIB_X509V3, - X509V3_R_INVALID_OBJECT_IDENTIFIER); - ERR_add_error_data(1, extval); + ERR_raise_data(ERR_LIB_X509V3, X509V3_R_INVALID_OBJECT_IDENTIFIER, + "%s", extval); return NULL; } sk_ASN1_OBJECT_push(extku, objtmp); /* no failure as it was reserved */ diff --git a/crypto/x509/v3_info.c b/crypto/x509/v3_info.c index 594ee3aa23..003f3ce172 100644 --- a/crypto/x509/v3_info.c +++ b/crypto/x509/v3_info.c @@ -106,9 +106,9 @@ static AUTHORITY_INFO_ACCESS *v2i_AUTHORITY_INFO_ACCESS(X509V3_EXT_METHOD AUTHORITY_INFO_ACCESS *ainfo = NULL; CONF_VALUE *cnf, ctmp; ACCESS_DESCRIPTION *acc; - int i, objlen; + int i; const int num = sk_CONF_VALUE_num(nval); - char *objtmp, *ptmp; + char *ptmp; if ((ainfo = sk_ACCESS_DESCRIPTION_new_reserve(NULL, num)) == NULL) { 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); goto err; } - objlen = ptmp - cnf->name; ctmp.name = ptmp + 1; ctmp.value = cnf->value; if (!v2i_GENERAL_NAME_ex(acc->location, method, ctx, &ctmp, 0)) goto err; - if ((objtmp = OPENSSL_strndup(cnf->name, objlen)) == NULL) { - ERR_raise(ERR_LIB_X509V3, - ERR_R_MALLOC_FAILURE); - goto err; - } - acc->method = OBJ_txt2obj(objtmp, 0); + acc->method = OBJ_txt2obj(cnf->value, 0); if (!acc->method) { - ERR_raise(ERR_LIB_X509V3, - X509V3_R_BAD_OBJECT); - ERR_add_error_data(2, "value=", objtmp); - OPENSSL_free(objtmp); + ERR_raise_data(ERR_LIB_X509V3, X509V3_R_BAD_OBJECT, + "value=%s", cnf->value); goto err; } - OPENSSL_free(objtmp); - } return ainfo; err: diff --git a/crypto/x509/v3_pcons.c b/crypto/x509/v3_pcons.c index 72628b4695..a8e8ab299f 100644 --- a/crypto/x509/v3_pcons.c +++ b/crypto/x509/v3_pcons.c @@ -73,8 +73,8 @@ static void *v2i_POLICY_CONSTRAINTS(const X509V3_EXT_METHOD *method, if (!X509V3_get_value_int(val, &pcons->inhibitPolicyMapping)) goto err; } else { - ERR_raise(ERR_LIB_X509V3, X509V3_R_INVALID_NAME); - ERR_add_error_data(1, val->name); + ERR_raise_data(ERR_LIB_X509V3, X509V3_R_INVALID_NAME, + "%s", val->name); goto err; } } diff --git a/crypto/x509/v3_pmaps.c b/crypto/x509/v3_pmaps.c index 7350b1f437..0a76b2f38d 100644 --- a/crypto/x509/v3_pmaps.c +++ b/crypto/x509/v3_pmaps.c @@ -80,17 +80,15 @@ static void *v2i_POLICY_MAPPINGS(const X509V3_EXT_METHOD *method, for (i = 0; i < num; i++) { val = sk_CONF_VALUE_value(nval, i); if (!val->value || !val->name) { - ERR_raise(ERR_LIB_X509V3, - X509V3_R_INVALID_OBJECT_IDENTIFIER); - ERR_add_error_data(1, val->name); + ERR_raise_data(ERR_LIB_X509V3, X509V3_R_INVALID_OBJECT_IDENTIFIER, + "%s", val->name); goto err; } obj1 = OBJ_txt2obj(val->name, 0); obj2 = OBJ_txt2obj(val->value, 0); if (!obj1 || !obj2) { - ERR_raise(ERR_LIB_X509V3, - X509V3_R_INVALID_OBJECT_IDENTIFIER); - ERR_add_error_data(1, val->name); + ERR_raise_data(ERR_LIB_X509V3, X509V3_R_INVALID_OBJECT_IDENTIFIER, + "%s", val->name); goto err; } pmap = POLICY_MAPPING_new(); diff --git a/crypto/x509/x509_att.c b/crypto/x509/x509_att.c index ad74768148..6a949f190e 100644 --- a/crypto/x509/x509_att.c +++ b/crypto/x509/x509_att.c @@ -222,9 +222,8 @@ X509_ATTRIBUTE *X509_ATTRIBUTE_create_by_txt(X509_ATTRIBUTE **attr, obj = OBJ_txt2obj(atrname, 0); if (obj == NULL) { - ERR_raise(ERR_LIB_X509, - X509_R_INVALID_FIELD_NAME); - ERR_add_error_data(2, "name=", atrname); + ERR_raise_data(ERR_LIB_X509, X509_R_INVALID_FIELD_NAME, + "name=%s", atrname); return NULL; } nattr = X509_ATTRIBUTE_create_by_OBJ(attr, obj, type, bytes, len); diff --git a/crypto/x509/x509name.c b/crypto/x509/x509name.c index a919a61250..690e2799ff 100644 --- a/crypto/x509/x509name.c +++ b/crypto/x509/x509name.c @@ -246,9 +246,8 @@ X509_NAME_ENTRY *X509_NAME_ENTRY_create_by_txt(X509_NAME_ENTRY **ne, obj = OBJ_txt2obj(field, 0); if (obj == NULL) { - ERR_raise(ERR_LIB_X509, - X509_R_INVALID_FIELD_NAME); - ERR_add_error_data(2, "name=", field); + ERR_raise_data(ERR_LIB_X509, X509_R_INVALID_FIELD_NAME, + "name=%s", field); return NULL; } nentry = X509_NAME_ENTRY_create_by_OBJ(ne, obj, type, bytes, len); |