strerror_r: fix OpenBSD behavior on out-of-range
authorEric Blake <eblake@redhat.com>
Tue, 21 Jun 2011 16:00:55 +0000 (10:00 -0600)
committerEric Blake <eblake@redhat.com>
Tue, 21 Jun 2011 17:06:12 +0000 (11:06 -0600)
commit23d3c1a2676b1aa6cb1388891485de846d7435d8
tree63bb81715217cae66c602305cb36a582546ff821
parentc74873191b6e585cdd5a3b2ce5e07edae1427cef
strerror_r: fix OpenBSD behavior on out-of-range

On OpenBSD, strerror_r(1000,buf,19) gives "Unknown error: " rather
than "Unknown error: 100" while failing with ERANGE.  Admittedly,
this behavior is nice, since a truncated integer is misleading,
but all other platforms use maximal strings on ERANGE and we are
already replacing strerror_r for other reasons, so it is easier
to work around this behavior than to adjust the testsuite (how
do you quickly decide if the only reason that the ERANGE string
was shorter than maximal was because the implementation avoided
truncating an integer?).

This patch intentionally avoids dragging in the strnlen module.

* lib/strerror_r.c (strerror_r): Always use maximal string.
* doc/posix-functions/strerror_r.texi (strerror_r): Document it.

Signed-off-by: Eric Blake <eblake@redhat.com>
ChangeLog
doc/posix-functions/strerror_r.texi
lib/strerror_r.c