summaryrefslogtreecommitdiffstats
path: root/crypto/err/err.c
diff options
context:
space:
mode:
authorRichard Levitte <levitte@openssl.org>2020-11-25 12:03:32 +0100
committerRichard Levitte <levitte@openssl.org>2020-11-27 12:02:56 +0100
commit63132c53f975b322011e08a4e8f7f8c76c3b535a (patch)
treeee1db6c880d28991e4b18f0b13620eedf2e14d5b /crypto/err/err.c
parent66923436788d307c8e64cc392ffcd9631065eaa5 (diff)
ERR: Restore the similarity of ERR_print_error_cb() and ERR_error_string_n()
Reviewed-by: Tomas Mraz <tmraz@fedoraproject.org> (Merged from https://github.com/openssl/openssl/pull/13510)
Diffstat (limited to 'crypto/err/err.c')
-rw-r--r--crypto/err/err.c17
1 files changed, 13 insertions, 4 deletions
diff --git a/crypto/err/err.c b/crypto/err/err.c
index 8500fe7988..06f0d35054 100644
--- a/crypto/err/err.c
+++ b/crypto/err/err.c
@@ -489,11 +489,12 @@ static unsigned long get_error_values(ERR_GET_ACTION g,
return ret;
}
-void ERR_error_string_n(unsigned long e, char *buf, size_t len)
+void ossl_err_string_int(unsigned long e, const char *func,
+ char *buf, size_t len)
{
char lsbuf[64], rsbuf[256];
const char *ls, *rs = NULL;
- unsigned long f = 0, l, r;
+ unsigned long l, r;
if (len == 0)
return;
@@ -512,24 +513,32 @@ void ERR_error_string_n(unsigned long e, char *buf, size_t len)
* directly instead.
*/
r = ERR_GET_REASON(e);
+#ifndef OPENSSL_NO_ERR
if (ERR_SYSTEM_ERROR(e)) {
if (openssl_strerror_r(r, rsbuf, sizeof(rsbuf)))
rs = rsbuf;
} else {
rs = ERR_reason_error_string(e);
}
+#endif
if (rs == NULL) {
BIO_snprintf(rsbuf, sizeof(rsbuf), "reason(%lu)", r);
rs = rsbuf;
}
- BIO_snprintf(buf, len, "error:%08lX:%s:%s:%s", e, ls, "", rs);
+ BIO_snprintf(buf, len, "error:%08lX:%s:%s:%s", e, ls, func, rs);
if (strlen(buf) == len - 1) {
/* Didn't fit; use a minimal format. */
- BIO_snprintf(buf, len, "err:%lx:%lx:%lx:%lx", e, l, f, r);
+ BIO_snprintf(buf, len, "err:%lx:%lx:%lx:%lx", e, l, 0L, r);
}
}
+
+void ERR_error_string_n(unsigned long e, char *buf, size_t len)
+{
+ ossl_err_string_int(e, "", buf, len);
+}
+
/*
* ERR_error_string_n should be used instead for ret != NULL as
* ERR_error_string cannot know how large the buffer is