Browse Source

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)
master
Richard Levitte 2 years ago
parent
commit
a150f8e1fc
51 changed files with 273 additions and 366 deletions
  1. +2
    -2
      apps/lib/apps.c
  2. +4
    -7
      crypto/asn1/a_mbstr.c
  3. +3
    -7
      crypto/asn1/asn1_gen.c
  4. +6
    -6
      crypto/asn1/asn_mime.c
  5. +4
    -4
      crypto/asn1/asn_mstbl.c
  6. +3
    -5
      crypto/bio/b_addr.c
  7. +4
    -4
      crypto/bio/bss_acpt.c
  8. +4
    -4
      crypto/bio/bss_conn.c
  9. +7
    -8
      crypto/bio/bss_dgram.c
  10. +10
    -7
      crypto/cmp/cmp_client.c
  11. +4
    -12
      crypto/cmp/cmp_msg.c
  12. +3
    -7
      crypto/cmp/cmp_status.c
  13. +2
    -4
      crypto/cms/cms_smime.c
  14. +6
    -6
      crypto/comp/c_zlib.c
  15. +4
    -5
      crypto/conf/conf_def.c
  16. +2
    -2
      crypto/conf/conf_lib.c
  17. +10
    -14
      crypto/conf/conf_mod.c
  18. +13
    -12
      crypto/conf/conf_ssl.c
  19. +12
    -4
      crypto/dso/dso_dl.c
  20. +5
    -4
      crypto/dso/dso_dlfcn.c
  21. +10
    -13
      crypto/dso/dso_vms.c
  22. +3
    -4
      crypto/dso/dso_win32.c
  23. +4
    -2
      crypto/ec/ec_curve.c
  24. +6
    -6
      crypto/engine/eng_cnf.c
  25. +2
    -3
      crypto/engine/eng_fat.c
  26. +1
    -2
      crypto/engine/eng_list.c
  27. +2
    -3
      crypto/evp/evp_cnf.c
  28. +4
    -4
      crypto/evp/evp_pbe.c
  29. +2
    -2
      crypto/evp/evp_pkey.c
  30. +21
    -35
      crypto/http/http_client.c
  31. +2
    -3
      crypto/ocsp/ocsp_vfy.c
  32. +3
    -3
      crypto/pkcs7/pk7_smime.c
  33. +2
    -2
      crypto/provider_conf.c
  34. +3
    -2
      crypto/rand/rand_lib.c
  35. +9
    -10
      crypto/rand/randfile.c
  36. +5
    -8
      crypto/ts/ts_conf.c
  37. +7
    -9
      crypto/ts/ts_rsp_verify.c
  38. +17
    -27
      crypto/ui/ui_lib.c
  39. +13
    -34
      crypto/ui/ui_openssl.c
  40. +2
    -3
      crypto/x509/v3_addr.c
  41. +2
    -2
      crypto/x509/v3_akey.c
  42. +8
    -8
      crypto/x509/v3_alt.c
  43. +2
    -3
      crypto/x509/v3_bitst.c
  44. +13
    -17
      crypto/x509/v3_conf.c
  45. +5
    -5
      crypto/x509/v3_cpols.c
  46. +2
    -3
      crypto/x509/v3_extku.c
  47. +5
    -15
      crypto/x509/v3_info.c
  48. +2
    -2
      crypto/x509/v3_pcons.c
  49. +4
    -6
      crypto/x509/v3_pmaps.c
  50. +2
    -3
      crypto/x509/x509_att.c
  51. +2
    -3
      crypto/x509/x509name.c

+ 2
- 2
apps/lib/apps.c View File

@ -2043,8 +2043,8 @@ ASN1_VALUE *app_http_get_asn1(const char *url, const char *proxy,
if (!OSSL_HTTP_parse_url(url, &server, &port, NULL, NULL, &use_ssl))
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;
}


+ 4
- 7
crypto/asn1/a_mbstr.c View 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;
}


+ 3
- 7
crypto/asn1/asn1_gen.c View 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;
}


+ 6
- 6
crypto/asn1/asn_mime.c View File

@ -453,8 +453,8 @@ ASN1_VALUE *SMIME_read_ASN1_ex(BIO *bio, BIO **bcont, const ASN1_ITEM *it,
if (strcmp(hdr->value, "application/x-pkcs7-signature") &&
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;
}


+ 4
- 4
crypto/asn1/asn_mstbl.c View 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);


+ 3
- 5
crypto/bio/b_addr.c View 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 {


+ 4
- 4
crypto/bio/bss_acpt.c View 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;
}


+ 4
- 4
crypto/bio/bss_conn.c View 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;


+ 7
- 8
crypto/bio/bss_dgram.c View 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;
}


+ 10
- 7
crypto/cmp/cmp_client.c View File

@ -169,9 +169,9 @@ static int send_receive_check(OSSL_CMP_CTX *ctx, const OSSL_CMP_MSG *req,
ctx->msg_timeout = msg_timeout; /* restore original value */
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);


+ 4
- 12
crypto/cmp/cmp_msg.c View 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;
}


+ 3
- 7
crypto/cmp/cmp_status.c View 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;
}
}


+ 2
- 4
crypto/cms/cms_smime.c View 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;


+ 6
- 6
crypto/comp/c_zlib.c View 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;


+ 4
- 5
crypto/conf/conf_def.c View 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 */


+ 2
- 2
crypto/conf/conf_lib.c View File

@ -279,8 +279,8 @@ char *NCONF_get_string(const CONF *conf, const char *group, const char *name)
ERR_raise(ERR_LIB_CONF, CONF_R_NO_CONF_OR_ENVIRONMENT_VARIABLE);
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;
}


+ 10
- 14
crypto/conf/conf_mod.c View 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;
}


+ 13
- 12
crypto/conf/conf_ssl.c View File

@ -68,11 +68,12 @@ static int ssl_module_init(CONF_IMODULE *md, const CONF *cnf)
ssl_conf_section = CONF_imodule_get_value(md);
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);


+ 12
- 4
crypto/dso/dso_dl.c View 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;


+ 5
- 4
crypto/dso/dso_dlfcn.c View 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;


+ 10
- 13
crypto/dso/dso_vms.c View 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;
}


+ 3
- 4
crypto/dso/dso_win32.c View 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;


+ 4
- 2
crypto/ec/ec_curve.c View File

@ -3298,9 +3298,11 @@ EC_GROUP *EC_GROUP_new_by_curve_name_ex(OSSL_LIB_CTX *libctx, const char *propq,
if ((curve = ec_curve_nid2curve(nid)) == NULL
|| (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;
}


+ 6
- 6
crypto/engine/eng_cnf.c View 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;


+ 2
- 3
crypto/engine/eng_fat.c View 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);


+ 1
- 2
crypto/engine/eng_list.c View 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 */
}


+ 2
- 3
crypto/evp/evp_cnf.c View 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;
}


+ 4
- 4
crypto/evp/evp_pbe.c View 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;
}
}


+ 2
- 2
crypto/evp/evp_pkey.c View File

@ -36,9 +36,9 @@ EVP_PKEY *EVP_PKCS82PKEY_ex(const PKCS8_PRIV_KEY_INFO *p8, OSSL_LIB_CTX *libctx,
}
if (!EVP_PKEY_set_type(pkey, OBJ_obj2nid(algoid))) {
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;
}


+ 21
- 35
crypto/http/http_client.c View 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;


+ 2
- 3
crypto/ocsp/ocsp_vfy.c View 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)


+ 3
- 3
crypto/pkcs7/pk7_smime.c View File

@ -290,9 +290,9 @@ int PKCS7_verify(PKCS7 *p7, STACK_OF(X509) *certs, X509_STORE *store,
j = X509_STORE_CTX_get_error(cert_ctx);
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 */


+ 2
- 2
crypto/provider_conf.c View 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;
}


+ 3
- 2
crypto/rand/rand_lib.c View File

@ -645,8 +645,9 @@ static int random_conf_init(CONF_IMODULE *md, const CONF *cnf)
if (!random_set_string(&dgbl->rng_propq, cval->value))
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;
}
}


+ 9
- 10
crypto/rand/randfile.c View 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;
}


+ 5
- 8
crypto/ts/ts_conf.c View File

@ -112,14 +112,12 @@ EVP_PKEY *TS_CONF_load_key(const char *file, const char *pass)
static void ts_CONF_lookup_fail(const char *name, const char *tag)
{
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;
}


+ 7
- 9
crypto/ts/ts_rsp_verify.c View 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;


+ 17
- 27
crypto/ui/ui_lib.c View 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) {


+ 13
- 34
crypto/ui/ui_openssl.c View 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


+ 2
- 3
crypto/x509/v3_addr.c View 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;
}


+ 2
- 2
crypto/x509/v3_akey.c View 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;
}
}


+ 8
- 8
crypto/x509/v3_alt.c View 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... */


+ 2
- 3
crypto/x509/v3_bitst.c View 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