diff options
-rw-r--r-- | src/lib/libcrypto/err/err.c | 29 | ||||
-rw-r--r-- | src/lib/libssl/src/crypto/err/err.c | 29 |
2 files changed, 36 insertions, 22 deletions
diff --git a/src/lib/libcrypto/err/err.c b/src/lib/libcrypto/err/err.c index c4192c6bfa..c44a065486 100644 --- a/src/lib/libcrypto/err/err.c +++ b/src/lib/libcrypto/err/err.c | |||
@@ -829,9 +829,9 @@ static unsigned long get_error_values(int inc, int top, const char **file, int * | |||
829 | 829 | ||
830 | void ERR_error_string_n(unsigned long e, char *buf, size_t len) | 830 | void ERR_error_string_n(unsigned long e, char *buf, size_t len) |
831 | { | 831 | { |
832 | char lsbuf[64], fsbuf[64], rsbuf[64]; | 832 | char lsbuf[30], fsbuf[30], rsbuf[30]; |
833 | const char *ls,*fs,*rs; | 833 | const char *ls,*fs,*rs; |
834 | unsigned long l,f,r; | 834 | int l, f, r, ret; |
835 | 835 | ||
836 | l=ERR_GET_LIB(e); | 836 | l=ERR_GET_LIB(e); |
837 | f=ERR_GET_FUNC(e); | 837 | f=ERR_GET_FUNC(e); |
@@ -841,16 +841,23 @@ void ERR_error_string_n(unsigned long e, char *buf, size_t len) | |||
841 | fs=ERR_func_error_string(e); | 841 | fs=ERR_func_error_string(e); |
842 | rs=ERR_reason_error_string(e); | 842 | rs=ERR_reason_error_string(e); |
843 | 843 | ||
844 | if (ls == NULL) | 844 | if (ls == NULL) { |
845 | snprintf(lsbuf, sizeof(lsbuf), "lib(%lu)", l); | 845 | (void) snprintf(lsbuf, sizeof(lsbuf), "lib(%d)", l); |
846 | if (fs == NULL) | 846 | ls = lsbuf; |
847 | snprintf(fsbuf, sizeof(fsbuf), "func(%lu)", f); | 847 | } |
848 | if (rs == NULL) | 848 | if (fs == NULL) { |
849 | snprintf(rsbuf, sizeof(rsbuf), "reason(%lu)", r); | 849 | (void) snprintf(fsbuf, sizeof(fsbuf), "func(%d)", f); |
850 | fs = fsbuf; | ||
851 | } | ||
852 | if (rs == NULL) { | ||
853 | (void) snprintf(rsbuf, sizeof(rsbuf), "reason(%d)", r); | ||
854 | rs = rsbuf; | ||
855 | } | ||
850 | 856 | ||
851 | snprintf(buf, len,"error:%08lX:%s:%s:%s", e, ls?ls:lsbuf, | 857 | ret = snprintf(buf, len, "error:%08lX:%s:%s:%s", e, ls, fs, rs); |
852 | fs?fs:fsbuf, rs?rs:rsbuf); | 858 | if (ret == -1) |
853 | if (strlen(buf) == len-1) | 859 | return; /* can't happen, and can't do better if it does */ |
860 | if (ret >= len) | ||
854 | { | 861 | { |
855 | /* output may be truncated; make sure we always have 5 | 862 | /* output may be truncated; make sure we always have 5 |
856 | * colon-separated fields, i.e. 4 colons ... */ | 863 | * colon-separated fields, i.e. 4 colons ... */ |
diff --git a/src/lib/libssl/src/crypto/err/err.c b/src/lib/libssl/src/crypto/err/err.c index c4192c6bfa..c44a065486 100644 --- a/src/lib/libssl/src/crypto/err/err.c +++ b/src/lib/libssl/src/crypto/err/err.c | |||
@@ -829,9 +829,9 @@ static unsigned long get_error_values(int inc, int top, const char **file, int * | |||
829 | 829 | ||
830 | void ERR_error_string_n(unsigned long e, char *buf, size_t len) | 830 | void ERR_error_string_n(unsigned long e, char *buf, size_t len) |
831 | { | 831 | { |
832 | char lsbuf[64], fsbuf[64], rsbuf[64]; | 832 | char lsbuf[30], fsbuf[30], rsbuf[30]; |
833 | const char *ls,*fs,*rs; | 833 | const char *ls,*fs,*rs; |
834 | unsigned long l,f,r; | 834 | int l, f, r, ret; |
835 | 835 | ||
836 | l=ERR_GET_LIB(e); | 836 | l=ERR_GET_LIB(e); |
837 | f=ERR_GET_FUNC(e); | 837 | f=ERR_GET_FUNC(e); |
@@ -841,16 +841,23 @@ void ERR_error_string_n(unsigned long e, char *buf, size_t len) | |||
841 | fs=ERR_func_error_string(e); | 841 | fs=ERR_func_error_string(e); |
842 | rs=ERR_reason_error_string(e); | 842 | rs=ERR_reason_error_string(e); |
843 | 843 | ||
844 | if (ls == NULL) | 844 | if (ls == NULL) { |
845 | snprintf(lsbuf, sizeof(lsbuf), "lib(%lu)", l); | 845 | (void) snprintf(lsbuf, sizeof(lsbuf), "lib(%d)", l); |
846 | if (fs == NULL) | 846 | ls = lsbuf; |
847 | snprintf(fsbuf, sizeof(fsbuf), "func(%lu)", f); | 847 | } |
848 | if (rs == NULL) | 848 | if (fs == NULL) { |
849 | snprintf(rsbuf, sizeof(rsbuf), "reason(%lu)", r); | 849 | (void) snprintf(fsbuf, sizeof(fsbuf), "func(%d)", f); |
850 | fs = fsbuf; | ||
851 | } | ||
852 | if (rs == NULL) { | ||
853 | (void) snprintf(rsbuf, sizeof(rsbuf), "reason(%d)", r); | ||
854 | rs = rsbuf; | ||
855 | } | ||
850 | 856 | ||
851 | snprintf(buf, len,"error:%08lX:%s:%s:%s", e, ls?ls:lsbuf, | 857 | ret = snprintf(buf, len, "error:%08lX:%s:%s:%s", e, ls, fs, rs); |
852 | fs?fs:fsbuf, rs?rs:rsbuf); | 858 | if (ret == -1) |
853 | if (strlen(buf) == len-1) | 859 | return; /* can't happen, and can't do better if it does */ |
860 | if (ret >= len) | ||
854 | { | 861 | { |
855 | /* output may be truncated; make sure we always have 5 | 862 | /* output may be truncated; make sure we always have 5 |
856 | * colon-separated fields, i.e. 4 colons ... */ | 863 | * colon-separated fields, i.e. 4 colons ... */ |