From jakub@redhat.com Tue Mar 4 15:51:00 2008 From: jakub@redhat.com (Jakub Jelinek) Date: Tue, 04 Mar 2008 15:51:00 -0000 Subject: [PATCH] Fortify {,v}{as,d}printf and obstack_{,v}printf Message-ID: <20080304155729.GI3726@sunsite.mff.cuni.cz> Hi! The following patch fortifies these 6 functions with -D_FORTIFY_SOURCE=2 to make sure %n in format string is only used if the format string is not writable. Tested on x86_64-linux and ppc-linux (the latter mainly to test the long double stuff). 2008-03-04 Jakub Jelinek * include/stdio.h (__asprintf_chk, __dprintf_chk, __obstack_printf_chk): New prototypes. (__vasprintf_chk, __vdprintf_chk, __obstack_vprintf_chk): Likewise. Add libc_hidden_proto. * libio/obprintf.c (_IO_obstack_jumps): No longer static, add attribute_hidden. * libio/bits/stdio-ldbl.h (__asprintf_chk, __dprintf_chk, __obstack_printf_chk, __vasprintf_chk, __vdprintf_chk, __obstack_vprintf_chk): Add __LDBL_REDIR_DECL. * libio/bits/stdio2.h (__asprintf_chk, __dprintf_chk, __obstack_printf_chk, __vasprintf_chk, __vdprintf_chk, __obstack_vprintf_chk): New prototypes. (asprintf, __asprintf, dprintf, obstack_printf, vasprintf, vdprintf, obstack_vprintf): New inlines. * debug/dprintf_chk.c: New file. * debug/vdprintf_chk.c: New file. * debug/asprintf_chk.c: New file. * debug/vasprintf_chk.c: New file. * debug/obprintf_chk.c: New file. * debug/tst-chk1.c (do_test): Add asprintf and obstack_printf tests. * debug/Versions (__asprintf_chk, __dprintf_chk, __obstack_printf_chk, __vasprintf_chk, __vdprintf_chk, __obstack_vprintf_chk): Export @@GLIBC_2.8. * debug/Makefile: Build asprintf_chk, vasprintf_chk, dprintf_chk, vdprintf_chk and obprintf_chk, set CFLAGS for them. * sysdeps/ieee754/ldbl-opt/nldbl-compat.c (__nldbl___vasprintf_chk, __nldbl___vdprintf_chk, __nldbl___obstack_vprintf_chk): Add libc_hidden_proto. * sysdeps/ieee754/ldbl-opt/nldbl-compat.h (__nldbl___vasprintf_chk, __nldbl___vdprintf_chk, __nldbl___obstack_vprintf_chk): New prototypes. * sysdeps/ieee754/ldbl-opt/Versions (__nldbl___asprintf_chk, __nldbl___vasprintf_chk, __nldbl___dprintf_chk, __nldbl___vdprintf_chk, __nldbl___obstack_printf_chk, __nldbl___obstack_vprintf_chk): Export @@GLIBC_2.8. * sysdeps/ieee754/ldbl-opt/Makefile (libnldbl-calls): Add asprintf_chk, vasprintf_chk, dprintf_chk, vdprintf_chk, obstack_printf_chk and obstack_vprintf_chk. * sysdeps/ieee754/ldbl-opt/nldbl-obstack_vprintf_chk.c: New file. * sysdeps/ieee754/ldbl-opt/nldbl-dprintf_chk.c: New file. * sysdeps/ieee754/ldbl-opt/nldbl-obstack_printf_chk.c: New file. * sysdeps/ieee754/ldbl-opt/nldbl-asprintf_chk.c: New file. * sysdeps/ieee754/ldbl-opt/nldbl-vdprintf_chk.c: New file. * sysdeps/ieee754/ldbl-opt/nldbl-vasprintf_chk.c: New file. --- libc/include/stdio.h.jj 2007-10-16 10:20:13.000000000 +0200 +++ libc/include/stdio.h 2008-03-04 12:58:36.000000000 +0100 @@ -41,6 +41,14 @@ extern int __vprintf_chk (int, const cha extern int __vfprintf_chk (FILE *, int, const char *, _G_va_list); extern char *__fgets_unlocked_chk (char *buf, size_t size, int n, FILE *fp); extern char *__fgets_chk (char *buf, size_t size, int n, FILE *fp); +extern int __asprintf_chk (char **, int, const char *, ...) __THROW; +extern int __vasprintf_chk (char **, int, const char *, _G_va_list) __THROW; +extern int __dprintf_chk (int, int, const char *, ...); +extern int __vdprintf_chk (int, int, const char *, _G_va_list); +extern int __obstack_printf_chk (struct obstack *, int, const char *, ...) + __THROW; +extern int __obstack_vprintf_chk (struct obstack *, int, const char *, + _G_va_list) __THROW; #endif extern int __isoc99_fscanf (FILE *__restrict __stream, @@ -149,6 +157,9 @@ libc_hidden_proto (__libc_fatal) libc_hidden_proto (__vsprintf_chk) libc_hidden_proto (__vsnprintf_chk) libc_hidden_proto (__vfprintf_chk) +libc_hidden_proto (__vasprintf_chk) +libc_hidden_proto (__vdprintf_chk) +libc_hidden_proto (__obstack_vprintf_chk) # if !defined NOT_IN_libc && defined SHARED && defined DO_VERSIONING \ && !defined NO_HIDDEN --- libc/libio/obprintf.c.jj 2006-01-14 13:09:46.000000000 +0100 +++ libc/libio/obprintf.c 2008-03-04 11:56:37.000000000 +0100 @@ -1,5 +1,5 @@ /* Print output of stream to given obstack. - Copyright (C) 1996,1997,1999,2000,2001,2002,2003,2004,2005,2006 + Copyright (C) 1996,1997,1999,2000,2001,2002,2003,2004,2005,2006,2008 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper , 1996. @@ -95,7 +95,7 @@ _IO_obstack_xsputn (_IO_FILE *fp, const /* the jump table. */ -static const struct _IO_jump_t _IO_obstack_jumps = +const struct _IO_jump_t _IO_obstack_jumps attribute_hidden = { JUMP_INIT_DUMMY, JUMP_INIT(finish, NULL), --- libc/libio/bits/stdio-ldbl.h.jj 2007-09-18 21:24:15.000000000 +0200 +++ libc/libio/bits/stdio-ldbl.h 2008-03-04 12:23:55.000000000 +0100 @@ -1,5 +1,5 @@ /* -mlong-double-64 compatibility mode for stdio functions. - Copyright (C) 2006, 2007 Free Software Foundation, Inc. + Copyright (C) 2006, 2007, 2008 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -85,5 +85,13 @@ __LDBL_REDIR_DECL (__fprintf_chk) __LDBL_REDIR_DECL (__printf_chk) __LDBL_REDIR_DECL (__vfprintf_chk) __LDBL_REDIR_DECL (__vprintf_chk) +# ifdef __USE_GNU +__LDBL_REDIR_DECL (__asprintf_chk) +__LDBL_REDIR_DECL (__vasprintf_chk) +__LDBL_REDIR_DECL (__dprintf_chk) +__LDBL_REDIR_DECL (__vdprintf_chk) +__LDBL_REDIR_DECL (__obstack_printf_chk) +__LDBL_REDIR_DECL (__obstack_vprintf_chk) +# endif # endif #endif --- libc/libio/bits/stdio2.h.jj 2007-09-29 20:51:56.000000000 +0200 +++ libc/libio/bits/stdio2.h 2008-03-04 14:17:02.000000000 +0100 @@ -1,5 +1,5 @@ /* Checking macros for stdio functions. - Copyright (C) 2004, 2005, 2007 Free Software Foundation, Inc. + Copyright (C) 2004, 2005, 2007, 2008 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -128,6 +128,93 @@ vfprintf (FILE *__restrict __stream, return __vfprintf_chk (__stream, __USE_FORTIFY_LEVEL - 1, __fmt, __ap); } +# ifdef __USE_GNU + +extern int __asprintf_chk (char **__restrict __ptr, int __flag, + __const char *__restrict __fmt, ...) + __THROW __attribute__ ((__format__ (__printf__, 3, 4))) __wur; +extern int __vasprintf_chk (char **__restrict __ptr, int __flag, + __const char *__restrict __fmt, _G_va_list __arg) + __THROW __attribute__ ((__format__ (__printf__, 3, 0))) __wur; +extern int __dprintf_chk (int __fd, int __flag, __const char *__restrict __fmt, + ...) __attribute__ ((__format__ (__printf__, 3, 4))); +extern int __vdprintf_chk (int __fd, int __flag, + __const char *__restrict __fmt, _G_va_list __arg) + __attribute__ ((__format__ (__printf__, 3, 0))); +extern int __obstack_printf_chk (struct obstack *__restrict __obstack, + int __flag, __const char *__restrict __format, + ...) + __THROW __attribute__ ((__format__ (__printf__, 3, 4))); +extern int __obstack_vprintf_chk (struct obstack *__restrict __obstack, + int __flag, + __const char *__restrict __format, + _G_va_list __args) + __THROW __attribute__ ((__format__ (__printf__, 3, 0))); + +# ifdef __va_arg_pack +__extern_always_inline int +__NTH (asprintf (char **__restrict __ptr, __const char *__restrict __fmt, ...)) +{ + return __asprintf_chk (__ptr, __USE_FORTIFY_LEVEL - 1, __fmt, + __va_arg_pack ()); +} + +__extern_always_inline int +__NTH (__asprintf (char **__restrict __ptr, __const char *__restrict __fmt, + ...)) +{ + return __asprintf_chk (__ptr, __USE_FORTIFY_LEVEL - 1, __fmt, + __va_arg_pack ()); +} + +__extern_always_inline int +dprintf (int __fd, __const char *__restrict __fmt, ...) +{ + return __dprintf_chk (__fd, __USE_FORTIFY_LEVEL - 1, __fmt, + __va_arg_pack ()); +} + +__extern_always_inline int +__NTH (obstack_printf (struct obstack *__restrict __obstack, + __const char *__restrict __fmt, ...)) +{ + return __obstack_printf_chk (__obstack, __USE_FORTIFY_LEVEL - 1, __fmt, + __va_arg_pack ()); +} +# elif !defined __cplusplus +# define asprintf(ptr, ...) \ + __asprintf_chk (ptr, __USE_FORTIFY_LEVEL - 1, __VA_ARGS__) +# define __asprintf(ptr, ...) \ + __asprintf_chk (ptr, __USE_FORTIFY_LEVEL - 1, __VA_ARGS__) +# define dprintf(fd, ...) \ + __dprintf_chk (fd, __USE_FORTIFY_LEVEL - 1, __VA_ARGS__) +# define obstack_printf(obstack, ...) \ + __obstack_printf_chk (obstack, __USE_FORTIFY_LEVEL - 1, __VA_ARGS__) +# endif + +__extern_always_inline int +__NTH (vasprintf (char **__restrict __ptr, __const char *__restrict __fmt, + _G_va_list __ap)) +{ + return __vasprintf_chk (__ptr, __USE_FORTIFY_LEVEL - 1, __fmt, __ap); +} + +__extern_always_inline int +vdprintf (int __fd, __const char *__restrict __fmt, _G_va_list __ap) +{ + return __vdprintf_chk (__fd, __USE_FORTIFY_LEVEL - 1, __fmt, __ap); +} + +__extern_always_inline int +__NTH (obstack_vprintf (struct obstack *__restrict __obstack, + __const char *__restrict __fmt, _G_va_list __ap)) +{ + return __obstack_vprintf_chk (__obstack, __USE_FORTIFY_LEVEL - 1, __fmt, + __ap); +} + +# endif + #endif extern char *__gets_chk (char *__str, size_t) __wur; --- libc/debug/dprintf_chk.c.jj 2008-03-04 11:51:31.000000000 +0100 +++ libc/debug/dprintf_chk.c 2008-03-04 13:22:54.000000000 +0100 @@ -0,0 +1,37 @@ +/* Copyright (C) 1991, 1995, 1997, 1998, 2004, 2006, 2008 + Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#include +#include +#include + + +/* Write formatted output to D, according to the format string FORMAT. */ +int +__dprintf_chk (int d, int flags, const char *format, ...) +{ + va_list arg; + int done; + + va_start (arg, format); + done = __vdprintf_chk (d, flags, format, arg); + va_end (arg); + + return done; +} --- libc/debug/vdprintf_chk.c.jj 2008-03-04 11:45:28.000000000 +0100 +++ libc/debug/vdprintf_chk.c 2008-03-04 14:07:43.000000000 +0100 @@ -0,0 +1,69 @@ +/* Copyright (C) 1995, 1997-2000, 2001, 2002, 2003, 2006, 2008 + Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. + + As a special exception, if you link the code in this file with + files compiled with a GNU compiler to produce an executable, + that does not cause the resulting executable to be covered by + the GNU Lesser General Public License. This exception does not + however invalidate any other reasons why the executable file + might be covered by the GNU Lesser General Public License. + This exception applies to code released by its copyright holders + in files containing the exception. */ + +#include +#include + +int +__vdprintf_chk (int d, int flags, const char *format, va_list arg) +{ + struct _IO_FILE_plus tmpfil; + struct _IO_wide_data wd; + int done; + +#ifdef _IO_MTSAFE_IO + tmpfil.file._lock = NULL; +#endif + _IO_no_init (&tmpfil.file, _IO_USER_LOCK, 0, &wd, &_IO_wfile_jumps); + _IO_JUMPS (&tmpfil) = &_IO_file_jumps; + INTUSE(_IO_file_init) (&tmpfil); +#if !_IO_UNIFIED_JUMPTABLES + tmpfil.vtable = NULL; +#endif + if (INTUSE(_IO_file_attach) (&tmpfil.file, d) == NULL) + { + INTUSE(_IO_un_link) (&tmpfil); + return EOF; + } + tmpfil.file._IO_file_flags = + (_IO_mask_flags (&tmpfil.file, _IO_NO_READS, + _IO_NO_READS+_IO_NO_WRITES+_IO_IS_APPENDING) + | _IO_DELETE_DONT_CLOSE); + + /* For flags > 0 (i.e. __USE_FORTIFY_LEVEL > 1) request that %n + can only come from read-only format strings. */ + if (flags > 0) + tmpfil.file._flags2 |= _IO_FLAGS2_FORTIFY; + + done = INTUSE(_IO_vfprintf) (&tmpfil.file, format, arg); + + _IO_FINISH (&tmpfil.file); + + return done; +} +libc_hidden_def (__vdprintf_chk) --- libc/debug/asprintf_chk.c.jj 2008-03-04 11:23:43.000000000 +0100 +++ libc/debug/asprintf_chk.c 2008-03-04 13:23:03.000000000 +0100 @@ -0,0 +1,38 @@ +/* Copyright (C) 1991, 1995, 1997, 1998, 2004, 2006, 2008 + Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#include +#include +#include + + +/* Write formatted output from FORMAT to a string which is + allocated with malloc and stored in *STRING_PTR. */ +int +__asprintf_chk (char **result_ptr, int flags, const char *format, ...) +{ + va_list arg; + int done; + + va_start (arg, format); + done = __vasprintf_chk (result_ptr, flags, format, arg); + va_end (arg); + + return done; +} --- libc/debug/vasprintf_chk.c.jj 2008-03-04 11:17:47.000000000 +0100 +++ libc/debug/vasprintf_chk.c 2008-03-04 13:24:14.000000000 +0100 @@ -0,0 +1,97 @@ +/* Copyright (C) 1995,1997,1999-2002,2004,2006,2008 + Free Software Foundation, Inc. + This file is part of the GNU C Library. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. + + As a special exception, if you link the code in this file with + files compiled with a GNU compiler to produce an executable, + that does not cause the resulting executable to be covered by + the GNU Lesser General Public License. This exception does not + however invalidate any other reasons why the executable file + might be covered by the GNU Lesser General Public License. + This exception applies to code released by its copyright holders + in files containing the exception. */ + +#include +#include +#include +#include +#include "../libio/libioP.h" +#include "../libio/strfile.h" + +int +__vasprintf_chk (char **result_ptr, int flags, const char *format, + va_list args) +{ + /* Initial size of the buffer to be used. Will be doubled each time an + overflow occurs. */ + const _IO_size_t init_string_size = 100; + char *string; + _IO_strfile sf; + int ret; + _IO_size_t needed; + _IO_size_t allocated; + /* No need to clear the memory here (unlike for open_memstream) since + we know we will never seek on the stream. */ + string = (char *) malloc (init_string_size); + if (string == NULL) + return -1; +#ifdef _IO_MTSAFE_IO + sf._sbf._f._lock = NULL; +#endif + _IO_no_init ((_IO_FILE *) &sf._sbf, _IO_USER_LOCK, -1, NULL, NULL); + _IO_JUMPS ((struct _IO_FILE_plus *) &sf._sbf) = &_IO_str_jumps; + _IO_str_init_static_internal (&sf, string, init_string_size, string); + sf._sbf._f._flags &= ~_IO_USER_BUF; + sf._s._allocate_buffer = (_IO_alloc_type) malloc; + sf._s._free_buffer = (_IO_free_type) free; + + /* For flags > 0 (i.e. __USE_FORTIFY_LEVEL > 1) request that %n + can only come from read-only format strings. */ + if (flags > 0) + sf._sbf._f._flags2 |= _IO_FLAGS2_FORTIFY; + + ret = INTUSE(_IO_vfprintf) (&sf._sbf._f, format, args); + if (ret < 0) + { + free (sf._sbf._f._IO_buf_base); + return ret; + } + /* Only use realloc if the size we need is of the same (binary) + order of magnitude then the memory we allocated. */ + needed = sf._sbf._f._IO_write_ptr - sf._sbf._f._IO_write_base + 1; + allocated = sf._sbf._f._IO_write_end - sf._sbf._f._IO_write_base; + if ((allocated >> 1) <= needed) + *result_ptr = (char *) realloc (sf._sbf._f._IO_buf_base, needed); + else + { + *result_ptr = (char *) malloc (needed); + if (*result_ptr != NULL) + { + memcpy (*result_ptr, sf._sbf._f._IO_buf_base, needed - 1); + free (sf._sbf._f._IO_buf_base); + } + else + /* We have no choice, use the buffer we already have. */ + *result_ptr = (char *) realloc (sf._sbf._f._IO_buf_base, needed); + } + if (*result_ptr == NULL) + *result_ptr = sf._sbf._f._IO_buf_base; + (*result_ptr)[needed - 1] = '\0'; + return ret; +} +libc_hidden_def (__vasprintf_chk) --- libc/debug/obprintf_chk.c.jj 2008-03-04 11:56:57.000000000 +0100 +++ libc/debug/obprintf_chk.c 2008-03-04 14:14:31.000000000 +0100 @@ -0,0 +1,117 @@ +/* Print output of stream to given obstack. + Copyright (C) 1996,1997,1999,2000,2001,2002,2003,2004,2005,2006,2008 + Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Ulrich Drepper , 1996. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + + +#include +#include +#include "../libio/strfile.h" +#include +#include +#include +#include +#include +#include + + +struct _IO_obstack_file +{ + struct _IO_FILE_plus file; + struct obstack *obstack; +}; + +extern const struct _IO_jump_t _IO_obstack_jumps attribute_hidden; + +int +__obstack_vprintf_chk (struct obstack *obstack, int flags, const char *format, + va_list args) +{ + struct obstack_FILE + { + struct _IO_obstack_file ofile; + } new_f; + int result; + int size; + int room; + +#ifdef _IO_MTSAFE_IO + new_f.ofile.file.file._lock = NULL; +#endif + + _IO_no_init (&new_f.ofile.file.file, _IO_USER_LOCK, -1, NULL, NULL); + _IO_JUMPS (&new_f.ofile.file) = &_IO_obstack_jumps; + room = obstack_room (obstack); + size = obstack_object_size (obstack) + room; + if (size == 0) + { + /* We have to handle the allocation a bit different since the + `_IO_str_init_static' function would handle a size of zero + different from what we expect. */ + + /* Get more memory. */ + obstack_make_room (obstack, 64); + + /* Recompute how much room we have. */ + room = obstack_room (obstack); + size = room; + + assert (size != 0); + } + + _IO_str_init_static_internal ((struct _IO_strfile_ *) &new_f.ofile, + obstack_base (obstack), + size, obstack_next_free (obstack)); + /* Now allocate the rest of the current chunk. */ + assert (size == (new_f.ofile.file.file._IO_write_end + - new_f.ofile.file.file._IO_write_base)); + assert (new_f.ofile.file.file._IO_write_ptr + == (new_f.ofile.file.file._IO_write_base + + obstack_object_size (obstack))); + obstack_blank_fast (obstack, room); + + new_f.ofile.obstack = obstack; + + /* For flags > 0 (i.e. __USE_FORTIFY_LEVEL > 1) request that %n + can only come from read-only format strings. */ + if (flags > 0) + new_f.ofile.file.file._flags2 |= _IO_FLAGS2_FORTIFY; + + result = INTUSE(_IO_vfprintf) (&new_f.ofile.file.file, format, args); + + /* Shrink the buffer to the space we really currently need. */ + obstack_blank_fast (obstack, (new_f.ofile.file.file._IO_write_ptr + - new_f.ofile.file.file._IO_write_end)); + + return result; +} +libc_hidden_def (__obstack_vprintf_chk) + + +int +__obstack_printf_chk (struct obstack *obstack, int flags, const char *format, + ...) +{ + int result; + va_list ap; + va_start (ap, format); + result = __obstack_vprintf_chk (obstack, flags, format, ap); + va_end (ap); + return result; +} --- libc/debug/tst-chk1.c.jj 2007-09-29 20:51:56.000000000 +0200 +++ libc/debug/tst-chk1.c 2008-03-04 15:12:56.000000000 +0100 @@ -1,4 +1,4 @@ -/* Copyright (C) 2004, 2005, 2006, 2007 Free Software Foundation, Inc. +/* Copyright (C) 2004, 2005, 2006, 2007, 2008 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Jakub Jelinek , 2004. @@ -20,6 +20,7 @@ #include #include #include +#include #include #include #include @@ -31,6 +32,9 @@ #include #include +#define obstack_chunk_alloc malloc +#define obstack_chunk_free free + char *temp_filename; static void do_prepare (void); static int do_test (void); @@ -705,6 +709,36 @@ do_test (void) if (fprintf (fp, buf2 + 4, str5) != 7) FAIL (); + char *my_ptr = NULL; + strcpy (buf2 + 2, "%n%s%n"); + /* When the format string is writable and contains %n, + with -D_FORTIFY_SOURCE=2 it causes __chk_fail. */ + CHK_FAIL2_START + if (asprintf (&my_ptr, buf2, str4, &n1, str5, &n1) != 14) + FAIL (); + else + free (my_ptr); + CHK_FAIL2_END + + struct obstack obs; + obstack_init (&obs); + CHK_FAIL2_START + if (obstack_printf (&obs, buf2, str4, &n1, str5, &n1) != 14) + FAIL (); + CHK_FAIL2_END + obstack_free (&obs, NULL); + + my_ptr = NULL; + if (asprintf (&my_ptr, "%s%n%s%n", str4, &n1, str5, &n1) != 14) + FAIL (); + else + free (my_ptr); + + obstack_init (&obs); + if (obstack_printf (&obs, "%s%n%s%n", str4, &n1, str5, &n1) != 14) + FAIL (); + obstack_free (&obs, NULL); + if (freopen (temp_filename, "r", stdin) == NULL) { puts ("could not open temporary file"); --- libc/debug/Versions.jj 2007-09-16 07:06:24.000000000 +0200 +++ libc/debug/Versions 2008-03-04 12:25:04.000000000 +0100 @@ -42,6 +42,10 @@ libc { GLIBC_2.7 { __fread_chk; __fread_unlocked_chk; } + GLIBC_2.8 { + __asprintf_chk; __vasprintf_chk; __dprintf_chk; __vdprintf_chk; + __obstack_printf_chk; __obstack_vprintf_chk; + } GLIBC_PRIVATE { __fortify_fail; } --- libc/debug/Makefile.jj 2007-09-15 17:18:46.000000000 +0200 +++ libc/debug/Makefile 2008-03-04 14:49:36.000000000 +0100 @@ -1,4 +1,4 @@ -# Copyright (C) 1998-2001,2004,2005,2006,2007 Free Software Foundation, Inc. +# Copyright (C) 1998-2001,2004-2008 Free Software Foundation, Inc. # This file is part of the GNU C Library. # The GNU C Library is free software; you can redistribute it and/or @@ -41,7 +41,8 @@ routines = backtrace backtracesyms back confstr_chk getgroups_chk ttyname_r_chk getlogin_r_chk \ gethostname_chk getdomainname_chk wcrtomb_chk mbsnrtowcs_chk \ wcsnrtombs_chk mbsrtowcs_chk wcsrtombs_chk mbstowcs_chk \ - wcstombs_chk \ + wcstombs_chk asprintf_chk vasprintf_chk dprintf_chk \ + vdprintf_chk obprintf_chk \ stack_chk_fail fortify_fail \ $(static-only-routines) static-only-routines := warning-nop stack_chk_fail_local @@ -51,6 +52,11 @@ CFLAGS-sprintf_chk.c = -D_IO_MTSAFE_IO CFLAGS-snprintf_chk.c = -D_IO_MTSAFE_IO CFLAGS-vsprintf_chk.c = -D_IO_MTSAFE_IO CFLAGS-vsnprintf_chk.c = -D_IO_MTSAFE_IO +CFLAGS-asprintf_chk.c = -D_IO_MTSAFE_IO +CFLAGS-vasprintf_chk.c = -D_IO_MTSAFE_IO +CFLAGS-obprintf_chk.c = -D_IO_MTSAFE_IO +CFLAGS-dprintf_chk.c = -D_IO_MTSAFE_IO $(exceptions) +CFLAGS-vdprintf_chk.c = -D_IO_MTSAFE_IO $(exceptions) CFLAGS-printf_chk.c = -D_IO_MTSAFE_IO $(exceptions) CFLAGS-fprintf_chk.c = -D_IO_MTSAFE_IO $(exceptions) CFLAGS-vprintf_chk.c = -D_IO_MTSAFE_IO $(exceptions) --- libc/sysdeps/ieee754/ldbl-opt/nldbl-compat.c.jj 2007-09-18 21:24:15.000000000 +0200 +++ libc/sysdeps/ieee754/ldbl-opt/nldbl-compat.c 2008-03-04 13:20:33.000000000 +0100 @@ -1,5 +1,5 @@ /* *printf* family compatibility routines for IEEE double as long double - Copyright (C) 2006, 2007 Free Software Foundation, Inc. + Copyright (C) 2006, 2007, 2008 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Jakub Jelinek , 2006. @@ -48,6 +48,9 @@ libc_hidden_proto (__nldbl___vfprintf_ch libc_hidden_proto (__nldbl___vsyslog_chk) libc_hidden_proto (__nldbl___vsprintf_chk) libc_hidden_proto (__nldbl___vswprintf_chk) +libc_hidden_proto (__nldbl___vasprintf_chk) +libc_hidden_proto (__nldbl___vdprintf_chk) +libc_hidden_proto (__nldbl___obstack_vprintf_chk) libc_hidden_proto (__nldbl___vstrfmon) libc_hidden_proto (__nldbl___vstrfmon_l) libc_hidden_proto (__nldbl___isoc99_vsscanf) @@ -667,6 +670,86 @@ __nldbl___wprintf_chk (int flag, const w return done; } +int +attribute_compat_text_section +__nldbl___vasprintf_chk (char **ptr, int flag, const char *fmt, va_list arg) +{ + int res; + __no_long_double = 1; + res = __vasprintf_chk (ptr, flag, fmt, arg); + __no_long_double = 0; + return res; +} +libc_hidden_def (__nldbl___vasprintf_chk) + +int +attribute_compat_text_section +__nldbl___asprintf_chk (char **ptr, int flag, const char *fmt, ...) +{ + va_list arg; + int done; + + va_start (arg, fmt); + done = __nldbl___vasprintf_chk (ptr, flag, fmt, arg); + va_end (arg); + + return done; +} + +int +attribute_compat_text_section +__nldbl___vdprintf_chk (int d, int flag, const char *fmt, va_list arg) +{ + int res; + set_no_long_double (); + res = __vdprintf_chk (d, flag, fmt, arg); + clear_no_long_double (); + return res; +} +libc_hidden_def (__nldbl___vdprintf_chk) + +int +attribute_compat_text_section +__nldbl___dprintf_chk (int d, int flag, const char *fmt, ...) +{ + va_list arg; + int done; + + va_start (arg, fmt); + done = __nldbl___vdprintf_chk (d, flag, fmt, arg); + va_end (arg); + + return done; +} + +int +attribute_compat_text_section +__nldbl___obstack_vprintf_chk (struct obstack *obstack, int flag, + const char *fmt, va_list arg) +{ + int res; + __no_long_double = 1; + res = __obstack_vprintf_chk (obstack, flag, fmt, arg); + __no_long_double = 0; + return res; +} +libc_hidden_def (__nldbl___obstack_vprintf_chk) + +int +attribute_compat_text_section +__nldbl___obstack_printf_chk (struct obstack *obstack, int flag, + const char *fmt, ...) +{ + va_list arg; + int done; + + va_start (arg, fmt); + done = __nldbl___obstack_vprintf_chk (obstack, flag, fmt, arg); + va_end (arg); + + return done; +} + extern __typeof (printf_size) __printf_size; int --- libc/sysdeps/ieee754/ldbl-opt/nldbl-obstack_vprintf_chk.c.jj 2008-03-04 13:45:38.000000000 +0100 +++ libc/sysdeps/ieee754/ldbl-opt/nldbl-obstack_vprintf_chk.c 2008-03-04 13:46:35.000000000 +0100 @@ -0,0 +1,9 @@ +#include "nldbl-compat.h" + +int +attribute_hidden +__obstack_vprintf_chk (struct obstack *obstack, int flag, const char *fmt, + va_list ap) +{ + return __nldbl___obstack_vprintf_chk (obstack, flag, fmt, ap); +} --- libc/sysdeps/ieee754/ldbl-opt/nldbl-dprintf_chk.c.jj 2008-03-04 13:40:09.000000000 +0100 +++ libc/sysdeps/ieee754/ldbl-opt/nldbl-dprintf_chk.c 2008-03-04 13:40:32.000000000 +0100 @@ -0,0 +1,15 @@ +#include "nldbl-compat.h" + +attribute_hidden +int +__dprintf_chk (int d, int flag, const char *fmt, ...) +{ + va_list arg; + int done; + + va_start (arg, fmt); + done = __nldbl___vdprintf_chk (d, flag, fmt, arg); + va_end (arg); + + return done; +} --- libc/sysdeps/ieee754/ldbl-opt/nldbl-compat.h.jj 2007-09-18 21:24:15.000000000 +0200 +++ libc/sysdeps/ieee754/ldbl-opt/nldbl-compat.h 2008-03-04 13:06:31.000000000 +0100 @@ -93,6 +93,11 @@ extern int __nldbl___vsnprintf_chk (char extern int __nldbl___vswprintf_chk (wchar_t *__restrict, size_t, int, size_t, const wchar_t *__restrict, __gnuc_va_list) __THROW; +extern int __nldbl___vasprintf_chk (char **, int, const char *, _G_va_list) + __THROW; +extern int __nldbl___vdprintf_chk (int, int, const char *, _G_va_list); +extern int __nldbl___obstack_vprintf_chk (struct obstack *, int, const char *, + _G_va_list) __THROW; extern void __nldbl___vsyslog_chk (int, int, const char *, va_list); --- libc/sysdeps/ieee754/ldbl-opt/Versions.jj 2007-09-18 21:24:15.000000000 +0200 +++ libc/sysdeps/ieee754/ldbl-opt/Versions 2008-03-04 13:39:25.000000000 +0100 @@ -73,6 +73,11 @@ libc { __nldbl___isoc99_swscanf; __nldbl___isoc99_vwscanf; __nldbl___isoc99_vfwscanf; __nldbl___isoc99_vswscanf; } + GLIBC_2.8 { + __nldbl___asprintf_chk; __nldbl___vasprintf_chk; + __nldbl___dprintf_chk; __nldbl___vdprintf_chk; + __nldbl___obstack_printf_chk; __nldbl___obstack_vprintf_chk; + } } libm { NLDBL_VERSION { --- libc/sysdeps/ieee754/ldbl-opt/nldbl-obstack_printf_chk.c.jj 2008-03-04 13:45:35.000000000 +0100 +++ libc/sysdeps/ieee754/ldbl-opt/nldbl-obstack_printf_chk.c 2008-03-04 13:46:02.000000000 +0100 @@ -0,0 +1,13 @@ +#include "nldbl-compat.h" + +int +attribute_hidden +__obstack_printf_chk (struct obstack *obstack, int flag, const char *fmt, ...) +{ + int result; + va_list ap; + va_start (ap, fmt); + result = __nldbl___obstack_vprintf_chk (obstack, flag, fmt, ap); + va_end (ap); + return result; +} --- libc/sysdeps/ieee754/ldbl-opt/nldbl-asprintf_chk.c.jj 2008-03-04 13:42:32.000000000 +0100 +++ libc/sysdeps/ieee754/ldbl-opt/nldbl-asprintf_chk.c 2008-03-04 13:42:58.000000000 +0100 @@ -0,0 +1,15 @@ +#include "nldbl-compat.h" + +attribute_hidden +int +__asprintf_chk (char **string_ptr, int flag, const char *fmt, ...) +{ + va_list arg; + int done; + + va_start (arg, fmt); + done = __nldbl___vasprintf_chk (string_ptr, flag, fmt, arg); + va_end (arg); + + return done; +} --- libc/sysdeps/ieee754/ldbl-opt/nldbl-vdprintf_chk.c.jj 2008-03-04 13:40:52.000000000 +0100 +++ libc/sysdeps/ieee754/ldbl-opt/nldbl-vdprintf_chk.c 2008-03-04 13:41:11.000000000 +0100 @@ -0,0 +1,8 @@ +#include "nldbl-compat.h" + +int +attribute_hidden +__vdprintf_chk (int d, int flag, const char *fmt, va_list arg) +{ + return __nldbl___vdprintf_chk (d, flag, fmt, arg); +} --- libc/sysdeps/ieee754/ldbl-opt/Makefile.jj 2007-09-18 21:24:15.000000000 +0200 +++ libc/sysdeps/ieee754/ldbl-opt/Makefile 2008-03-04 13:48:05.000000000 +0100 @@ -20,7 +20,8 @@ libnldbl-calls = asprintf dprintf fprint fprintf_chk fwprintf_chk printf_chk snprintf_chk sprintf_chk \ swprintf_chk vfprintf_chk vfwprintf_chk vprintf_chk \ vsnprintf_chk vsprintf_chk vswprintf_chk vwprintf_chk \ - wprintf_chk \ + wprintf_chk asprintf_chk vasprintf_chk dprintf_chk \ + vdprintf_chk obstack_printf_chk obstack_vprintf_chk \ syslog syslog_chk vsyslog vsyslog_chk \ strfmon strfmon_l \ strtold strtold_l strtoldint wcstold wcstold_l wcstoldint \ --- libc/sysdeps/ieee754/ldbl-opt/nldbl-vasprintf_chk.c.jj 2008-03-04 13:46:58.000000000 +0100 +++ libc/sysdeps/ieee754/ldbl-opt/nldbl-vasprintf_chk.c 2008-03-04 13:47:22.000000000 +0100 @@ -0,0 +1,8 @@ +#include "nldbl-compat.h" + +int +attribute_hidden +__vasprintf_chk (char **result_ptr, int flag, const char *fmt, va_list ap) +{ + return __nldbl___vasprintf_chk (result_ptr, flag, fmt, ap); +} Jakub From schwidefsky@de.ibm.com Fri Mar 7 16:41:00 2008 From: schwidefsky@de.ibm.com (Martin Schwidefsky) Date: Fri, 07 Mar 2008 16:41:00 -0000 Subject: [PATCH] s390: Remove PT_IEEE_IP ptrace calls. Message-ID: <1204908023.21438.8.camel@localhost> Greetings, as I revisited the ptrace code in the kernel to see what we have to change for the new utrace interface and I noticed a bug in regard to PT_IEEE_IP. The PT_IEEE_IP ptrace peek/poke calls are supposed to return/modify the address of the last IEEE floating point fault. It can be called for a traced child process and for the current(!) process. The later is used by glibc in the fesetenv/fegetenv functions for the ieee_instruction_pointer field of the fenv_t structure. This self reference of a process via ptrace is rather alien to the ptrace interface, the call never quite fit in. The curious thing now is that this call has been broken for the last 6 years. A ptrace cleanup patch against the kernel simply removed the support for PT_IEEE_IP, peeking always returns 0 and poking the value has no effect. Nobody noticed for 6 years, so I conclude that nobody really needs the call. In that case we can as well get rid of it. Kernel patch will follow if this patch gets accepted. blue skies, Martin. --- 2008-03-07 Martin Schwidefsky * sysdeps/s390/fpu/fegetenv.c (fegetenv): Remove PTRACE_PEEKUSER ptrace call to get the ieee_instruction_pointer from the kernel. * sysdeps/s390/fpu/fesetenv.c (fesetenv): Remove PTRACE_POKEUSER ptrace call to set the ieee_instructtion_pointer. * sysdeps/unix/sysv/linux/s390/sys/user.h (struct _user_regs_struct): Add comment that ieee_instruction_pointer is always 0. diff -urpN libc/sysdeps/s390/fpu/fegetenv.c libc-s390/sysdeps/s390/fpu/fegetenv.c --- libc/sysdeps/s390/fpu/fegetenv.c 2003-05-05 20:22:18.000000000 +0200 +++ libc-s390/sysdeps/s390/fpu/fegetenv.c 2008-03-07 13:56:27.000000000 +0100 @@ -1,5 +1,5 @@ /* Store current floating-point environment. - Copyright (C) 2000, 2003 Free Software Foundation, Inc. + Copyright (C) 2000, 2008 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Denis Joseph Barrow (djbarrow@de.ibm.com). @@ -28,15 +28,7 @@ int fegetenv (fenv_t *envp) { - /* The S/390 IEEE fpu doesn't keep track of the ieee instruction pointer. - To get around that the kernel will store the address of the last - fpu fault to the process structure. This ptrace call reads this value - from the kernel space. That means the ieee_instruction_pointer is - only correct after a fpu fault. That's the best we can do, there is - no way to find out the ieee instruction pointer if there was no fault. */ _FPU_GETCW (envp->fpc); - envp->ieee_instruction_pointer = - (void *) ptrace (PTRACE_PEEKUSER, getpid (), PT_IEEE_IP); /* Success. */ return 0; diff -urpN libc/sysdeps/s390/fpu/fesetenv.c libc-s390/sysdeps/s390/fpu/fesetenv.c --- libc/sysdeps/s390/fpu/fesetenv.c 2002-09-10 03:26:38.000000000 +0200 +++ libc-s390/sysdeps/s390/fpu/fesetenv.c 2008-03-07 13:56:47.000000000 +0100 @@ -1,5 +1,5 @@ /* Install given floating-point environment. - Copyright (C) 2000, 2002 Free Software Foundation, Inc. + Copyright (C) 2000, 2008 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Denis Joseph Barrow (djbarrow@de.ibm.com). @@ -43,13 +43,7 @@ fesetenv (const fenv_t *envp) else env = (*envp); - /* The S/390 IEEE fpu doesn't have a register for the ieee - instruction pointer. The operating system is required to keep an - instruction pointer on a per process base. We read and write this - value with the ptrace interface. */ _FPU_SETCW (env.fpc); - ptrace (PTRACE_POKEUSER, getpid (), PT_IEEE_IP, - env.ieee_instruction_pointer); /* Success. */ return 0; diff -urpN libc/sysdeps/unix/sysv/linux/s390/sys/user.h libc-s390/sysdeps/unix/sysv/linux/s390/sys/user.h --- libc/sysdeps/unix/sysv/linux/s390/sys/user.h 2006-01-11 10:03:47.000000000 +0100 +++ libc-s390/sysdeps/unix/sysv/linux/s390/sys/user.h 2008-03-07 16:54:20.000000000 +0100 @@ -1,4 +1,4 @@ -/* Copyright (C) 2000,2005 Free Software Foundation, Inc. +/* Copyright (C) 2000,2008 Free Software Foundation, Inc. This file is part of the GNU C Library. The GNU C Library is free software; you can redistribute it and/or @@ -56,7 +56,7 @@ struct _user_regs_struct unsigned long orig_gpr2; /* Original gpr2. */ struct _user_fpregs_struct fp_regs; /* Floating point registers. */ struct _user_per_struct per_info; /* Hardware tracing registers. */ - unsigned long ieee_instruction_pointer; + unsigned long ieee_instruction_pointer; /* Always 0. */ }; struct user { From roland@redhat.com Fri Mar 7 18:59:00 2008 From: roland@redhat.com (Roland McGrath) Date: Fri, 07 Mar 2008 18:59:00 -0000 Subject: [PATCH] s390: Remove PT_IEEE_IP ptrace calls. In-Reply-To: Martin Schwidefsky's message of Friday, 7 March 2008 17:40:23 +0100 <1204908023.21438.8.camel@localhost> References: <1204908023.21438.8.camel@localhost> Message-ID: <20080307185837.523B827010F@magilla.localdomain> If you aren't worried about any compatibility issue for s390, we surely aren't. I assume you've checked with both users. ;-) Thanks, Roland From aj@suse.de Sun Mar 9 12:52:00 2008 From: aj@suse.de (Andreas Jaeger) Date: Sun, 09 Mar 2008 12:52:00 -0000 Subject: BZ 5753: Use protected namespace Message-ID: <87fxv0kqly.fsf@suse.de> The following is IMO mainly cosmetics. We use everywhere else in the file already the protected namespace, so let's be consistent in the installed file. Ok to commit? Andreas 2008-03-09 Andreas Jaeger [BZ #5753] * sysdeps/ia64/ieee754.h: Use protected namespace __BIG_ENDIAN/__LITTLE_ENDIAN. * sysdeps/ieee754/ieee754.h: Likewise. Patch by Aurelien Jarno . ============================================================ Index: sysdeps/ieee754/ieee754.h --- sysdeps/ieee754/ieee754.h 6 Jul 2001 04:55:54 -0000 1.12 +++ sysdeps/ieee754/ieee754.h 9 Mar 2008 12:49:00 -0000 @@ -80,7 +80,7 @@ union ieee754_double unsigned int mantissa1:32; #endif /* Big endian. */ #if __BYTE_ORDER == __LITTLE_ENDIAN -# if __FLOAT_WORD_ORDER == BIG_ENDIAN +# if __FLOAT_WORD_ORDER == __BIG_ENDIAN unsigned int mantissa0:20; unsigned int exponent:11; unsigned int negative:1; @@ -106,7 +106,7 @@ union ieee754_double unsigned int mantissa0:19; unsigned int mantissa1:32; #else -# if __FLOAT_WORD_ORDER == BIG_ENDIAN +# if __FLOAT_WORD_ORDER == __BIG_ENDIAN unsigned int mantissa0:19; unsigned int quiet_nan:1; unsigned int exponent:11; @@ -142,7 +142,7 @@ union ieee854_long_double unsigned int mantissa1:32; #endif #if __BYTE_ORDER == __LITTLE_ENDIAN -# if __FLOAT_WORD_ORDER == BIG_ENDIAN +# if __FLOAT_WORD_ORDER == __BIG_ENDIAN unsigned int exponent:15; unsigned int negative:1; unsigned int empty:16; @@ -171,7 +171,7 @@ union ieee854_long_double unsigned int mantissa1:32; #endif #if __BYTE_ORDER == __LITTLE_ENDIAN -# if __FLOAT_WORD_ORDER == BIG_ENDIAN +# if __FLOAT_WORD_ORDER == __BIG_ENDIAN unsigned int exponent:15; unsigned int negative:1; unsigned int empty:16; ============================================================ Index: sysdeps/ia64/ieee754.h --- sysdeps/ia64/ieee754.h 6 Jul 2001 04:55:54 -0000 1.2 +++ sysdeps/ia64/ieee754.h 9 Mar 2008 12:49:00 -0000 @@ -80,7 +80,7 @@ union ieee754_double unsigned int mantissa1:32; #endif /* Big endian. */ #if __BYTE_ORDER == __LITTLE_ENDIAN -# if __FLOAT_WORD_ORDER == BIG_ENDIAN +# if __FLOAT_WORD_ORDER == __BIG_ENDIAN unsigned int mantissa0:20; unsigned int exponent:11; unsigned int negative:1; @@ -106,7 +106,7 @@ union ieee754_double unsigned int mantissa0:19; unsigned int mantissa1:32; #else -# if __FLOAT_WORD_ORDER == BIG_ENDIAN +# if __FLOAT_WORD_ORDER == __BIG_ENDIAN unsigned int mantissa0:19; unsigned int quiet_nan:1; unsigned int exponent:11; @@ -143,7 +143,7 @@ union ieee854_long_double unsigned int mantissa1:32; #endif #if __BYTE_ORDER == __LITTLE_ENDIAN -# if __FLOAT_WORD_ORDER == BIG_ENDIAN +# if __FLOAT_WORD_ORDER == __BIG_ENDIAN unsigned int empty0:32; unsigned int exponent:15; unsigned int negative:1; @@ -175,7 +175,7 @@ union ieee854_long_double unsigned int mantissa1:32; #endif #if __BYTE_ORDER == __LITTLE_ENDIAN -# if __FLOAT_WORD_ORDER == BIG_ENDIAN +# if __FLOAT_WORD_ORDER == __BIG_ENDIAN unsigned int empty0:32; unsigned int exponent:15; unsigned int negative:1; -- Andreas Jaeger, Director Platform / openSUSE, aj@suse.de SUSE LINUX Products GmbH, GF: Markus Rex, HRB 16746 (AG N?rnberg) Maxfeldstr. 5, 90409 N?rnberg, Germany GPG fingerprint = 93A3 365E CE47 B889 DF7F FED1 389A 563C C272 A126 -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 193 bytes Desc: not available URL: From aj@suse.de Sun Mar 9 14:22:00 2008 From: aj@suse.de (Andreas Jaeger) Date: Sun, 09 Mar 2008 14:22:00 -0000 Subject: BZ 5857: Fix rint/nearbyint Message-ID: <878x0skmel.fsf@suse.de> rint and nearbyint gave in some cases wrong values. Ok to commit? A patch for ldbl-* might be needed as well - anybody interested to look at it? Andreas 2008-03-09 Andreas Jaeger [BZ #5857] * sysdeps/ieee754/dbl-64/s_rint.c (__rint): Handle j0==18. * sysdeps/ieee754/dbl-64/s_nearbyint.c (__nearbyint): Likewise. Patch by Mark Elliott . * math/libm-test.inc (nearbyint_test): Add new test cases from #5857. (rint_test): Likewise. ============================================================ Index: sysdeps/ieee754/dbl-64/s_rint.c --- sysdeps/ieee754/dbl-64/s_rint.c 13 Jul 1999 23:53:26 -0000 1.1 +++ sysdeps/ieee754/dbl-64/s_rint.c 9 Mar 2008 14:20:59 -0000 @@ -67,8 +67,11 @@ TWO52[2]={ if(((i0&i)|i1)==0) return x; /* x is integral */ i>>=1; if(((i0&i)|i1)!=0) { - if(j0==19) i1 = 0x40000000; else - i0 = (i0&(~i))|((0x20000)>>j0); + if(j0==19) i1 = 0x40000000; else if (j0<18) + i0 = (i0&(~i))|((0x20000)>>j0); else { + i0 &= ~i; + i1 = 0x80000000; + } } } } else if (j0>51) { ============================================================ Index: sysdeps/ieee754/dbl-64/s_nearbyint.c --- sysdeps/ieee754/dbl-64/s_nearbyint.c 13 Jul 1999 23:53:03 -0000 1.1 +++ sysdeps/ieee754/dbl-64/s_nearbyint.c 9 Mar 2008 14:21:00 -0000 @@ -71,8 +71,11 @@ TWO52[2]={ if(((i0&i)|i1)==0) return x; /* x is integral */ i>>=1; if(((i0&i)|i1)!=0) { - if(j0==19) i1 = 0x40000000; else - i0 = (i0&(~i))|((0x20000)>>j0); + if(j0==19) i1 = 0x40000000; else if (j0<18) + i0 = (i0&(~i))|((0x20000)>>j0); else { + i0 &= ~i; + i1 = 0x80000000; + } } } } else if (j0>51) { ============================================================ Index: math/libm-test.inc --- math/libm-test.inc 28 Oct 2007 01:14:25 -0000 1.77 +++ math/libm-test.inc 9 Mar 2008 14:21:00 -0000 @@ -1,4 +1,4 @@ -/* Copyright (C) 1997-2006, 2007 Free Software Foundation, Inc. +/* Copyright (C) 1997-2006, 2007, 2008 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Andreas Jaeger , 1997. @@ -4481,6 +4481,11 @@ nearbyint_test (void) TEST_f_f (nearbyint, -0.5, minus_zero); TEST_f_f (nearbyint, -1.5, -2.0); + TEST_f_f (nearbyint, 262144.75, 262145.0); + TEST_f_f (nearbyint, 262142.75, 262143.0); + TEST_f_f (nearbyint, 524286.75, 524287.0); + TEST_f_f (nearbyint, 524288.75, 524289.0); + END (nearbyint); } @@ -4852,6 +4857,10 @@ rint_test (void) TEST_f_f (rint, -0.1, -0.0); TEST_f_f (rint, -0.25, -0.0); TEST_f_f (rint, -0.625, -1.0); + TEST_f_f (rint, 262144.75, 262145.0); + TEST_f_f (rint, 262142.75, 262143.0); + TEST_f_f (rint, 524286.75, 524287.0); + TEST_f_f (rint, 524288.75, 524289.0); #ifdef TEST_LDOUBLE /* The result can only be represented in long double. */ TEST_f_f (rint, 4503599627370495.5L, 4503599627370496.0L); -- Andreas Jaeger, Director Platform / openSUSE, aj@suse.de SUSE LINUX Products GmbH, GF: Markus Rex, HRB 16746 (AG N?rnberg) Maxfeldstr. 5, 90409 N?rnberg, Germany GPG fingerprint = 93A3 365E CE47 B889 DF7F FED1 389A 563C C272 A126 -------------- next part -------------- A non-text attachment was scrubbed... Name: not available Type: application/pgp-signature Size: 193 bytes Desc: not available URL: From roland@redhat.com Sun Mar 9 23:01:00 2008 From: roland@redhat.com (Roland McGrath) Date: Sun, 09 Mar 2008 23:01:00 -0000 Subject: BZ 5753: Use protected namespace In-Reply-To: Andreas Jaeger's message of Sunday, 9 March 2008 13:51:21 +0100 <87fxv0kqly.fsf@suse.de> References: <87fxv0kqly.fsf@suse.de> Message-ID: <20080309230107.D4D8726F991@magilla.localdomain> > Ok to commit? Yes. From schwidefsky@de.ibm.com Mon Mar 10 08:04:00 2008 From: schwidefsky@de.ibm.com (Martin Schwidefsky) Date: Mon, 10 Mar 2008 08:04:00 -0000 Subject: [PATCH] s390: Remove PT_IEEE_IP ptrace calls. In-Reply-To: <20080307185837.523B827010F@magilla.localdomain> References: <1204908023.21438.8.camel@localhost> <20080307185837.523B827010F@magilla.localdomain> Message-ID: <1205136243.23606.11.camel@localhost> On Fri, 2008-03-07 at 10:58 -0800, Roland McGrath wrote: > If you aren't worried about any compatibility issue for s390, we surely aren't. > I assume you've checked with both users. ;-) Compatibility issues for a field that does not contain the value it should contain? It can't get more broken than it is today, all the major distribution versions have a kernel that null the field. So I am not worried about compatibility. In fact I am quite happy that we can remove this nasty ptrace hack in fesetenv/fegetenv. It even showed up on some benchmarks. -- blue skies, Martin. "Reality continues to ruin my life." - Calvin. From jakub@redhat.com Tue Mar 25 16:08:00 2008 From: jakub@redhat.com (Jakub Jelinek) Date: Tue, 25 Mar 2008 16:08:00 -0000 Subject: [PATCH] scopev4 in /etc/gai.conf Message-ID: <20080325161558.GX3726@sunsite.mff.cuni.cz> Hi! When scopev4 is specified in /etc/gai.conf without /prefix_len, for IPv4 address that's just that address, i.e. bits 32 (resp. 128 for v4 mapped address). E.g. scopev4 172.16.0.1 7 and scopev4 172.16.0.1/32 7 are handled the same. But if /prefix_len isn't present for IN6_IS_ADDR_V4_MAPPED address, the entry is handled as invalid (cp == NULL, so satisfies a few initial conditions, but then fails the bits >= 96 test, because it has been initialized to 32. I assume it should default to 128, right? Also, the example scopev4 entries in posix/gai.conf use scopev4 ::ffff:0.0.0.0 14 entry, which ATM isn't parsed at all, with the getaddrinfo.c change below would be parsed as ::ffff:0.0.0.0/128 14, while I believe the nullbits entry should have netmask 0, i.e. ::ffff:0.0.0.0/96. If the last number is 14, that's not a big deal, as getaddrinfo.c will then magically add scope_nullbits entry, but still it would be good if the comment was accurate. 2008-03-25 Jakub Jelinek * posix/gai.conf: Fix comment for scope nullbits. * sysdeps/posix/getaddrinfo.c (gaiconf_init): If /bits is not present, default to 128 bits for v4 mapped addresses. --- libc/posix/gai.conf.jj 2007-12-10 09:05:34.000000000 +0100 +++ libc/posix/gai.conf 2008-03-25 16:57:53.000000000 +0100 @@ -65,4 +65,4 @@ #scopev4 ::ffff:10.0.0.0/104 5 #scopev4 ::ffff:172.16.0.0/108 5 #scopev4 ::ffff:192.168.0.0/112 5 -#scopev4 ::ffff:0.0.0.0 14 +#scopev4 ::ffff:0.0.0.0/96 14 --- libc/sysdeps/posix/getaddrinfo.c.jj 2008-02-01 10:54:30.000000000 +0100 +++ libc/sysdeps/posix/getaddrinfo.c 2008-03-25 16:57:01.000000000 +0100 @@ -1775,6 +1775,7 @@ gaiconf_init (void) *cp++ = '\0'; if (inet_pton (AF_INET6, val1, &prefix)) { + bits = 128; if (IN6_IS_ADDR_V4MAPPED (&prefix) && (cp == NULL || (bits = strtoul (cp, &endp, 10)) != ULONG_MAX Jakub From jakub@redhat.com Thu Mar 27 16:17:00 2008 From: jakub@redhat.com (Jakub Jelinek) Date: Thu, 27 Mar 2008 16:17:00 -0000 Subject: [PATCH] creat+open syscalls in linux/wordsize-64/syscalls.list Message-ID: <20080327162456.GY3726@sunsite.mff.cuni.cz> Hi! After the 2007-11-10 change which added dummy linux/wordsize-64/{open,creat}64.c files a lot, but not all, 64-bit arches added creat/open syscall entries to their syscalls.list. Those that have not done that (sparc64, partially alpha) are broken, and it is IMHO much better to just list them all in one place. 2008-03-27 Jakub Jelinek * sysdeps/unix/sysv/linux/wordsize-64/syscalls.list: Add open and creat system calls. * sysdeps/unix/sysv/linux/alpha/syscalls.list: Remove open system call. * sysdeps/unix/sysv/linux/ia64/syscalls.list: Remove open and creat system calls. * sysdeps/unix/sysv/linux/powerpc/powerpc64/syscalls.list: Likewise. * sysdeps/unix/sysv/linux/s390/s390-64/syscalls.list: Likewise. * sysdeps/unix/sysv/linux/x86_64/syscalls.list: Likewise. --- libc/sysdeps/unix/sysv/linux/wordsize-64/syscalls.list 31 Mar 2006 21:46:50 -0000 1.2 +++ libc/sysdeps/unix/sysv/linux/wordsize-64/syscalls.list 27 Mar 2008 16:06:54 -0000 @@ -15,3 +15,5 @@ setrlimit - setrlimit i:ip __setrlimit s readahead - readahead i:iii __readahead readahead sendfile - sendfile i:iipi sendfile sendfile64 sync_file_range - sync_file_range i:iiii sync_file_range +creat - creat Ci:si __libc_creat creat creat64 +open - open Ci:siv __libc_open __open open __open64 open64 --- libc/sysdeps/unix/sysv/linux/alpha/syscalls.list 15 Feb 2005 00:12:18 -0000 1.65 +++ libc/sysdeps/unix/sysv/linux/alpha/syscalls.list 27 Mar 2008 16:06:54 -0000 @@ -17,8 +17,6 @@ sigstack - sigstack 2 sigstack vfork - vfork 0 __vfork vfork getpriority - getpriority i:ii __getpriority getpriority -open - open Ci:siv __libc_open __open open !__libc_open64 __open64 open64 -open64 open - # proper socket implementations: accept - accept Ci:iBN __libc_accept __accept accept --- libc/sysdeps/unix/sysv/linux/ia64/syscalls.list 10 Nov 2007 19:35:15 -0000 1.40 +++ libc/sysdeps/unix/sysv/linux/ia64/syscalls.list 27 Mar 2008 16:06:54 -0000 @@ -4,9 +4,6 @@ umount2 - umount 2 __umount2 umount2 getpriority - getpriority i:ii __getpriority getpriority -creat - creat Ci:si __libc_creat creat creat64 -open - open Ci:siv __libc_open __open open __open64 open64 - # semaphore and shm system calls msgctl - msgctl i:iip __msgctl msgctl msgget - msgget i:ii __msgget msgget --- libc/sysdeps/unix/sysv/linux/powerpc/powerpc64/syscalls.list 24 Nov 2007 03:23:29 -0000 1.10 +++ libc/sysdeps/unix/sysv/linux/powerpc/powerpc64/syscalls.list 27 Mar 2008 16:06:54 -0000 @@ -1,5 +1,3 @@ # File name Caller Syscall name # args Strong name Weak names -creat - creat Ci:si __libc_creat creat creat64 getrlimit - ugetrlimit i:ip __getrlimit getrlimit getrlimit64 -open - open Ci:siv __libc_open __open open __open64 open64 --- libc/sysdeps/unix/sysv/linux/s390/s390-64/syscalls.list 23 Nov 2007 15:20:51 -0000 1.21 +++ libc/sysdeps/unix/sysv/linux/s390/s390-64/syscalls.list 27 Mar 2008 16:06:54 -0000 @@ -2,9 +2,6 @@ vfork - vfork 0 __vfork vfork -creat - creat Ci:si __libc_creat creat creat64 -open - open Ci:siv __libc_open __open open __open64 open64 - # semaphore and shm system calls msgctl - msgctl i:iip __msgctl msgctl msgget - msgget i:ii __msgget msgget --- libc/sysdeps/unix/sysv/linux/x86_64/syscalls.list 10 Nov 2007 19:35:15 -0000 1.26 +++ libc/sysdeps/unix/sysv/linux/x86_64/syscalls.list 27 Mar 2008 16:06:54 -0000 @@ -1,13 +1,11 @@ # File name Caller Syscall name # args Strong name Weak names arch_prctl EXTRA arch_prctl i:ii __arch_prctl arch_prctl -creat - creat Ci:si __libc_creat creat creat64 modify_ldt EXTRA modify_ldt i:ipi __modify_ldt modify_ldt msgctl - msgctl i:iip __msgctl msgctl msgget - msgget i:ii __msgget msgget msgrcv - msgrcv Ci:ibnii __msgrcv msgrcv msgsnd - msgsnd Ci:ibni __msgsnd msgsnd -open - open Ci:siv __libc_open __open open __open64 open64 shmat - shmat i:ipi __shmat shmat shmctl - shmctl i:iip __shmctl shmctl shmdt - shmdt i:s __shmdt shmdt Jakub From jakub@redhat.com Sun Mar 30 21:56:00 2008 From: jakub@redhat.com (Jakub Jelinek) Date: Sun, 30 Mar 2008 21:56:00 -0000 Subject: [PATCH] Fix races in _nl_find_msg Message-ID: <20080330220421.GZ3726@sunsite.mff.cuni.cz> Hi! As the attached testcase shows (at least on quad core, perhaps not every time but very often), BZ#5058 fixes didn't cure all races. One problem is that nconversions isn't reread after acquiring wrlock, which means that several threads can use a stale cached nconversions value, which means they won't be able to find the conversion added by another thread, and can happily overwrite that entry. The other problem is that when convd->conv_tab is NULL, the setting of it to calloc returned address isn't atomic nor guarded by any lock, so multiple threads can do that. This can mean both memory leak, but also crash when the value is midway through _nl_find_msg one value and then suddenly changes to a different one. 2008-03-30 Jakub Jelinek * intl/dcigettext.c (_nl_find_msg): Reread nconversions after acquiring wrlock. Do conv_tab allocation while holding lock. * intl/Makefile: Add rules to build and run tst-gettext6. * intl/tst-gettext6.c: New test. * intl/tst-gettext6.sh: New file. * Makefile (LOCALES): Add ja_JP.UTF-8. --- libc/intl/dcigettext.c 17 Nov 2007 07:37:30 -0000 1.58 +++ libc/intl/dcigettext.c 30 Mar 2008 21:42:59 -0000 @@ -879,6 +879,7 @@ _nl_find_msg (domain_file, domainbinding { /* We have to allocate a new conversions table. */ __libc_rwlock_wrlock (domain->conversions_lock); + nconversions = domain->nconversions; /* Maybe in the meantime somebody added the translation. Recheck. */ @@ -1033,6 +1034,7 @@ _nl_find_msg (domain_file, domainbinding # endif ) { + __libc_lock_define_initialized (static, lock) /* We are supposed to do a conversion. First allocate an appropriate table with the same structure as the table of translations in the file, where we can put the pointers @@ -1042,13 +1044,21 @@ _nl_find_msg (domain_file, domainbinding handle this case by converting RESULTLEN bytes, including NULs. */ - if (convd->conv_tab == NULL - && ((convd->conv_tab = - (char **) calloc (nstrings + domain->n_sysdep_strings, - sizeof (char *))) - == NULL)) - /* Mark that we didn't succeed allocating a table. */ - convd->conv_tab = (char **) -1; + if (__builtin_expect (convd->conv_tab == NULL, 0)) + { + __libc_lock_lock (lock); + if (convd->conv_tab == NULL) + { + convd->conv_tab + = calloc (nstrings + domain->n_sysdep_strings, + sizeof (char *)); + if (convd->conv_tab != NULL) + goto not_translated_yet; + /* Mark that we didn't succeed allocating a table. */ + convd->conv_tab = (char **) -1; + } + __libc_lock_unlock (lock); + } if (__builtin_expect (convd->conv_tab == (char **) -1, 0)) /* Nothing we can do, no more memory. We cannot use the @@ -1057,12 +1067,14 @@ _nl_find_msg (domain_file, domainbinding if (convd->conv_tab[act] == NULL) { + __libc_lock_lock (lock); + not_translated_yet:; + /* We haven't used this string so far, so it is not translated yet. Do this now. */ /* We use a bit more efficient memory handling. We allocate always larger blocks which get used over time. This is faster than many small allocations. */ - __libc_lock_define_initialized (static, lock) # define INITIAL_BLOCK_SIZE 4080 static unsigned char *freemem; static size_t freemem_size; @@ -1074,8 +1086,6 @@ _nl_find_msg (domain_file, domainbinding transmem_block_t *transmem_list = NULL; # endif - __libc_lock_lock (lock); - inbuf = (const unsigned char *) result; outbuf = freemem + sizeof (size_t); --- libc/intl/Makefile 4 May 2005 17:53:42 -0000 1.54 +++ libc/intl/Makefile 30 Mar 2008 21:42:58 -0000 @@ -1,4 +1,4 @@ -# Copyright (C) 1995-2003, 2005 Free Software Foundation, Inc. +# Copyright (C) 1995-2003, 2005, 2008 Free Software Foundation, Inc. # This file is part of the GNU C Library. # The GNU C Library is free software; you can redistribute it and/or @@ -32,11 +32,11 @@ distribute = gmo.h gettextP.h hash-strin tst-codeset.sh tstcodeset.po \ tst-gettext3.sh \ tst-gettext4.sh tst-gettext4-de.po tst-gettext4-fr.po \ - tst-gettext5.sh + tst-gettext5.sh tst-gettext6.sh include ../Makeconfig -multithread-test-srcs := tst-gettext4 tst-gettext5 +multithread-test-srcs := tst-gettext4 tst-gettext5 tst-gettext6 test-srcs := tst-gettext tst-translit tst-gettext2 tst-codeset tst-gettext3 ifeq ($(have-thread-library),yes) test-srcs += $(multithread-test-srcs) @@ -67,7 +67,8 @@ ifneq ($(strip $(MSGFMT)),:) tests: $(objpfx)tst-translit.out $(objpfx)tst-gettext2.out \ $(objpfx)tst-codeset.out $(objpfx)tst-gettext3.out ifeq ($(have-thread-library),yes) -tests: $(objpfx)tst-gettext4.out $(objpfx)tst-gettext5.out +tests: $(objpfx)tst-gettext4.out $(objpfx)tst-gettext5.out \ + $(objpfx)tst-gettext6.out endif ifneq (no,$(PERL)) tests: $(objpfx)mtrace-tst-gettext @@ -90,6 +91,8 @@ $(objpfx)tst-gettext4.out: tst-gettext4. $(SHELL) -e $< $(common-objpfx) '$(run-program-prefix)' $(common-objpfx)intl/ $(objpfx)tst-gettext5.out: tst-gettext5.sh $(objpfx)tst-gettext5 $(SHELL) -e $< $(common-objpfx) '$(run-program-prefix)' $(common-objpfx)intl/ +$(objpfx)tst-gettext6.out: tst-gettext6.sh $(objpfx)tst-gettext6 + $(SHELL) -e $< $(common-objpfx) '$(run-program-prefix)' $(common-objpfx)intl/ endif endif @@ -104,6 +107,7 @@ CFLAGS-tst-codeset.c = -DOBJPFX=\"$(objp CFLAGS-tst-gettext3.c = -DOBJPFX=\"$(objpfx)\" CFLAGS-tst-gettext4.c = -DOBJPFX=\"$(objpfx)\" CFLAGS-tst-gettext5.c = -DOBJPFX=\"$(objpfx)\" +CFLAGS-tst-gettext6.c = -DOBJPFX=\"$(objpfx)\" ifeq ($(have-thread-library),yes) ifeq (yes,$(build-shared)) @@ -122,6 +126,7 @@ $(objpfx)tst-codeset.out: $(objpfx)tst-g $(objpfx)tst-gettext3.out: $(objpfx)tst-gettext.out $(objpfx)tst-gettext4.out: $(objpfx)tst-gettext.out $(objpfx)tst-gettext5.out: $(objpfx)tst-gettext.out +$(objpfx)tst-gettext6.out: $(objpfx)tst-gettext.out CPPFLAGS += -D'LOCALEDIR="$(msgcatdir)"' \ -D'LOCALE_ALIAS_PATH="$(msgcatdir)"' --- libc/intl/tst-gettext6.c 1 Jan 1970 00:00:00 -0000 +++ libc/intl/tst-gettext6.c 30 Mar 2008 21:42:59 -0000 @@ -0,0 +1,86 @@ +/* Test that gettext() in multithreaded applications works correctly. + Copyright (C) 2008 Free Software Foundation, Inc. + This file is part of the GNU C Library. + Contributed by Jakub Jelinek , 2008. + + The GNU C Library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + The GNU C Library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You should have received a copy of the GNU Lesser General Public + License along with the GNU C Library; if not, write to the Free + Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA + 02111-1307 USA. */ + +#include +#include +#include +#include +#include +#include +#include + +pthread_barrier_t b; + +static void * +tf (void *arg) +{ + pthread_barrier_wait (&b); + return gettext ("Operation not permitted"); +} + +int +test (void) +{ + pthread_t th[4]; + unsetenv ("LANGUAGE"); + unsetenv ("OUTPUT_CHARSET"); + textdomain ("tstgettext6"); + bindtextdomain ("tstgettext6", OBJPFX "domaindir"); + setlocale (LC_ALL, "ja_JP.UTF-8"); + pthread_barrier_init (&b, NULL, 4); + for (int i = 0; i < 4; i++) + if (pthread_create (&th[i], NULL, tf, NULL)) + { + puts ("pthread_create failed"); + return 1; + } + for (int i = 0; i < 4; i++) + pthread_join (th[i], NULL); + return 0; +} + +int +main (void) +{ + for (int i = 0; i < 300; i++) + { + pid_t p = fork (); + if (p == -1) + { + printf ("fork failed: %m\n"); + return 1; + } + if (p == 0) + _exit (test ()); + int status; + wait (&status); + if (WIFEXITED (status) && WEXITSTATUS (status) != 0) + { + printf ("child exited with %d\n", WEXITSTATUS (status)); + return 1; + } + else if (WIFSIGNALED (status)) + { + printf ("child killed by signal %d\n", WTERMSIG (status)); + return 1; + } + } + return 0; +} --- libc/intl/tst-gettext6.sh 1 Jan 1970 00:00:00 -0000 +++ libc/intl/tst-gettext6.sh 30 Mar 2008 21:42:59 -0000 @@ -0,0 +1,41 @@ +#! /bin/sh +# Test that gettext() in multithreaded applications works correctly. +# Copyright (C) 2008 Free Software Foundation, Inc. +# This file is part of the GNU C Library. +# + +# The GNU C Library is free software; you can redistribute it and/or +# modify it under the terms of the GNU Lesser General Public +# License as published by the Free Software Foundation; either +# version 2.1 of the License, or (at your option) any later version. + +# The GNU C Library is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# Lesser General Public License for more details. + +# You should have received a copy of the GNU Lesser General Public +# License along with the GNU C Library; if not, write to the Free +# Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA +# 02111-1307 USA. + +common_objpfx=$1 +run_program_prefix=$2 +objpfx=$3 + +LC_ALL=C +export LC_ALL + +# Create the domain directory. +mkdir -p ${objpfx}domaindir/ja_JP/LC_MESSAGES +# Populate it. +msgfmt -o ${objpfx}domaindir/ja_JP/LC_MESSAGES/tstgettext6.mo ../po/ja.po + +GCONV_PATH=${common_objpfx}iconvdata +export GCONV_PATH +LOCPATH=${common_objpfx}localedata +export LOCPATH + +${run_program_prefix} ${objpfx}tst-gettext6 > ${objpfx}tst-gettext6.out + +exit $? --- libc/localedata/Makefile 2 Oct 2007 17:19:40 -0000 1.107 +++ libc/localedata/Makefile 30 Mar 2008 21:46:25 -0000 @@ -133,7 +133,8 @@ LOCALES := de_DE.ISO-8859-1 de_DE.UTF-8 en_US.ISO-8859-1 ja_JP.EUC-JP da_DK.ISO-8859-1 \ hr_HR.ISO-8859-2 sv_SE.ISO-8859-1 ja_JP.SJIS fr_FR.ISO-8859-1 \ vi_VN.TCVN5712-1 nb_NO.ISO-8859-1 nn_NO.ISO-8859-1 \ - tr_TR.UTF-8 cs_CZ.UTF-8 zh_TW.EUC-TW fa_IR.UTF-8 fr_FR.UTF-8 + tr_TR.UTF-8 cs_CZ.UTF-8 zh_TW.EUC-TW fa_IR.UTF-8 fr_FR.UTF-8 \ + ja_JP.UTF-8 LOCALE_SRCS := $(shell echo "$(LOCALES)"|sed 's/\([^ .]*\)[^ ]*/\1/g') CHARMAPS := $(shell echo "$(LOCALES)" | \ sed -e 's/[^ .]*[.]\([^ ]*\)/\1/g' -e s/SJIS/SHIFT_JIS/g) Jakub