From 74527a0bb224fd510e5c718e23f8bc4307c90957 Mon Sep 17 00:00:00 2001 From: Love Hornquist Astrand Date: Sun, 13 Dec 2009 11:15:38 -0800 Subject: [PATCH] if we have strerror_r, assume its the non standard strerror_r --- lib/roken/strerror_r.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/lib/roken/strerror_r.c b/lib/roken/strerror_r.c index d2ed9a97a..ea32b6a1e 100644 --- a/lib/roken/strerror_r.c +++ b/lib/roken/strerror_r.c @@ -37,12 +37,23 @@ #include #include +#ifndef HAVE_STRERROR_R extern int sys_nerr; extern char *sys_errlist[]; +#endif int ROKEN_LIB_FUNCTION rk_strerror_r(int eno, char *strerrbuf, size_t buflen) { + /* Assume is the linux broken strerror_r (returns the a buffer (char *) if the input buffer wasn't use */ +#ifdef HAVE_STRERROR_R + const char *str; + str = strerror_r(eno, strerrbuf, buflen); + if (str != strerrbuf) + if (strlcpy(strerrbuf, str, buflen) >= buflen) + return ERANGE; + return 0; +#else int ret; if(eno < 0 || eno >= sys_nerr) { snprintf(strerrbuf, buflen, "Error %d occurred.", eno); @@ -52,4 +63,5 @@ rk_strerror_r(int eno, char *strerrbuf, size_t buflen) if (ret > buflen) return ERANGE; return 0; +#endif }