From 0d73b4a5ca6658f8fa164bce1fee9552482afe31 Mon Sep 17 00:00:00 2001 From: guenther <> Date: Sun, 20 Apr 2014 20:14:09 +0000 Subject: Chop off more SSLv2 tentacles and start fixing and noting y2038 issues. APIs that pass times as longs will have to change at some point... Bump major on both libcrypto and libssl. ok tedu@ --- src/lib/libcrypto/err/err.c | 29 ++++++++++++++++++----------- src/lib/libssl/src/crypto/err/err.c | 29 ++++++++++++++++++----------- 2 files changed, 36 insertions(+), 22 deletions(-) (limited to 'src/lib') 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 * void ERR_error_string_n(unsigned long e, char *buf, size_t len) { - char lsbuf[64], fsbuf[64], rsbuf[64]; + char lsbuf[30], fsbuf[30], rsbuf[30]; const char *ls,*fs,*rs; - unsigned long l,f,r; + int l, f, r, ret; l=ERR_GET_LIB(e); f=ERR_GET_FUNC(e); @@ -841,16 +841,23 @@ void ERR_error_string_n(unsigned long e, char *buf, size_t len) fs=ERR_func_error_string(e); rs=ERR_reason_error_string(e); - if (ls == NULL) - snprintf(lsbuf, sizeof(lsbuf), "lib(%lu)", l); - if (fs == NULL) - snprintf(fsbuf, sizeof(fsbuf), "func(%lu)", f); - if (rs == NULL) - snprintf(rsbuf, sizeof(rsbuf), "reason(%lu)", r); + if (ls == NULL) { + (void) snprintf(lsbuf, sizeof(lsbuf), "lib(%d)", l); + ls = lsbuf; + } + if (fs == NULL) { + (void) snprintf(fsbuf, sizeof(fsbuf), "func(%d)", f); + fs = fsbuf; + } + if (rs == NULL) { + (void) snprintf(rsbuf, sizeof(rsbuf), "reason(%d)", r); + rs = rsbuf; + } - snprintf(buf, len,"error:%08lX:%s:%s:%s", e, ls?ls:lsbuf, - fs?fs:fsbuf, rs?rs:rsbuf); - if (strlen(buf) == len-1) + ret = snprintf(buf, len, "error:%08lX:%s:%s:%s", e, ls, fs, rs); + if (ret == -1) + return; /* can't happen, and can't do better if it does */ + if (ret >= len) { /* output may be truncated; make sure we always have 5 * 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 * void ERR_error_string_n(unsigned long e, char *buf, size_t len) { - char lsbuf[64], fsbuf[64], rsbuf[64]; + char lsbuf[30], fsbuf[30], rsbuf[30]; const char *ls,*fs,*rs; - unsigned long l,f,r; + int l, f, r, ret; l=ERR_GET_LIB(e); f=ERR_GET_FUNC(e); @@ -841,16 +841,23 @@ void ERR_error_string_n(unsigned long e, char *buf, size_t len) fs=ERR_func_error_string(e); rs=ERR_reason_error_string(e); - if (ls == NULL) - snprintf(lsbuf, sizeof(lsbuf), "lib(%lu)", l); - if (fs == NULL) - snprintf(fsbuf, sizeof(fsbuf), "func(%lu)", f); - if (rs == NULL) - snprintf(rsbuf, sizeof(rsbuf), "reason(%lu)", r); + if (ls == NULL) { + (void) snprintf(lsbuf, sizeof(lsbuf), "lib(%d)", l); + ls = lsbuf; + } + if (fs == NULL) { + (void) snprintf(fsbuf, sizeof(fsbuf), "func(%d)", f); + fs = fsbuf; + } + if (rs == NULL) { + (void) snprintf(rsbuf, sizeof(rsbuf), "reason(%d)", r); + rs = rsbuf; + } - snprintf(buf, len,"error:%08lX:%s:%s:%s", e, ls?ls:lsbuf, - fs?fs:fsbuf, rs?rs:rsbuf); - if (strlen(buf) == len-1) + ret = snprintf(buf, len, "error:%08lX:%s:%s:%s", e, ls, fs, rs); + if (ret == -1) + return; /* can't happen, and can't do better if it does */ + if (ret >= len) { /* output may be truncated; make sure we always have 5 * colon-separated fields, i.e. 4 colons ... */ -- cgit v1.2.3-55-g6feb