diff options
author | Joe Orton <jorton@apache.org> | 2004-09-09 15:22:31 +0000 |
---|---|---|
committer | Joe Orton <jorton@apache.org> | 2004-09-09 15:22:31 +0000 |
commit | 0832d3c78e60b228b40e97b63a741cfcf78eae92 (patch) | |
tree | 6cbf6e26d3b1762fbe3140ef5c54cb83de68284d | |
parent | df6d9b2e3fa068fa645949152a211c2aff48e9bc (diff) | |
download | apr-0832d3c78e60b228b40e97b63a741cfcf78eae92.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: https://svn.apache.org/repos/asf/apr/apr/branches/APR_0_9_BRANCH@65326 13f79535-47bb-0310-9956-ffa450edef68
-rw-r--r-- | misc/unix/errorcodes.c | 8 | ||||
-rw-r--r-- | test/teststr.c | 6 |
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 |