Code

src/common.c: Copy the error-string to the buffer - no matter which implementation...
authorFlorian Forster <octo@leeloo.lan.home.verplant.org>
Sun, 2 Sep 2007 16:38:47 +0000 (18:38 +0200)
committerFlorian Forster <octo@leeloo.lan.home.verplant.org>
Sun, 2 Sep 2007 16:38:47 +0000 (18:38 +0200)
src/common.c

index f8655a98ee5e33fd2b0621d884e1073cd193f462..7555b7ef99d26150d81193ce7e1d4d1a8e3a4b33 100644 (file)
@@ -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 */