summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorjorton <jorton@13f79535-47bb-0310-9956-ffa450edef68>2004-09-09 15:22:31 +0000
committerjorton <jorton@13f79535-47bb-0310-9956-ffa450edef68>2004-09-09 15:22:31 +0000
commit40171930c29048beb2245403999fa6dd4a42a0dd (patch)
tree6cbf6e26d3b1762fbe3140ef5c54cb83de68284d
parent27c672f9969b3619731a9262098248a565414aac (diff)
downloadlibapr-40171930c29048beb2245403999fa6dd4a42a0dd.tar.gz
* misc/unix/errorcodes.c (native_strerror): Gracefully handle
strerror() returning NULL on Solaris. * test/teststr.c (string_error): Throw some randomish numbers at apr_strerror to check for robustness. git-svn-id: http://svn.apache.org/repos/asf/apr/apr/branches/APR_0_9_BRANCH@65326 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r--misc/unix/errorcodes.c8
-rw-r--r--test/teststr.c6
2 files changed, 13 insertions, 1 deletions
diff --git a/misc/unix/errorcodes.c b/misc/unix/errorcodes.c
index 9355c484f..46d7f8ab1 100644
--- a/misc/unix/errorcodes.c
+++ b/misc/unix/errorcodes.c
@@ -372,7 +372,13 @@ static char *native_strerror(apr_status_t statcode, char *buf,
sprintf(err, "Native Error #%d", statcode);
return stuffbuffer(buf, bufsize, err);
#else
- return stuffbuffer(buf, bufsize, strerror(statcode));
+ const char *err = strerror(statcode);
+ if (err) {
+ return stuffbuffer(buf, bufsize, err);
+ } else {
+ return stuffbuffer(buf, bufsize,
+ "APR does not understand this error code");
+ }
#endif
}
#endif
diff --git a/test/teststr.c b/test/teststr.c
index f2757de8f..c1049449c 100644
--- a/test/teststr.c
+++ b/test/teststr.c
@@ -163,6 +163,7 @@ static void snprintf_underflow(CuTest *tc)
static void string_error(CuTest *tc)
{
char buf[128], *rv;
+ apr_status_t n;
buf[0] = '\0';
rv = apr_strerror(APR_ENOENT, buf, sizeof buf);
@@ -172,6 +173,11 @@ static void string_error(CuTest *tc)
rv = apr_strerror(APR_TIMEUP, buf, sizeof buf);
CuAssertPtrEquals(tc, buf, rv);
CuAssertStrEquals(tc, "The timeout specified has expired", buf);
+
+ /* throw some randomish numbers at it to check for robustness */
+ for (n = 1; n < 1000000; n *= 2) {
+ apr_strerror(n, buf, sizeof buf);
+ }
}
#define SIZE 180000