From c48289c6d14aadd1aca41a1c93122b5ba399bf0b Mon Sep 17 00:00:00 2001 From: Florian Forster Date: Sun, 2 Sep 2007 18:38:47 +0200 Subject: [PATCH] src/common.c: Copy the error-string to the buffer - no matter which implementation is used. --- src/common.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/common.c b/src/common.c index f8655a98..7555b7ef 100644 --- a/src/common.c +++ b/src/common.c @@ -77,7 +77,15 @@ char *sstrerror (int errnum, char *buf, size_t buflen) { buf[0] = '\0'; #ifdef STRERROR_R_CHAR_P - buf = strerror_r (errnum, buf, buflen); + { + char *temp; + temp = strerror_r (errnum, buf, buflen); + if (buf[0] == '\0') + { + strncpy (buf, temp, buflen); + buf[buflen - 1] = '\0'; + } + } #else strerror_r (errnum, buf, buflen); #endif /* STRERROR_R_CHAR_P */ -- 2.30.2