public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libc/12782] New: POSIX strerror_r quality of implementation
@ 2011-05-18 23:33 eblake at redhat dot com
  2011-05-18 23:34 ` [Bug libc/12782] " eblake at redhat dot com
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: eblake at redhat dot com @ 2011-05-18 23:33 UTC (permalink / raw)
  To: glibc-bugs

http://sourceware.org/bugzilla/show_bug.cgi?id=12782

           Summary: POSIX strerror_r quality of implementation
           Product: glibc
           Version: 2.13
            Status: NEW
          Severity: normal
          Priority: P2
         Component: libc
        AssignedTo: drepper.fsp@gmail.com
        ReportedBy: eblake@redhat.com


Although POSIX permits 'buf' to remain untouched on error, it does not require
this; in fact, it recommends that buf still be populated insofar as possible
for a better quality of implementation (since applications are likely to use
the contents of buffer without checking for errors).  Furthermore, this is more
in line with what glibc does for GNU strerror_r (a useful result at all costs,
even if the result had to be truncated):

XSH line 63300:

"Similarly, implementations are encouraged to have strerror_r( ) return
[EINVAL] and put a string like "unknown error" or "error number xxx" in the
buffer pointed to by strerrbuf when the value of errnum is not a valid error
number."

and http://austingroupbugs.net/view.php?id=398:

"Additionally, implementations are encouraged to NUL-terminate strerrbuf
when failing with ERANGE for any size other than buflen of zero."

If you use the example program of
http://sourceware.org/bugzilla/show_bug.cgi?id=12204, then I argue that the
results on glibc should be:

result: failure 22 Unknown error 18446744073709551614
result: failure 34 Pe

rather than Bruno's claim of

result: failure 22 ______
result: failure 34 ______

Additionally, that bug showed prior art of other platforms that (almost) have
this QoI issue resolved according to POSIX recommendations:

FreeBSD 6.4 (albeit buggy for returning EINVAL on 0), AIX 6.1 (albeit buggy for
not returning ERANGE on short buffer), Tru64 5.1 (albeit buggy for wrong return
values).

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug libc/12782] POSIX strerror_r quality of implementation
  2011-05-18 23:33 [Bug libc/12782] New: POSIX strerror_r quality of implementation eblake at redhat dot com
@ 2011-05-18 23:34 ` eblake at redhat dot com
  2011-05-18 23:36 ` eblake at redhat dot com
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: eblake at redhat dot com @ 2011-05-18 23:34 UTC (permalink / raw)
  To: glibc-bugs

http://sourceware.org/bugzilla/show_bug.cgi?id=12782

Eric Blake <eblake at redhat dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
         Depends on|                            |12204

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug libc/12782] POSIX strerror_r quality of implementation
  2011-05-18 23:33 [Bug libc/12782] New: POSIX strerror_r quality of implementation eblake at redhat dot com
  2011-05-18 23:34 ` [Bug libc/12782] " eblake at redhat dot com
@ 2011-05-18 23:36 ` eblake at redhat dot com
  2011-05-21 16:13 ` drepper.fsp at gmail dot com
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: eblake at redhat dot com @ 2011-05-18 23:36 UTC (permalink / raw)
  To: glibc-bugs

http://sourceware.org/bugzilla/show_bug.cgi?id=12782

--- Comment #1 from Eric Blake <eblake at redhat dot com> 2011-05-18 23:35:55 UTC ---
Created attachment 5736
  --> http://sourceware.org/bugzilla/attachment.cgi?id=5736
proposed patch

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug libc/12782] POSIX strerror_r quality of implementation
  2011-05-18 23:33 [Bug libc/12782] New: POSIX strerror_r quality of implementation eblake at redhat dot com
  2011-05-18 23:34 ` [Bug libc/12782] " eblake at redhat dot com
  2011-05-18 23:36 ` eblake at redhat dot com
@ 2011-05-21 16:13 ` drepper.fsp at gmail dot com
  2011-05-21 17:21 ` bruno at clisp dot org
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: drepper.fsp at gmail dot com @ 2011-05-21 16:13 UTC (permalink / raw)
  To: glibc-bugs

http://sourceware.org/bugzilla/show_bug.cgi?id=12782

Ulrich Drepper <drepper.fsp at gmail dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED

--- Comment #2 from Ulrich Drepper <drepper.fsp at gmail dot com> 2011-05-21 16:12:46 UTC ---
I've applied a simpler patch.

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug libc/12782] POSIX strerror_r quality of implementation
  2011-05-18 23:33 [Bug libc/12782] New: POSIX strerror_r quality of implementation eblake at redhat dot com
                   ` (2 preceding siblings ...)
  2011-05-21 16:13 ` drepper.fsp at gmail dot com
@ 2011-05-21 17:21 ` bruno at clisp dot org
  2012-06-30 16:12 ` bruno at clisp dot org
  2014-06-27 13:20 ` fweimer at redhat dot com
  5 siblings, 0 replies; 7+ messages in thread
From: bruno at clisp dot org @ 2011-05-21 17:21 UTC (permalink / raw)
  To: glibc-bugs

http://sourceware.org/bugzilla/show_bug.cgi?id=12782

Bruno Haible <bruno at clisp dot org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |bruno at clisp dot org

--- Comment #3 from Bruno Haible <bruno at clisp dot org> 2011-05-21 17:21:18 UTC ---
The new code at
http://sourceware.org/git/?p=glibc.git;a=blob;f=string/xpg-strerror.c;h=00256c3dac2591e99b504c97b05945e27aefecce;hb=7ea72f99966a65a56aedba817ee2413ff9b1f23c
has three flaws:

- It overwrites buf[0] when buflen == 0. This is an out-of-bounds access.

- If errnum is invalid, it wastes time calling __strerror_r and strlen
  before then returning EINVAL and ignoring the result of __strerror_r.

- It includes <libintl.h> and <locale.h> and defines dgettext(), although
  these are not needed any more, because the localization is now done by
  __strerror_r.

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug libc/12782] POSIX strerror_r quality of implementation
  2011-05-18 23:33 [Bug libc/12782] New: POSIX strerror_r quality of implementation eblake at redhat dot com
                   ` (3 preceding siblings ...)
  2011-05-21 17:21 ` bruno at clisp dot org
@ 2012-06-30 16:12 ` bruno at clisp dot org
  2014-06-27 13:20 ` fweimer at redhat dot com
  5 siblings, 0 replies; 7+ messages in thread
From: bruno at clisp dot org @ 2012-06-30 16:12 UTC (permalink / raw)
  To: glibc-bugs

http://sourceware.org/bugzilla/show_bug.cgi?id=12782

--- Comment #4 from Bruno Haible <bruno at clisp dot org> 2012-06-30 16:11:50 UTC ---
The first and third reported flaw were fixed by Ulrich in
http://sourceware.org/git/?p=glibc.git;a=commitdiff;h=adcd5c15d2a37794d021104160b425ff61f88219

For the second one, see bug 14317.

-- 
Configure bugmail: http://sourceware.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 7+ messages in thread

* [Bug libc/12782] POSIX strerror_r quality of implementation
  2011-05-18 23:33 [Bug libc/12782] New: POSIX strerror_r quality of implementation eblake at redhat dot com
                   ` (4 preceding siblings ...)
  2012-06-30 16:12 ` bruno at clisp dot org
@ 2014-06-27 13:20 ` fweimer at redhat dot com
  5 siblings, 0 replies; 7+ messages in thread
From: fweimer at redhat dot com @ 2014-06-27 13:20 UTC (permalink / raw)
  To: glibc-bugs

https://sourceware.org/bugzilla/show_bug.cgi?id=12782

Florian Weimer <fweimer at redhat dot com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
              Flags|                            |security-

-- 
You are receiving this mail because:
You are on the CC list for the bug.


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2014-06-27 13:20 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-05-18 23:33 [Bug libc/12782] New: POSIX strerror_r quality of implementation eblake at redhat dot com
2011-05-18 23:34 ` [Bug libc/12782] " eblake at redhat dot com
2011-05-18 23:36 ` eblake at redhat dot com
2011-05-21 16:13 ` drepper.fsp at gmail dot com
2011-05-21 17:21 ` bruno at clisp dot org
2012-06-30 16:12 ` bruno at clisp dot org
2014-06-27 13:20 ` fweimer at redhat dot com

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).