On Tue, Feb 06, 2007 at 06:32:25PM -0600, Matthew Woehlke wrote:
> From noticing the testsuite failure, I found what looks like a bug in
> ne_strerror. On x86 Solaris, strerror_r does not truncate strings.
> Instead, it returns 34 (ERANGE) if the buffer is not large enough (the
> man page here is not helpful, although the letter of the doc clearly
> allows this behavior).
>
> Only way I can think of to fix this is to check for the failure, and it
> a failure occurs, to alloc a larger buffer and retry until strerror_r
> succeeds, and then play like it was glibc's strerror and strncpy the
> result back into the original buffer (this time truncating it).
Thanks for the report - it's simpler to just use a temp buffer anyway;
I've applied this:
Index: src/ne_string.c
===================================================================
--- src/ne_string.c (revision 1148)
+++ src/ne_string.c (working copy)
@@ -349,7 +349,11 @@
if (ret != buf)
ne_strnzcpy(buf, ret, buflen);
#else /* POSIX-style strerror_r: */
- strerror_r(errnum, buf, buflen);
+ char tmp[256];
+ if (strerror_r(errnum, tmp, sizeof tmp) == 0)
+ ne_strnzcpy(buf, tmp, buflen);
+ else
+ ne_snprintf(buf, buflen, "Unknown error %d", errnum);
#endif
#else /* no strerror_r: */
ne_strnzcpy(buf, strerror(errnum), buflen);
_______________________________________________
neon mailing list
[email protected]
http://mailman.webdav.org/mailman/listinfo/neon