diff options
author | Matt Caswell <matt@openssl.org> | 2016-05-23 13:52:29 +0100 |
---|---|---|
committer | Matt Caswell <matt@openssl.org> | 2016-05-23 23:26:10 +0100 |
commit | 7d37818dacc87c21dfc9d2def5014657344875e3 (patch) | |
tree | 459cf7a75959c26b09b1e91be893b5f4fe27b3fe /crypto/err | |
parent | a93e0e78db78e03bdcd29acf9bbc8a812ee50cb6 (diff) |
Use strerror_r()/strerror_s() instead of strerror() where possible
The function strerror() is not thread safe. We should use strerror_r()
where possible, or strerror_s() on Windows.
RT#2267
Reviewed-by: Richard Levitte <levitte@openssl.org>
Diffstat (limited to 'crypto/err')
-rw-r--r-- | crypto/err/err.c | 6 |
1 files changed, 1 insertions, 5 deletions
diff --git a/crypto/err/err.c b/crypto/err/err.c index 1035e4c749..9b679d9b48 100644 --- a/crypto/err/err.c +++ b/crypto/err/err.c @@ -220,12 +220,8 @@ static void build_SYS_str_reasons(void) str->error = (unsigned long)i; if (str->string == NULL) { char (*dest)[LEN_SYS_STR_REASON] = &(strerror_tab[i - 1]); - char *src = strerror(i); - if (src != NULL) { - strncpy(*dest, src, sizeof(*dest)); - (*dest)[sizeof(*dest) - 1] = '\0'; + if (openssl_strerror_r(i, *dest, sizeof(*dest))) str->string = *dest; - } } if (str->string == NULL) str->string = "unknown"; |