From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 326 invoked by alias); 4 Jul 2006 11:22:59 -0000 Received: (qmail 32765 invoked by uid 48); 4 Jul 2006 11:22:49 -0000 Date: Tue, 04 Jul 2006 11:22:00 -0000 Message-ID: <20060704112249.32764.qmail@sourceware.org> From: "vda dot linux at googlemail dot com" To: glibc-bugs@sources.redhat.com In-Reply-To: <20040902190535.364.dancasimiro@alum.rpi.edu> References: <20040902190535.364.dancasimiro@alum.rpi.edu> Reply-To: sourceware-bugzilla@sourceware.org Subject: [Bug libc/364] strerror_r does not copy error string to user supplied buffer X-Bugzilla-Reason: CC Mailing-List: contact glibc-bugs-help@sourceware.org; run by ezmlm Precedence: bulk List-Subscribe: List-Post: List-Help: , Sender: glibc-bugs-owner@sourceware.org X-SW-Source: 2006-07/txt/msg00006.txt.bz2 List-Id: ------- 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 #include #include 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.