summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 2a9fc51)
raw | patch | inline | side by side (parent: 2a9fc51)
author | Florian Forster <octo@leeloo.lan.home.verplant.org> | |
Mon, 3 Sep 2007 12:44:53 +0000 (14:44 +0200) | ||
committer | Florian Forster <octo@leeloo.lan.home.verplant.org> | |
Mon, 3 Sep 2007 12:44:53 +0000 (14:44 +0200) |
I don't trust this GNU implementation one bit.. ;)
src/common.c | patch | blob | history |
diff --git a/src/common.c b/src/common.c
index 7555b7ef99d26150d81193ce7e1d4d1a8e3a4b33..951bae306e834d15f3b7d1e66fb217740bedaff0 100644 (file)
--- a/src/common.c
+++ b/src/common.c
temp = strerror_r (errnum, buf, buflen);
if (buf[0] == '\0')
{
- strncpy (buf, temp, buflen);
+ if ((temp != NULL) && (temp != buf) && (temp[0] != '\0'))
+ strncpy (buf, temp, buflen);
+ else
+ strncpy (buf, "strerror_r did not return "
+ "an error message", buflen);
buf[buflen - 1] = '\0';
}
}
#else
- strerror_r (errnum, buf, buflen);
+ if (strerror_r (errnum, buf, buflen) != 0)
+ {
+ snprintf (buf, buflen, "Error #%i; "
+ "Additionally, strerror_r failed.",
+ errnum);
+ }
#endif /* STRERROR_R_CHAR_P */
+ buf[buflen - 1] = '\0';
return (buf);
} /* char *sstrerror */