CRYPTO: refactor ERR_raise()+ERR_add_error_data() to ERR_raise_data()
authorRichard Levitte <levitte@openssl.org>
Wed, 4 Nov 2020 15:14:00 +0000 (16:14 +0100)
committerRichard Levitte <levitte@openssl.org>
Fri, 13 Nov 2020 08:35:31 +0000 (09:35 +0100)
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:
apps/lib/apps.c
crypto/asn1/a_mbstr.c
crypto/asn1/asn1_gen.c
crypto/asn1/asn_mime.c
crypto/asn1/asn_mstbl.c
crypto/bio/b_addr.c
crypto/bio/bss_acpt.c
crypto/bio/bss_conn.c
crypto/bio/bss_dgram.c
crypto/cmp/cmp_client.c
crypto/cmp/cmp_msg.c
crypto/cmp/cmp_status.c
crypto/cms/cms_smime.c
crypto/comp/c_zlib.c
crypto/conf/conf_def.c
crypto/conf/conf_lib.c
crypto/conf/conf_mod.c
crypto/conf/conf_ssl.c
crypto/dso/dso_dl.c
crypto/dso/dso_dlfcn.c
crypto/dso/dso_vms.c
crypto/dso/dso_win32.c
crypto/ec/ec_curve.c
crypto/engine/eng_cnf.c
crypto/engine/eng_fat.c
crypto/engine/eng_list.c
crypto/evp/evp_cnf.c
crypto/evp/evp_pbe.c
crypto/evp/evp_pkey.c
crypto/http/http_client.c
crypto/ocsp/ocsp_vfy.c
crypto/pkcs7/pk7_smime.c
crypto/provider_conf.c
crypto/rand/rand_lib.c
crypto/rand/randfile.c
crypto/ts/ts_conf.c
crypto/ts/ts_rsp_verify.c
crypto/ui/ui_lib.c
crypto/ui/ui_openssl.c
crypto/x509/v3_addr.c
crypto/x509/v3_akey.c
crypto/x509/v3_alt.c
crypto/x509/v3_bitst.c
crypto/x509/v3_conf.c
crypto/x509/v3_cpols.c
crypto/x509/v3_extku.c
crypto/x509/v3_info.c
crypto/x509/v3_pcons.c
crypto/x509/v3_pmaps.c
crypto/x509/x509_att.c
crypto/x509/x509name.c

index 8125dd11608b714b8b9816780a085439fb288171..ab76ed8e7abdb104475de9061d8d340da50c3c0a 100644 (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))
         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;
     }
 
index 9b307dbb9da4d218a76ab07152250436d278b12a..7279133c2adaab1b2e167bb566e41f4366de0900 100644 (file)
@@ -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;
     }
 
index e717a9365337568471ddf0e6c527ff94feace7bb..3c003ee1038fe825dab8542e5195eedf0fab1671 100644 (file)
@@ -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;
 
         }
index 1e952734d012bfde182db808f87349106b38febf..8ee0970dc680f41513cf00469bcec6401e5121ce 100644 (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") &&
             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;
     }
index 3992468a01d713b9ae7d537aff86fcf61717f137..3543cd22568fd0ea5b0a603854edf6487fc64100 100644 (file)
@@ -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);
index 7a8ac6fb9c9ec863f9cc704f421cd25233b1f51d..7515cf264b1a2cd84c39d779caffd1c7c829eb69 100644 (file)
@@ -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 {
index 3b5c7f1c19f678aded509096e611aae983a34928..5b776224d669baa2f11763106ae188f3a6913952 100644 (file)
@@ -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;
             }
 
index a88d1ce61bb727b420853ce853faa75db7c2938e..c7bd0a329fea514fc9cc777715e1ca98b2c7dee9 100644 (file)
@@ -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;
index 39b69572f9d9384c355908bbb78d2af530cbe873..45981ab27bccdb122382933b853aeccefb0f8260 100644 (file)
@@ -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;
     }
 
index dd974413c04968fef403f1611b33db9ed5ad9d8a..c19eea818fcc98fb3bff2e4f871e799c4f565f50 100644 (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 */
 
     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);
index eff093c6b51450afb9bc5b7baac5f085b79ac0a6..1a4a8731687693223334909aeec851e77ced5970 100644 (file)
@@ -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;
 }
 
index 1660906753f1f56fba32f415067dbad905aa093d..dc14f754de239df92acdf724bda94a85269853fd 100644 (file)
@@ -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;
     }
 }
 
index 84cd27afea28388ed66f01bc3940cf900dcb154f..5c903f204bd93225e3399b191f4a599a29c1f28e 100644 (file)
@@ -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;
index 0211da9b91e41f0a034d66d0537403e4e09b772f..5d69dc96d2664258669f1c47a2b8c409c688f14e 100644 (file)
@@ -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;
index 5923f882120b2d638ccdfd2047e01f775c2d46ad..2637e17fd80b09fd904d1cac007bac5754ef794e 100644 (file)
@@ -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 */
index d100d5ed5cf18ec7ea319bd5a95111c1a71542cd..1f106d8c071d09eccecd1c59094c92497825a7a9 100644 (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);
         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;
 }
 
index 9a07beb6b61650d912ec5cc2c03c41a3c4dd42bd..cb1bf7cd3c6043c407ef13aaf85832e51d9c8c93 100644 (file)
@@ -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;
 }
 
index 6512dda132bf36c2a72e8f851a979fca46acb497..a4b35bab9962ae89a77154faf73d4a483b38a68b 100644 (file)
@@ -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);
index 721fb14c83560db96deb9aaa25b71ca16118356a..36dcf1d73d1d620bf7294a71765f00bcb2527aa0 100644 (file)
@@ -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;
index 4137d7d9f852579b61dde97b1671cbc00573a0f7..76bc6055bcf5e54a1006617da938c840163dc5cf 100644 (file)
@@ -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;
index 90b94992b422c6013f223cd37d07d6c1751b69f3..03abcc0d730ef8d28b540fbd3e4386214467c48b 100644 (file)
@@ -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;
     }
index 3b4d5962206344bd9255f81ee6be1e5b26d916e1..4d3059d43879f8e9108ebdff32ba04aa600aa775 100644 (file)
@@ -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;
index 0c7597ad9f2cfa2e0309a4675736fa9f8088c3b4..051d3fe18165e55e644e04122f0403195d567b80 100644 (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
         || (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;
     }
index 4a14400a042e7a06bece979cda5c505aa98a1a22..14744bb7f55bd7dfaa87567f1df82eb065ce76a5 100644 (file)
@@ -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;
index 7b971678fde8cc8869203c8cc42b322e44bdad6a..78537057b7088a3c098a9ccfbbb9e51c87aa2c40 100644 (file)
@@ -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);
index 3008384d3fbf6c2373159197e8a6ceb5dca81749..de3475fe22f1a4a69bd8a9e92faba0f22d713e39 100644 (file)
@@ -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 */
 }
index 7da71dddb3e9703b0b00b0ab6ef780f028a7d308..7c2301d26cf24e990df3fe48eddc37a42bfcab67 100644 (file)
@@ -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;
         }
 
index e6bd33259d5410a42f1a0d33eb0044f4a20edd18..d9d51e0d78aa3f6da7133635766ee023cc1b1424 100644 (file)
@@ -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;
         }
     }
index c92605d50a1bb5ebb6ef85538060c8c131963e7e..b049420d0bafea1d64e7a26adda41454d89d9484 100644 (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))) {
-        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;
     }
 
index ef23b889aac5bd037a5b5da06e01d1971f306012..d8a6bdec317d4bbafeaf92d8e2136e86814a2cf4 100644 (file)
@@ -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;
index 1b8b3e3060ec0139f7cd5d7bdb5a87381e82d890..f49f651007ec0df7e082d81c120710e02860e463 100644 (file)
@@ -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)
index f3e6ac1ce9e62a0e89c7f529ae29e05d25fa264e..770534d9f6ac9fb1049204ac2dbae98d226ce58d 100644 (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);
             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 */
index 22b4116f880eba64234e48305181b72b3b4098d5..709e7a1c515a22351a2a191fd72e495060e5ceb3 100644 (file)
@@ -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;
     }
 
index fdce6711ed3b1f636fe6a626094f6c878a31cb46..211f4f3f514dd28bf107ae8f57023e333dfb3150 100644 (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))
                 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;
         }
     }
index b104895e3a6fae027aa2d9a57773f04938fb9d8a..655dc71b06609b25619a7f4216cb6fe2c8a4d2c8 100644 (file)
@@ -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;
     }
 
index 6fb8e496615ddd73a18cf5769012833592205c47..fd2ad90754b04f20756f84c4f43f042c28bc5905 100644 (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)
 {
-    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;
 }
index b0bcba79176753c2ed981d12e27bc7ebad4642b8..8e097a33362534c5f805d0c40335dcf9dcd0598a 100644 (file)
@@ -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;
index 4c7454661254c7dddab0249767c0c28d3df74e7c..fd03dc6cd06aa9678893daf62d56f745914ab962 100644 (file)
@@ -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) {
index dc7e9cc56a39c7c4988c0bd073372abc3228b62f..0a38658c72a6cc151bbbe4db83d70126e542ea6f 100644 (file)
@@ -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
index ae4978409bcdb36e953b6538f502e26d18c1d906..b7dd8890875710e750d4f6e9e035df2cd123f502 100644 (file)
@@ -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;
         }
 
index 529dddf66492bfded5c7c455e97cd5b4d59dee9d..21ea1e4c758f0ce8a0b1629745257357b3fc037f 100644 (file)
@@ -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;
         }
     }
index 9d403040372d6ec6118a51b265188955cdaccd07..2344c554fa173516d3eb55987c346f30adc2bf8e 100644 (file)
@@ -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... */
index 68369fb3efec4635a1acc6c66c8312063d6131e7..0caa338ff098745e922996963cd403e83f541be3 100644 (file)
@@ -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;
         }
index 984f118075aa130675ed0120b074ffce4c5031c0..47b626659c7c7e3b66e42c62a649bab2fd5daee8 100644 (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);
     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;
     }
 
index 7d27c1f2251ca6b1c5d3d7f08078f25561288cae..55aa5cac05968204ea8dd07c169e947887c38db8 100644 (file)
@@ -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();
index 9aabfe165648a4558a252672e923d25b0a9c7c89..753733323e94281c6bb59f27f2d1dac24c88848e 100644 (file)
@@ -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 */
index 594ee3aa23f8d0de1434ec2023907c42d06cf212..003f3ce17216ffe04335168c15e724ed068fcaa1 100644 (file)
@@ -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:
index 72628b46957ee9ede5521d1171f89dbae3adfabb..a8e8ab299f81eaa6ca47d0dc89bb59d6fe7f3172 100644 (file)
@@ -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;
         }
     }
index 7350b1f4378c1c47f0c75fcb9073efcd2468e152..0a76b2f38d0d72ad01566a2146212c226fa60773 100644 (file)
@@ -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();
index ad747681487d10da0ff885ace5c4f39aa14eb9de..6a949f190e991426ad0845d683c42c5e6273afe7 100644 (file)
@@ -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);
index a919a612502fe6e31c8af9a27855930cfef2884f..690e2799ffcdee4cd2db9f68892b71179564df15 100644 (file)
@@ -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);