* Note: at least for RSA keys if this function returns
* -1, there will be no error reasons.
*/
- unsigned long err;
-
- BIO_printf(out, "Key is invalid\n");
-
- while ((err = ERR_peek_error()) != 0) {
- BIO_printf(out, "Detailed error: %s\n",
- ERR_reason_error_string(err));
- ERR_get_error(); /* remove err from error stack */
- }
+ BIO_printf(bio_err, "Key is invalid\n");
+ ERR_print_errors(bio_err);
goto end;
}
}
int text = 0, noout = 0, ret = EXIT_FAILURE, check = 0, r;
OPTION_CHOICE o;
char *infile = NULL, *outfile = NULL, *prog;
- unsigned long err;
prog = opt_init(argc, argv, pkeyparam_options);
while ((o = opt_next()) != OPT_EOF) {
* Note: at least for RSA keys if this function returns
* -1, there will be no error reasons.
*/
- BIO_printf(out, "Parameters are invalid\n");
-
- while ((err = ERR_peek_error()) != 0) {
- BIO_printf(out, "Detailed error: %s\n",
- ERR_reason_error_string(err));
- ERR_get_error(); /* remove err from error stack */
- }
+ BIO_printf(bio_err, "Parameters are invalid\n");
+ ERR_print_errors(bio_err);
goto end;
}
}
pctx = EVP_PKEY_CTX_new_from_pkey(NULL, pkey, NULL);
if (pctx == NULL) {
- BIO_printf(out, "RSA unable to create PKEY context\n");
+ BIO_printf(bio_err, "RSA unable to create PKEY context\n");
ERR_print_errors(bio_err);
goto end;
}
if (r == 1) {
BIO_printf(out, "RSA key ok\n");
} else if (r == 0) {
- unsigned long err;
-
- while ((err = ERR_peek_error()) != 0 &&
- ERR_GET_LIB(err) == ERR_LIB_RSA &&
- ERR_GET_REASON(err) != ERR_R_MALLOC_FAILURE) {
- BIO_printf(out, "RSA key error: %s\n",
- ERR_reason_error_string(err));
- ERR_get_error(); /* remove err from error stack */
- }
+ BIO_printf(bio_err, "RSA key not ok\n");
+ ERR_print_errors(bio_err);
} else if (r == -1) {
ERR_print_errors(bio_err);
goto end;
# endif
if (bind(sock, BIO_ADDR_sockaddr(addr), BIO_ADDR_sockaddr_size(addr)) != 0) {
- ERR_raise_data(ERR_LIB_SYS, get_last_socket_error(),
+ ERR_raise_data(ERR_LIB_SYS, get_last_socket_error() /* may be 0 */,
"calling bind()");
ERR_raise(ERR_LIB_BIO, BIO_R_UNABLE_TO_BIND_SOCKET);
return 0;
while ((err = ERR_get_error_all(&file, &line, &func, &data, &flags)) != 0) {
const char *component =
improve_location_name(func, ERR_lib_error_string(err));
+ unsigned long reason = ERR_GET_REASON(err);
+ const char *rs = NULL;
+ char rsbuf[256];
+
+#ifndef OPENSSL_NO_ERR
+ if (ERR_SYSTEM_ERROR(err)) {
+ if (openssl_strerror_r(reason, rsbuf, sizeof(rsbuf)))
+ rs = rsbuf;
+ } else {
+ rs = ERR_reason_error_string(err);
+ }
+#endif
+ if (rs == NULL) {
+ BIO_snprintf(rsbuf, sizeof(rsbuf), "reason(%lu)", reason);
+ rs = rsbuf;
+ }
+ if (data != NULL && (flags & ERR_TXT_STRING) != 0)
+ BIO_snprintf(msg, sizeof(msg), "%s:%s", rs, data);
+ else
+ BIO_snprintf(msg, sizeof(msg), "%s", rs);
- if (!(flags & ERR_TXT_STRING))
- data = NULL;
- BIO_snprintf(msg, sizeof(msg), "%s%s%s", ERR_reason_error_string(err),
- data == NULL || *data == '\0' ? "" : " : ",
- data == NULL ? "" : data);
if (log_fn == NULL) {
#ifndef OPENSSL_NO_STDIO
BIO *bio = BIO_new_fp(stderr, BIO_NOCLOSE);
ERR_raise(ERR_LIB_CMP, CMP_R_NULL_ARGUMENT);
base_err_msg_size += strlen("NULL_ARGUMENT");
expected_size = base_err_msg_size;
- ossl_cmp_add_error_data("data1"); /* should prepend separator " : " */
- expected_size += strlen(" : " "data1");
+ ossl_cmp_add_error_data("data1"); /* should prepend separator ":" */
+ expected_size += strlen(":" "data1");
ossl_cmp_add_error_data("data2"); /* should prepend separator " : " */
expected_size += strlen(" : " "data2");
ossl_cmp_add_error_line("new line"); /* should prepend separator "\n" */
res = 0;
ERR_raise(ERR_LIB_CMP, CMP_R_INVALID_ARGS);
- base_err_msg_size = strlen("INVALID_ARGS") + strlen(" : ");
+ base_err_msg_size = strlen("INVALID_ARGS") + strlen(":");
expected_size = base_err_msg_size;
while (expected_size < 4096) { /* force split */
ERR_add_error_txt(STR_SEP, max_str_literal);