apr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Joe Orton <jor...@redhat.com>
Subject Re: [Fwd: [mp2] coredump strerror code on Solaris 8
Date Thu, 09 Sep 2004 08:15:43 GMT
On Wed, Sep 08, 2004 at 06:18:49PM -0400, Stas Bekman wrote:
> But normally apr_strerror(500, buf, 256) returns "not specified error" 
> string or something like that, which is cool. Why does it segfault is what 
> I can't understand. Notice that it doesn't happen on linux.

strerror(500) will return NULL on Solaris which APR does not expect (and
the standards seem to say is wrong behaviour too for what that's worth).

This patch should fix the issue, thanks for the report:

Index: errorcodes.c
===================================================================
RCS file: /home/cvs/apr/misc/unix/errorcodes.c,v
retrieving revision 1.55.2.2
diff -u -r1.55.2.2 errorcodes.c
--- errorcodes.c	13 Feb 2004 09:33:49 -0000	1.55.2.2
+++ errorcodes.c	9 Sep 2004 08:11:32 -0000
@@ -372,7 +372,13 @@
     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


Mime
View raw message