public inbox for glibc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug libc/364] New: strerror_r does not copy error string to user supplied buffer
@ 2004-09-02 19:05 dancasimiro at alum dot rpi dot edu
  2004-09-02 19:07 ` [Bug libc/364] " dancasimiro at alum dot rpi dot edu
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: dancasimiro at alum dot rpi dot edu @ 2004-09-02 19:05 UTC (permalink / raw)
  To: glibc-bugs

According to the specification, strerror_r should copy the error string to the
user supplied buffer. 
(http://www.opengroup.org/onlinepubs/009695399/functions/strerror.html)

The current version of strerror_r does not copy *anything* unless there is a
problem.

-- 
           Summary: strerror_r does not copy error string to user supplied
                    buffer
           Product: glibc
           Version: 2.3.3
            Status: NEW
          Severity: minor
          Priority: P3
         Component: libc
        AssignedTo: gotom at debian dot or dot jp
        ReportedBy: dancasimiro at alum dot rpi dot edu
                CC: glibc-bugs at sources dot redhat dot com
 GCC build triplet: i686-pc-linux-gnu
  GCC host triplet: i686-pc-linux-gnu
GCC target triplet: i686-pc-linux-gnu


http://sources.redhat.com/bugzilla/show_bug.cgi?id=364

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


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

* [Bug libc/364] strerror_r does not copy error string to user supplied buffer
  2004-09-02 19:05 [Bug libc/364] New: strerror_r does not copy error string to user supplied buffer dancasimiro at alum dot rpi dot edu
@ 2004-09-02 19:07 ` dancasimiro at alum dot rpi dot edu
  2004-09-02 21:07 ` schwab at suse dot de
                   ` (4 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: dancasimiro at alum dot rpi dot edu @ 2004-09-02 19:07 UTC (permalink / raw)
  To: glibc-bugs


------- Additional Comments From dancasimiro at alum dot rpi dot edu  2004-09-02 19:07 -------
Created an attachment (id=184)
 --> (http://sources.redhat.com/bugzilla/attachment.cgi?id=184&action=view)
Implement correct behavior

This patch implements the expected behavior.  It copies as much of the error
string as fits into the user supplied buffer.

-- 


http://sources.redhat.com/bugzilla/show_bug.cgi?id=364

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


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

* [Bug libc/364] strerror_r does not copy error string to user supplied buffer
  2004-09-02 19:05 [Bug libc/364] New: strerror_r does not copy error string to user supplied buffer dancasimiro at alum dot rpi dot edu
  2004-09-02 19:07 ` [Bug libc/364] " dancasimiro at alum dot rpi dot edu
@ 2004-09-02 21:07 ` schwab at suse dot de
  2006-07-04 11:22 ` vda dot linux at googlemail dot com
                   ` (3 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: schwab at suse dot de @ 2004-09-02 21:07 UTC (permalink / raw)
  To: glibc-bugs


------- Additional Comments From schwab at suse dot de  2004-09-02 21:07 -------
You are looking at the GNU version of strerror_r, the POSIX version is 
implemented as __xpg_strerror_r. 

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


http://sources.redhat.com/bugzilla/show_bug.cgi?id=364

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


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

* [Bug libc/364] strerror_r does not copy error string to user supplied buffer
  2004-09-02 19:05 [Bug libc/364] New: strerror_r does not copy error string to user supplied buffer dancasimiro at alum dot rpi dot edu
  2004-09-02 19:07 ` [Bug libc/364] " dancasimiro at alum dot rpi dot edu
  2004-09-02 21:07 ` schwab at suse dot de
@ 2006-07-04 11:22 ` vda dot linux at googlemail dot com
  2006-07-04 11:40 ` jakub at redhat dot com
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 7+ messages in thread
From: vda dot linux at googlemail dot com @ 2006-07-04 11:22 UTC (permalink / raw)
  To: glibc-bugs


------- Additional Comments From vda dot linux at googlemail dot com  2006-07-04 11:22 -------
glibc 2.4 include/string.h says:

#if defined __USE_XOPEN2K || defined __USE_MISC
/* Reentrant version of `strerror'.
   There are 2 flavors of `strerror_r', GNU which returns the string
   and may or may not use the supplied temporary buffer and POSIX one
   which fills the string into the buffer.
   To use the POSIX version, -D_XOPEN_SOURCE=600 or -D_POSIX_C_SOURCE=200112L
   without -D_GNU_SOURCE is needed, otherwise the GNU version is
   preferred.  */
# if defined __USE_XOPEN2K && !defined __USE_GNU
/* Fill BUF with a string describing the meaning of the `errno' code in
   ERRNUM.  */
#  ifdef __REDIRECT_NTH
extern int __REDIRECT_NTH (strerror_r,
                           (int __errnum, char *__buf, size_t __buflen),
                           __xpg_strerror_r) __nonnull ((2));
#  else
extern int __xpg_strerror_r (int __errnum, char *__buf, size_t __buflen)
     __THROW __nonnull ((2));
#   define strerror_r __xpg_strerror_r
#  endif
# else
/* If a temporary buffer is required, at most BUFLEN bytes of BUF will be
   used.  */
extern char *strerror_r (int __errnum, char *__buf, size_t __buflen)
     __THROW __nonnull ((2));
# endif
#endif

Manpage says the same. However the testcase below shows that
POSIX version of strerr_r is selected _without_ -D_XOPEN_SOURCE=600
or -D_POSIX_C_SOURCE=200112L:

#include <errno.h>
#include <string.h>
#include <stdio.h>
main()
{
  int i;
  char buf[1024] = "junk";
  i = strerror_r(ERANGE, buf, 5);
  printf("%d:%s\n",i,buf);
  i = strerror_r(ERANGE, buf, 1024);
  printf("%d:%s\n",i,buf);
  return 0;
}

See? It returns int, not char*.

# ./a.out
-1:junk
0:Numerical result out of range


-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
         Resolution|INVALID                     |


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

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


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

* [Bug libc/364] strerror_r does not copy error string to user supplied buffer
  2004-09-02 19:05 [Bug libc/364] New: strerror_r does not copy error string to user supplied buffer dancasimiro at alum dot rpi dot edu
                   ` (2 preceding siblings ...)
  2006-07-04 11:22 ` vda dot linux at googlemail dot com
@ 2006-07-04 11:40 ` jakub at redhat dot com
  2006-07-04 11:57 ` vda dot linux at googlemail dot com
  2006-07-04 13:32 ` vda dot linux at googlemail dot com
  5 siblings, 0 replies; 7+ messages in thread
From: jakub at redhat dot com @ 2006-07-04 11:40 UTC (permalink / raw)
  To: glibc-bugs


------- Additional Comments From jakub at redhat dot com  2006-07-04 11:39 -------
Why are you reopening this?  Man pages aren't included in glibc.
Yes, glibc 2.4 if no feature test macros are specified defaults to
_POSIX_C_SOURCE 200112L, unlike older glibcs.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|REOPENED                    |RESOLVED
         Resolution|                            |INVALID


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

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


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

* [Bug libc/364] strerror_r does not copy error string to user supplied buffer
  2004-09-02 19:05 [Bug libc/364] New: strerror_r does not copy error string to user supplied buffer dancasimiro at alum dot rpi dot edu
                   ` (3 preceding siblings ...)
  2006-07-04 11:40 ` jakub at redhat dot com
@ 2006-07-04 11:57 ` vda dot linux at googlemail dot com
  2006-07-04 13:32 ` vda dot linux at googlemail dot com
  5 siblings, 0 replies; 7+ messages in thread
From: vda dot linux at googlemail dot com @ 2006-07-04 11:57 UTC (permalink / raw)
  To: glibc-bugs


------- Additional Comments From vda dot linux at googlemail dot com  2006-07-04 11:57 -------
Because I'm tracking down obscure bug in svn (seemingly),
and tracked it down to strerror_r not updating buffer 
and _not_ returning -1.

From: Denis Vlasenko <vda.linux@googlemail.com>
To: Malcolm Rowe <malcolm-svn-dev@farside.org.uk>
Subject: Re: BUG: svn enters unkillable state, tracked down to UTF conv in locale!=C
Date: Tue, 4 Jul 2006 13:53:59 +0200

> If your native_strerror() looks like that, you must have STRERROR_R_RC_INT
> defined (in APR's include/arch/unix/apr_private.h), which implies you're
> using the platform-native C library for either AIX or Tru64 (from the
> comments in the above file).
>
> I thought you were using glibc?  What OS are you using?

It _is_ glibc 2.4. Looks like glibc people switched to POSIX version
of strerror_r. See here:

http://sources.redhat.com/bugzilla/show_bug.cgi?id=364

But sometimes it returns >=0, yet buffer is not modified.

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
         Resolution|INVALID                     |


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

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


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

* [Bug libc/364] strerror_r does not copy error string to user supplied buffer
  2004-09-02 19:05 [Bug libc/364] New: strerror_r does not copy error string to user supplied buffer dancasimiro at alum dot rpi dot edu
                   ` (4 preceding siblings ...)
  2006-07-04 11:57 ` vda dot linux at googlemail dot com
@ 2006-07-04 13:32 ` vda dot linux at googlemail dot com
  5 siblings, 0 replies; 7+ messages in thread
From: vda dot linux at googlemail dot com @ 2006-07-04 13:32 UTC (permalink / raw)
  To: glibc-bugs


------- Additional Comments From vda dot linux at googlemail dot com  2006-07-04 13:32 -------
Okay, it was svn playing some silly tricks with supplying it's own prototypes.
svn ended up linking against wrong flavor of strerror_r...

-- 
           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|REOPENED                    |RESOLVED
         Resolution|                            |INVALID


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

------- You are receiving this mail because: -------
You are on the CC list for the bug, or are watching someone who is.


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

end of thread, other threads:[~2006-07-04 13:32 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2004-09-02 19:05 [Bug libc/364] New: strerror_r does not copy error string to user supplied buffer dancasimiro at alum dot rpi dot edu
2004-09-02 19:07 ` [Bug libc/364] " dancasimiro at alum dot rpi dot edu
2004-09-02 21:07 ` schwab at suse dot de
2006-07-04 11:22 ` vda dot linux at googlemail dot com
2006-07-04 11:40 ` jakub at redhat dot com
2006-07-04 11:57 ` vda dot linux at googlemail dot com
2006-07-04 13:32 ` vda dot linux at googlemail 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).