From: Florian Forster Date: Sun, 2 Sep 2007 16:38:47 +0000 (+0200) Subject: src/common.c: Copy the error-string to the buffer - no matter which implementation... X-Git-Tag: collectd-4.0.8~13 X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=c48289c6d14aadd1aca41a1c93122b5ba399bf0b;p=collectd.git src/common.c: Copy the error-string to the buffer - no matter which implementation is used. --- 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 */