[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[commits] r3502 - in /fsf/trunk/libc: ./ debug/ include/ inet/ io/ io/bits/ misc/sys/ rt/ rt/bits/ stdio-common/ sysdeps/i386/i586/ sy...
- To: commits@xxxxxxxxxx
- Subject: [commits] r3502 - in /fsf/trunk/libc: ./ debug/ include/ inet/ io/ io/bits/ misc/sys/ rt/ rt/bits/ stdio-common/ sysdeps/i386/i586/ sy...
- From: eglibc@xxxxxxxxxx
- Date: Sun, 16 Sep 2007 07:03:19 -0000
Author: eglibc
Date: Sun Sep 16 00:03:17 2007
New Revision: 3502
Log:
Import glibc-mainline for 2007-09-16
Added:
fsf/trunk/libc/rt/bits/
fsf/trunk/libc/rt/bits/mqueue2.h
fsf/trunk/libc/sysdeps/unix/sysv/linux/i386/call_fallocate.S
Modified:
fsf/trunk/libc/ChangeLog
fsf/trunk/libc/Versions.def
fsf/trunk/libc/debug/Versions
fsf/trunk/libc/debug/fortify_fail.c
fsf/trunk/libc/include/stdio.h
fsf/trunk/libc/inet/inet_net.c
fsf/trunk/libc/io/bits/fcntl2.h
fsf/trunk/libc/io/fcntl.h
fsf/trunk/libc/misc/sys/cdefs.h
fsf/trunk/libc/rt/Makefile
fsf/trunk/libc/rt/Versions
fsf/trunk/libc/rt/mq_open.c
fsf/trunk/libc/rt/mqueue.h
fsf/trunk/libc/stdio-common/vfscanf.c
fsf/trunk/libc/sysdeps/i386/i586/memcpy.S
fsf/trunk/libc/sysdeps/i386/i586/mempcpy.S
fsf/trunk/libc/sysdeps/i386/i586/memset.S
fsf/trunk/libc/sysdeps/unix/sysv/linux/dl-osinfo.h
fsf/trunk/libc/sysdeps/unix/sysv/linux/i386/Makefile
fsf/trunk/libc/sysdeps/unix/sysv/linux/i386/posix_fallocate.c
fsf/trunk/libc/sysdeps/unix/sysv/linux/i386/posix_fallocate64.c
fsf/trunk/libc/sysdeps/unix/sysv/linux/i386/syscalls.list
fsf/trunk/libc/sysdeps/unix/sysv/linux/mq_open.c
Modified: fsf/trunk/libc/ChangeLog
==============================================================================
--- fsf/trunk/libc/ChangeLog (original)
+++ fsf/trunk/libc/ChangeLog Sun Sep 16 00:03:17 2007
@@ -1,3 +1,63 @@
+2003-11-01 Daniel Jacobowitz <dan@xxxxxxxxxx>
+
+ * sysdeps/unix/sysv/linux/dl-osinfo.h (_dl_discover_osversion): Don't
+ parse more than three parts of the version number.
+
+2007-09-15 Ulrich Drepper <drepper@xxxxxxxxxx>
+
+ * stdio-common/vfscanf.c (_IO_vfwscanf): Add support for 'm'
+ modifier. Patch by Jakub Jelinek.
+
+2007-08-26 Jakub Jelinek <jakub@xxxxxxxxxx>
+
+ * sysdeps/unix/sysv/linux/i386/Makefile (sysdep_routines): Add
+ call_fallocate in misc subdir.
+ * sysdeps/unix/sysv/linux/i386/call_fallocate.S: New file.
+ * sysdeps/unix/sysv/linux/i386/syscalls.list (fallocate64): Remove.
+ * sysdeps/unix/sysv/linux/i386/posix_fallocate.c: Use __call_fallocate
+ instead of __fallocate64.
+ * sysdeps/unix/sysv/linux/i386/posix_fallocate64.c: Likewise.
+
+2007-09-15 Jakub Jelinek <jakub@xxxxxxxxxx>
+
+ * rt/Versions (librt): Export __mq_open_2@@GLIBC_2.7.
+ * rt/Makefile (headers): Add bits/mqueue2.h.
+ * rt/mqueue.h: Include bits/mqueue2.h if -D_FORTIFY_SOURCE=2,
+ optimizing with GCC and __va_arg_pack_len is defined.
+ * rt/bits/mqueue2.h: New file.
+ * rt/mq_open.c (__mq_open): Renamed from mq_open.
+ (mq_open): New strong_alias.
+ (__mq_open_2): New function.
+ * sysdeps/unix/sysv/linux/mq_open.c (__mq_open): Renamed from mq_open.
+ (mq_open): New strong_alias.
+ (__mq_open_2): New function.
+ * debug/Versions (libc): Export __fortify_fail@@GLIBC_PRIVATE.
+ * Versions.def (librt): Add GLIBC_2.7 version.
+ * debug/fortify_fail.c (__fortify_fail): Add libc_hidden_def.
+ * include/stdio.h (__fortify_fail): Add libc_hidden_proto.
+
+ * misc/sys/cdefs.h (__errordecl, __va_arg_pack_len): Define.
+ * io/fcntl.h: Include bits/fcntl2.h when __va_arg_pack_len
+ is defined rather than when not C++.
+ * io/bits/fcntl2.h (__open_alias, __open64_alias, __openat_alias,
+ __openat64_alias): New redirects.
+ (__open_too_many_args, __open_missing_mode, __open64_too_many_args,
+ __open64_missing_mode, __openat_too_many_args, __openat_missing_mode,
+ __openat64_too_many_args, __openat64_missing_mode): New __errordecls.
+ (open, open64, openat, openat64): Rewrite as __extern_always_inline
+ functions instead of function-like macros.
+
+2007-09-14 H.J. Lu <hongjiu.lu@xxxxxxxxx>
+
+ * sysdeps/i386/i586/memcpy.S (__memcpy_chk): New definition.
+ * sysdeps/i386/i586/mempcpy.S (__memcpy_chk): New definition.
+ * sysdeps/i386/i586/memset.S (__memset_chk): New definition.
+
+2007-09-15 Mike Frysinger <vapier@xxxxxxxxxx>
+
+ * inet/inet_net.c: Reset digit to 0 for inputs starting with "0x".
+ * inet/tst-network.c (tests): Add edge case tests for "0", "0x", "0x0".
+
2007-09-14 Mike Frysinger <vapier@xxxxxxxxxx>
* inet/tst-network.c: Increment ERRORS for failing tests.
Modified: fsf/trunk/libc/Versions.def
==============================================================================
--- fsf/trunk/libc/Versions.def (original)
+++ fsf/trunk/libc/Versions.def Sun Sep 16 00:03:17 2007
@@ -100,6 +100,7 @@
GLIBC_2.3.3
GLIBC_2.3.4
GLIBC_2.4
+ GLIBC_2.7
}
libutil {
GLIBC_2.0
Modified: fsf/trunk/libc/debug/Versions
==============================================================================
--- fsf/trunk/libc/debug/Versions (original)
+++ fsf/trunk/libc/debug/Versions Sun Sep 16 00:03:17 2007
@@ -42,4 +42,7 @@
GLIBC_2.7 {
__fread_chk; __fread_unlocked_chk;
}
+ GLIBC_PRIVATE {
+ __fortify_fail;
+ }
}
Modified: fsf/trunk/libc/debug/fortify_fail.c
==============================================================================
--- fsf/trunk/libc/debug/fortify_fail.c (original)
+++ fsf/trunk/libc/debug/fortify_fail.c Sun Sep 16 00:03:17 2007
@@ -32,3 +32,4 @@
__libc_message (2, "*** %s ***: %s terminated\n",
msg, __libc_argv[0] ?: "<unknown>");
}
+libc_hidden_def (__fortify_fail)
Modified: fsf/trunk/libc/include/stdio.h
==============================================================================
--- fsf/trunk/libc/include/stdio.h (original)
+++ fsf/trunk/libc/include/stdio.h Sun Sep 16 00:03:17 2007
@@ -67,6 +67,7 @@
__attribute__ ((__noreturn__));
extern void __libc_message (int do_abort, __const char *__fnt, ...);
extern void __fortify_fail (const char *msg) __attribute__ ((noreturn));
+libc_hidden_proto (__fortify_fail)
/* Acquire ownership of STREAM. */
extern void __flockfile (FILE *__stream);
Modified: fsf/trunk/libc/inet/inet_net.c
==============================================================================
--- fsf/trunk/libc/inet/inet_net.c (original)
+++ fsf/trunk/libc/inet/inet_net.c Sun Sep 16 00:03:17 2007
@@ -55,7 +55,7 @@
if (*cp == '0')
digit = 1, base = 8, cp++;
if (*cp == 'x' || *cp == 'X')
- base = 16, cp++;
+ digit = 0, base = 16, cp++;
while ((c = *cp) != 0) {
if (isdigit(c)) {
if (base == 8 && (c == '8' || c == '9'))
Modified: fsf/trunk/libc/io/bits/fcntl2.h
==============================================================================
--- fsf/trunk/libc/io/bits/fcntl2.h (original)
+++ fsf/trunk/libc/io/bits/fcntl2.h Sun Sep 16 00:03:17 2007
@@ -25,161 +25,149 @@
appropriate third/fourth parameter. */
#ifndef __USE_FILE_OFFSET64
extern int __open_2 (__const char *__path, int __oflag) __nonnull ((1));
+extern int __REDIRECT (__open_alias, (__const char *__path, int __oflag, ...),
+ open) __nonnull ((1));
#else
-extern int __REDIRECT (__open_2, (__const char *__file, int __oflag),
+extern int __REDIRECT (__open_2, (__const char *__path, int __oflag),
__open64_2) __nonnull ((1));
+extern int __REDIRECT (__open_alias, (__const char *__path, int __oflag, ...),
+ open64) __nonnull ((1));
#endif
+__errordecl (__open_too_many_args,
+ "open can be called either with 2 or 3 arguments, not more");
+__errordecl (__open_missing_mode,
+ "open with O_CREAT in second argument needs 3 arguments");
-#define open(fname, flags, ...) \
- (__extension__ \
- ({ int ___r; \
- /* If the compiler complains about an invalid type, excess elements, \
- etc. in the initialization this means a parameter of the wrong type \
- has been passed to open. */ \
- int ___arr[] = { __VA_ARGS__ }; \
- if (__builtin_constant_p (flags) && ((flags) & O_CREAT) != 0) \
- { \
- /* If the compiler complains about the size of this array type the \
- mode parameter is missing since O_CREAT has been used. */ \
- typedef int __open_missing_mode[((flags) & O_CREAT) != 0 \
- ? ((long int) sizeof (___arr) \
- - (long int) sizeof (int)) : 1];\
- } \
- if (sizeof (___arr) == 0) \
- { \
- if (__builtin_constant_p (flags) && ((flags) & O_CREAT) == 0) \
- ___r = open (fname, flags); \
- else \
- ___r = __open_2 (fname, flags); \
- } \
- else \
- { \
- /* If the compiler complains about the size of this array type too \
- many parameters have been passed to open. */ \
- typedef int __open_too_many_args[-(sizeof (___arr) \
- > sizeof (int))]; \
- ___r = open (fname, flags, ___arr[0]); \
- } \
- ___r; \
- }))
+__extern_always_inline int
+open (__const char *__path, int __oflag, ...)
+{
+ if (__va_arg_pack_len () > 1)
+ __open_too_many_args ();
+
+ if (__builtin_constant_p (__oflag))
+ {
+ if ((__oflag & O_CREAT) != 0 && __va_arg_pack_len () < 1)
+ {
+ __open_missing_mode ();
+ return __open_2 (__path, __oflag);
+ }
+ return __open_alias (__path, __oflag, __va_arg_pack ());
+ }
+
+ if (__va_arg_pack_len () < 1)
+ return __open_2 (__path, __oflag);
+
+ return __open_alias (__path, __oflag, __va_arg_pack ());
+}
#ifdef __USE_LARGEFILE64
extern int __open64_2 (__const char *__path, int __oflag) __nonnull ((1));
+extern int __REDIRECT (__open64_alias, (__const char *__path, int __oflag,
+ ...), open64) __nonnull ((1));
+__errordecl (__open64_too_many_args,
+ "open64 can be called either with 2 or 3 arguments, not more");
+__errordecl (__open64_missing_mode,
+ "open64 with O_CREAT in second argument needs 3 arguments");
-# define open64(fname, flags, ...) \
- (__extension__ \
- ({ int ___r; \
- /* If the compiler complains about an invalid type, excess elements, \
- etc. in the initialization this means a parameter of the wrong type \
- has been passed to open64. */ \
- int ___arr[] = { __VA_ARGS__ }; \
- if (__builtin_constant_p (flags) && ((flags) & O_CREAT) != 0) \
- { \
- /* If the compiler complains about the size of this array type the \
- mode parameter is missing since O_CREAT has been used. */ \
- typedef int __open_missing_mode[((flags) & O_CREAT) != 0 \
- ? ((long int) sizeof (___arr) \
- - (long int) sizeof (int)) : 1];\
- } \
- if (sizeof (___arr) == 0) \
- { \
- if (__builtin_constant_p (flags) && ((flags) & O_CREAT) == 0) \
- ___r = open64 (fname, flags); \
- else \
- ___r = __open64_2 (fname, flags); \
- } \
- else \
- { \
- /* If the compiler complains about the size of this array type too \
- many parameters have been passed to open64. */ \
- typedef int __open_too_many_args[-(sizeof (___arr) \
- > sizeof (int))]; \
- ___r = open64 (fname, flags, ___arr[0]); \
- } \
- ___r; \
- }))
+__extern_always_inline int
+open64 (__const char *__path, int __oflag, ...)
+{
+ if (__va_arg_pack_len () > 1)
+ __open64_too_many_args ();
+
+ if (__builtin_constant_p (__oflag))
+ {
+ if ((__oflag & O_CREAT) != 0 && __va_arg_pack_len () < 1)
+ {
+ __open64_missing_mode ();
+ return __open64_2 (__path, __oflag);
+ }
+ return __open64_alias (__path, __oflag, __va_arg_pack ());
+ }
+
+ if (__va_arg_pack_len () < 1)
+ return __open64_2 (__path, __oflag);
+
+ return __open64_alias (__path, __oflag, __va_arg_pack ());
+}
#endif
+
#ifdef __USE_ATFILE
# ifndef __USE_FILE_OFFSET64
extern int __openat_2 (int __fd, __const char *__path, int __oflag)
__nonnull ((2));
+extern int __REDIRECT (__openat_alias, (int __fd, __const char *__path,
+ int __oflag, ...), openat)
+ __nonnull ((2));
# else
-extern int __REDIRECT (__openat_2, (int __fd, __const char *__file,
+extern int __REDIRECT (__openat_2, (int __fd, __const char *__path,
int __oflag), __openat64_2)
__nonnull ((2));
+extern int __REDIRECT (__openat_alias, (int __fd, __const char *__path,
+ int __oflag, ...), openat64)
+ __nonnull ((2));
# endif
+__errordecl (__openat_too_many_args,
+ "openat can be called either with 3 or 4 arguments, not more");
+__errordecl (__openat_missing_mode,
+ "openat with O_CREAT in third argument needs 4 arguments");
-# define openat(fd, fname, flags, ...) \
- (__extension__ \
- ({ int ___r; \
- /* If the compiler complains about an invalid type, excess elements, \
- etc. in the initialization this means a parameter of the wrong type \
- has been passed to openat. */ \
- int ___arr[] = { __VA_ARGS__ }; \
- if (__builtin_constant_p (flags) && ((flags) & O_CREAT) != 0) \
- { \
- /* If the compiler complains about the size of this array type the \
- mode parameter is missing since O_CREAT has been used. */ \
- typedef int __open_missing_mode[((flags) & O_CREAT) != 0 \
- ? ((long int) sizeof (___arr) \
- - (long int) sizeof (int)) : 1];\
- } \
- if (sizeof (___arr) == 0) \
- { \
- if (__builtin_constant_p (flags) && ((flags) & O_CREAT) == 0) \
- ___r = openat (fd, fname, flags); \
- else \
- ___r = __openat_2 (fd, fname, flags); \
- } \
- else \
- { \
- /* If the compiler complains about the size of this array type too \
- many parameters have been passed to openat. */ \
- typedef int __open_too_many_args[-(sizeof (___arr) \
- > sizeof (int))]; \
- ___r = openat (fd, fname, flags, ___arr[0]); \
- } \
- ___r; \
- }))
+__extern_always_inline int
+openat (int __fd, __const char *__path, int __oflag, ...)
+{
+ if (__va_arg_pack_len () > 1)
+ __openat_too_many_args ();
+
+ if (__builtin_constant_p (__oflag))
+ {
+ if ((__oflag & O_CREAT) != 0 && __va_arg_pack_len () < 1)
+ {
+ __openat_missing_mode ();
+ return __openat_2 (__fd, __path, __oflag);
+ }
+ return __openat_alias (__fd, __path, __oflag, __va_arg_pack ());
+ }
+
+ if (__va_arg_pack_len () < 1)
+ return __openat_2 (__fd, __path, __oflag);
+
+ return __openat_alias (__fd, __path, __oflag, __va_arg_pack ());
+}
# ifdef __USE_LARGEFILE64
extern int __openat64_2 (int __fd, __const char *__path, int __oflag)
__nonnull ((2));
+extern int __REDIRECT (__openat64_alias, (int __fd, __const char *__path,
+ int __oflag, ...), openat64)
+ __nonnull ((2));
+__errordecl (__openat64_too_many_args,
+ "openat64 can be called either with 3 or 4 arguments, not more");
+__errordecl (__openat64_missing_mode,
+ "openat64 with O_CREAT in third argument needs 4 arguments");
-# define openat64(fd, fname, flags, ...) \
- (__extension__ \
- ({ int ___r; \
- /* If the compiler complains about an invalid type, excess elements, \
- etc. in the initialization this means a parameter of the wrong type \
- has been passed to openat64. */ \
- int ___arr[] = { __VA_ARGS__ }; \
- if (__builtin_constant_p (flags) && ((flags) & O_CREAT) != 0) \
- { \
- /* If the compiler complains about the size of this array type the \
- mode parameter is missing since O_CREAT has been used. */ \
- typedef int __open_missing_mode[((flags) & O_CREAT) != 0 \
- ? ((long int) sizeof (___arr) \
- - (long int) sizeof (int)) : 1];\
- } \
- if (sizeof (___arr) == 0) \
- { \
- if (__builtin_constant_p (flags) && ((flags) & O_CREAT) == 0) \
- ___r = openat64 (fd, fname, flags); \
- else \
- ___r = __openat64_2 (fd, fname, flags); \
- } \
- else \
- { \
- /* If the compiler complains about the size of this array type too \
- many parameters have been passed to openat64. */ \
- typedef int __open_too_many_args[-(sizeof (___arr) \
- > sizeof (int))]; \
- ___r = openat64 (fd, fname, flags, ___arr[0]); \
- } \
- ___r; \
- }))
+__extern_always_inline int
+openat64 (int __fd, __const char *__path, int __oflag, ...)
+{
+ if (__va_arg_pack_len () > 1)
+ __openat64_too_many_args ();
+
+ if (__builtin_constant_p (__oflag))
+ {
+ if ((__oflag & O_CREAT) != 0 && __va_arg_pack_len () < 1)
+ {
+ __openat64_missing_mode ();
+ return __openat64_2 (__fd, __path, __oflag);
+ }
+ return __openat64_alias (__fd, __path, __oflag, __va_arg_pack ());
+ }
+
+ if (__va_arg_pack_len () < 1)
+ return __openat64_2 (__fd, __path, __oflag);
+
+ return __openat64_alias (__fd, __path, __oflag, __va_arg_pack ());
+}
# endif
#endif
Modified: fsf/trunk/libc/io/fcntl.h
==============================================================================
--- fsf/trunk/libc/io/fcntl.h (original)
+++ fsf/trunk/libc/io/fcntl.h Sun Sep 16 00:03:17 2007
@@ -211,9 +211,9 @@
#endif
-/* Define some macros helping to catch common problems. */
+/* Define some inlines helping to catch common problems. */
#if __USE_FORTIFY_LEVEL > 0 && defined __extern_always_inline \
- && !defined __cplusplus
+ && defined __va_arg_pack_len
# include <bits/fcntl2.h>
#endif
Modified: fsf/trunk/libc/misc/sys/cdefs.h
==============================================================================
--- fsf/trunk/libc/misc/sys/cdefs.h (original)
+++ fsf/trunk/libc/misc/sys/cdefs.h Sun Sep 16 00:03:17 2007
@@ -132,6 +132,7 @@
#define __bos(ptr) __builtin_object_size (ptr, __USE_FORTIFY_LEVEL > 1)
#define __bos0(ptr) __builtin_object_size (ptr, 0)
#define __warndecl(name, msg) extern void name (void)
+#define __errordecl(name, msg) extern void name (void)
/* Support for flexible arrays. */
@@ -296,6 +297,7 @@
__extern_always_inline function to some other vararg function. */
#if __GNUC_PREREQ (4,3)
# define __va_arg_pack() __builtin_va_arg_pack ()
+# define __va_arg_pack_len() __builtin_va_arg_pack_len ()
#endif
/* It is possible to compile containing GCC extensions even if GCC is
Modified: fsf/trunk/libc/rt/Makefile
==============================================================================
--- fsf/trunk/libc/rt/Makefile (original)
+++ fsf/trunk/libc/rt/Makefile Sun Sep 16 00:03:17 2007
@@ -1,4 +1,4 @@
-# Copyright (C) 1997-2004, 2006 Free Software Foundation, Inc.
+# Copyright (C) 1997-2004, 2006, 2007 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
@@ -21,7 +21,7 @@
#
subdir := rt
-headers := aio.h mqueue.h bits/mqueue.h
+headers := aio.h mqueue.h bits/mqueue.h bits/mqueue2.h
aio-routines := aio_cancel aio_error aio_fsync aio_misc aio_read \
aio_read64 aio_return aio_suspend aio_write \
Modified: fsf/trunk/libc/rt/Versions
==============================================================================
--- fsf/trunk/libc/rt/Versions (original)
+++ fsf/trunk/libc/rt/Versions Sun Sep 16 00:03:17 2007
@@ -22,4 +22,7 @@
mq_open; mq_close; mq_unlink; mq_getattr; mq_setattr;
mq_notify; mq_send; mq_receive; mq_timedsend; mq_timedreceive;
}
+ GLIBC_2.7 {
+ __mq_open_2;
+ }
}
Added: fsf/trunk/libc/rt/bits/mqueue2.h
==============================================================================
--- fsf/trunk/libc/rt/bits/mqueue2.h (added)
+++ fsf/trunk/libc/rt/bits/mqueue2.h Sun Sep 16 00:03:17 2007
@@ -1,0 +1,56 @@
+/* Checking macros for mq functions.
+ Copyright (C) 2007 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. */
+
+#ifndef _FCNTL_H
+# error "Never include <bits/mqueue2.h> directly; use <mqueue.h> instead."
+#endif
+
+/* Check that calls to mq_open with O_CREAT set have an appropriate third and fourth
+ parameter. */
+extern mqd_t mq_open (__const char *__name, int __oflag, ...)
+ __THROW __nonnull ((1));
+extern mqd_t __mq_open_2 (__const char *__name, int __oflag) __nonnull ((1));
+extern mqd_t __REDIRECT (__mq_open_alias, (__const char *__name, int __oflag, ...),
+ mq_open) __nonnull ((1));
+__errordecl (__mq_open_wrong_number_of_args,
+ "mq_open can be called either with 2 or 4 arguments");
+__errordecl (__mq_open_missing_mode_and_attr,
+ "mq_open with O_CREAT in second argument needs 4 arguments");
+
+__extern_always_inline mqd_t
+mq_open (__const char *__name, int __oflag, ...)
+{
+ if (__va_arg_pack_len () != 0 && __va_arg_pack_len () != 2)
+ __mq_open_wrong_number_of_args ();
+
+ if (__builtin_constant_p (__oflag))
+ {
+ if ((__oflag & O_CREAT) != 0 && __va_arg_pack_len () == 0)
+ {
+ __mq_open_missing_mode_and_attr ();
+ return __mq_open_2 (__name, __oflag);
+ }
+ return __mq_open_alias (__name, __oflag, __va_arg_pack ());
+ }
+
+ if (__va_arg_pack_len () == 0)
+ return __mq_open_2 (__name, __oflag);
+
+ return __mq_open_alias (__name, __oflag, __va_arg_pack ());
+}
Modified: fsf/trunk/libc/rt/mq_open.c
==============================================================================
--- fsf/trunk/libc/rt/mq_open.c (original)
+++ fsf/trunk/libc/rt/mq_open.c Sun Sep 16 00:03:17 2007
@@ -1,4 +1,4 @@
-/* Copyright (C) 2004 Free Software Foundation, Inc.
+/* Copyright (C) 2004, 2007 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
@@ -18,6 +18,7 @@
#include <errno.h>
#include <mqueue.h>
+#include <stdio.h>
/* Establish connection between a process and a message queue NAME and
return message queue descriptor or (mqd_t) -1 on error. OFLAG determines
@@ -27,10 +28,21 @@
attributes. If the fourth argument is NULL, default attributes are
used. */
mqd_t
-mq_open (const char *name, int oflag, ...)
+__mq_open (const char *name, int oflag, ...)
{
__set_errno (ENOSYS);
return (mqd_t) -1;
}
+strong_alias (__mq_open, mq_open);
stub_warning (mq_open)
+
+mqd_t
+__mq_open_2 (const char *name, int oflag)
+{
+ if (oflag & O_CREAT)
+ __fortify_fail ("invalid mq_open call: O_CREAT without mode and attr");
+
+ return __mq_open (name, oflag);
+}
+stub_warning (__mq_open_2)
#include <stub-tag.h>
Modified: fsf/trunk/libc/rt/mqueue.h
==============================================================================
--- fsf/trunk/libc/rt/mqueue.h (original)
+++ fsf/trunk/libc/rt/mqueue.h Sun Sep 16 00:03:17 2007
@@ -90,6 +90,12 @@
__nonnull ((2, 5));
#endif
+/* Define some inlines helping to catch common problems. */
+#if __USE_FORTIFY_LEVEL > 0 && defined __extern_always_inline \
+ && defined __va_arg_pack_len
+# include <bits/mqueue2.h>
+#endif
+
__END_DECLS
#endif /* mqueue.h */
Modified: fsf/trunk/libc/stdio-common/vfscanf.c
==============================================================================
--- fsf/trunk/libc/stdio-common/vfscanf.c (original)
+++ fsf/trunk/libc/stdio-common/vfscanf.c Sun Sep 16 00:03:17 2007
@@ -60,12 +60,13 @@
#define NOSKIP 0x0020 /* do not skip blanks */
#define NUMBER_SIGNED 0x0040 /* signed integer */
#define GROUP 0x0080 /* ': group numbers */
-#define MALLOC 0x0100 /* a: malloc strings */
+#define GNU_MALLOC 0x0100 /* a: malloc strings */
#define CHAR 0x0200 /* hh: char */
#define I18N 0x0400 /* I: use locale's digits */
#define HEXA_FLOAT 0x0800 /* hexadecimal float */
#define READ_POINTER 0x1000 /* this is a pointer value */
-
+#define POSIX_MALLOC 0x2000 /* m: malloc strings */
+#define MALLOC (GNU_MALLOC | POSIX_MALLOC)
#include <locale/localeinfo.h>
#include <libioP.h>
@@ -146,6 +147,21 @@
if (done == 0) done = EOF; \
goto errout; \
} while (0)
+#define add_ptr_to_free(ptr) \
+ do \
+ { \
+ if (ptrs_to_free == NULL \
+ || ptrs_to_free->count == (sizeof (ptrs_to_free->ptrs) \
+ / sizeof (ptrs_to_free->ptrs[0]))) \
+ { \
+ struct ptrs_to_free *new_ptrs = alloca (sizeof (*ptrs_to_free)); \
+ new_ptrs->count = 0; \
+ new_ptrs->next = ptrs_to_free; \
+ ptrs_to_free = new_ptrs; \
+ } \
+ ptrs_to_free->ptrs[ptrs_to_free->count++] = (ptr); \
+ } \
+ while (0)
#define ARGCHECK(s, format) \
do \
{ \
@@ -169,6 +185,12 @@
_IO_funlockfile (S); \
__libc_cleanup_region_end (0)
+struct ptrs_to_free
+{
+ size_t count;
+ struct ptrs_to_free *next;
+ char **ptrs[32];
+};
/* Read formatted input from S according to the format string
FORMAT, using the argument list in ARG.
@@ -218,6 +240,7 @@
#else
const char *thousands;
#endif
+ struct ptrs_to_free *ptrs_to_free = NULL;
/* State for the conversions. */
mbstate_t state;
/* Integral holding variables. */
@@ -493,8 +516,11 @@
}
/* String conversions (%s, %[) take a `char **'
arg and fill it in with a malloc'd pointer. */
- flags |= MALLOC;
+ flags |= GNU_MALLOC;
break;
+ case L_('m'):
+ flags |= POSIX_MALLOC;
+ break;
case L_('z'):
if (need_longlong && sizeof (size_t) > sizeof (unsigned long int))
flags |= LONGDBL;
@@ -741,6 +767,10 @@
if (flags & MALLOC) \
{ \
/* The string is to be stored in a malloc'd buffer. */ \
+ /* For %mS using char ** is actually wrong, but \
+ shouldn't make a difference on any arch glibc \
+ supports and would unnecessarily complicate \
+ things. */ \
strptr = ARG (char **); \
if (strptr == NULL) \
conv_error (); \
@@ -748,6 +778,10 @@
strsize = 100; \
*strptr = (char *) malloc (strsize * sizeof (Type)); \
Str = (Type *) *strptr; \
+ if (Str != NULL) \
+ add_ptr_to_free (strptr); \
+ else if (flags & POSIX_MALLOC) \
+ goto reteof; \
} \
else \
Str = ARG (Type *); \
@@ -796,10 +830,13 @@
strleng + MB_CUR_MAX);
if (newstr == NULL)
{
+ if (flags & POSIX_MALLOC)
+ goto reteof;
/* We lose. Oh well. Terminate the
string and stop converting,
so at least we don't skip any input. */
((char *) (*strptr))[strleng] = '\0';
+ strptr = NULL;
++done;
conv_error ();
}
@@ -843,10 +880,13 @@
str = (char *) realloc (*strptr, strsize + 1);
if (str == NULL)
{
+ if (flags & POSIX_MALLOC)
+ goto reteof;
/* We lose. Oh well. Terminate the
string and stop converting,
so at least we don't skip any input. */
((char *) (*strptr))[strsize - 1] = '\0';
+ strptr = NULL;
++done;
conv_error ();
}
@@ -886,10 +926,13 @@
newstr = (char *) realloc (*strptr, strleng + n + 1);
if (newstr == NULL)
{
+ if (flags & POSIX_MALLOC)
+ goto reteof;
/* We lose. Oh well. Terminate the string
and stop converting, so at least we don't
skip any input. */
((char *) (*strptr))[strleng] = '\0';
+ strptr = NULL;
++done;
conv_error ();
}
@@ -911,6 +954,7 @@
if (cp != NULL)
*strptr = cp;
}
+ strptr = NULL;
++done;
}
@@ -964,10 +1008,13 @@
* sizeof (wchar_t));
if (wstr == NULL)
{
+ if (flags & POSIX_MALLOC)
+ goto reteof;
/* We lose. Oh well. Terminate the string
and stop converting, so at least we don't
skip any input. */
((wchar_t *) (*strptr))[strsize - 1] = L'\0';
+ strptr = NULL;
++done;
conv_error ();
}
@@ -1033,10 +1080,13 @@
* sizeof (wchar_t)));
if (wstr == NULL)
{
+ if (flags & POSIX_MALLOC)
+ goto reteof;
/* We lose. Oh well. Terminate the
string and stop converting, so at
least we don't skip any input. */
((wchar_t *) (*strptr))[strsize - 1] = L'\0';
+ strptr = NULL;
++done;
conv_error ();
}
@@ -1072,6 +1122,7 @@
if (cp != NULL)
*strptr = (char *) cp;
}
+ strptr = NULL;
++done;
}
@@ -2219,10 +2270,13 @@
* sizeof (wchar_t));
if (wstr == NULL)
{
+ if (flags & POSIX_MALLOC)
+ goto reteof;
/* We lose. Oh well. Terminate the string
and stop converting, so at least we don't
skip any input. */
((wchar_t *) (*strptr))[strsize - 1] = L'\0';
+ strptr = NULL;
++done;
conv_error ();
}
@@ -2298,10 +2352,13 @@
* sizeof (wchar_t)));
if (wstr == NULL)
{
+ if (flags & POSIX_MALLOC)
+ goto reteof;
/* We lose. Oh well. Terminate the
string and stop converting,
so at least we don't skip any input. */
((wchar_t *) (*strptr))[strsize - 1] = L'\0';
+ strptr = NULL;
++done;
conv_error ();
}
@@ -2349,6 +2406,7 @@
if (cp != NULL)
*strptr = (char *) cp;
}
+ strptr = NULL;
++done;
}
@@ -2435,10 +2493,13 @@
strleng + MB_CUR_MAX);
if (newstr == NULL)
{
+ if (flags & POSIX_MALLOC)
+ goto reteof;
/* We lose. Oh well. Terminate the string
and stop converting, so at least we don't
skip any input. */
((char *) (*strptr))[strleng] = '\0';
+ strptr = NULL;
++done;
conv_error ();
}
@@ -2497,10 +2558,13 @@
newsize = strsize + 1;
goto allocagain;
}
+ if (flags & POSIX_MALLOC)
+ goto reteof;
/* We lose. Oh well. Terminate the
string and stop converting,
so at least we don't skip any input. */
((char *) (*strptr))[strsize - 1] = '\0';
+ strptr = NULL;
++done;
conv_error ();
}
@@ -2537,10 +2601,13 @@
newstr = (char *) realloc (*strptr, strleng + n + 1);
if (newstr == NULL)
{
+ if (flags & POSIX_MALLOC)
+ goto reteof;
/* We lose. Oh well. Terminate the string
and stop converting, so at least we don't
skip any input. */
((char *) (*strptr))[strleng] = '\0';
+ strptr = NULL;
++done;
conv_error ();
}
@@ -2562,6 +2629,7 @@
if (cp != NULL)
*strptr = cp;
}
+ strptr = NULL;
++done;
}
@@ -2600,6 +2668,31 @@
if (errp != NULL)
*errp |= errval;
+ if (done == EOF)
+ {
+ reteof:
+ if (__builtin_expect (ptrs_to_free != NULL, 0))
+ {
+ struct ptrs_to_free *p = ptrs_to_free;
+ while (p != NULL)
+ {
+ for (size_t cnt = 0; cnt < p->count; ++cnt)
+ {
+ free (*p->ptrs[cnt]);
+ *p->ptrs[cnt] = NULL;
+ }
+ p = p->next;
+ free (ptrs_to_free);
+ ptrs_to_free = p;
+ }
+ }
+ return EOF;
+ }
+ else if (__builtin_expect (strptr != NULL, 0))
+ {
+ free (*strptr);
+ *strptr = NULL;
+ }
return done;
}
Modified: fsf/trunk/libc/sysdeps/i386/i586/memcpy.S
==============================================================================
--- fsf/trunk/libc/sysdeps/i386/i586/memcpy.S (original)
+++ fsf/trunk/libc/sysdeps/i386/i586/memcpy.S Sun Sep 16 00:03:17 2007
@@ -35,6 +35,13 @@
#define LEN SRC+PTR_SIZE
.text
+#if defined PIC && !defined NOT_IN_libc
+ENTRY (__memcpy_chk)
+ movl 12(%esp), %eax
+ cmpl %eax, 16(%esp)
+ jb HIDDEN_JUMPTARGET (__chk_fail)
+END (__memcpy_chk)
+#endif
ENTRY (BP_SYM (memcpy))
ENTER
Modified: fsf/trunk/libc/sysdeps/i386/i586/mempcpy.S
==============================================================================
--- fsf/trunk/libc/sysdeps/i386/i586/mempcpy.S (original)
+++ fsf/trunk/libc/sysdeps/i386/i586/mempcpy.S Sun Sep 16 00:03:17 2007
@@ -1,4 +1,5 @@
#define memcpy __mempcpy
+#define __memcpy_chk __mempcpy_chk
#include <sysdeps/i386/i586/memcpy.S>
libc_hidden_def (BP_SYM (__mempcpy))
Modified: fsf/trunk/libc/sysdeps/i386/i586/memset.S
==============================================================================
--- fsf/trunk/libc/sysdeps/i386/i586/memset.S (original)
+++ fsf/trunk/libc/sysdeps/i386/i586/memset.S Sun Sep 16 00:03:17 2007
@@ -38,6 +38,13 @@
#endif
.text
+#if defined PIC && !defined NOT_IN_libc && !BZERO_P
+ENTRY (__memset_chk)
+ movl 12(%esp), %eax
+ cmpl %eax, 16(%esp)
+ jb HIDDEN_JUMPTARGET (__chk_fail)
+END (__memset_chk)
+#endif
ENTRY (BP_SYM (memset))
ENTER
Modified: fsf/trunk/libc/sysdeps/unix/sysv/linux/dl-osinfo.h
==============================================================================
--- fsf/trunk/libc/sysdeps/unix/sysv/linux/dl-osinfo.h (original)
+++ fsf/trunk/libc/sysdeps/unix/sysv/linux/dl-osinfo.h Sun Sep 16 00:03:17 2007
@@ -121,7 +121,7 @@
version <<= 8;
version |= here;
- if (*cp++ != '.')
+ if (*cp++ != '.' || parts == 3)
/* Another part following? */
break;
}
Modified: fsf/trunk/libc/sysdeps/unix/sysv/linux/i386/Makefile
==============================================================================
Binary files - no diff available.
Added: fsf/trunk/libc/sysdeps/unix/sysv/linux/i386/call_fallocate.S
==============================================================================
--- fsf/trunk/libc/sysdeps/unix/sysv/linux/i386/call_fallocate.S (added)
+++ fsf/trunk/libc/sysdeps/unix/sysv/linux/i386/call_fallocate.S Sun Sep 16 00:03:17 2007
@@ -1,0 +1,7 @@
+#include <sysdep.h>
+
+#ifdef __NR_fallocate
+PSEUDO_ERRVAL (__call_fallocate, fallocate, 6)
+ ret_ERRVAL
+PSEUDO_END_ERRVAL(__call_fallocate)
+#endif
Modified: fsf/trunk/libc/sysdeps/unix/sysv/linux/i386/posix_fallocate.c
==============================================================================
--- fsf/trunk/libc/sysdeps/unix/sysv/linux/i386/posix_fallocate.c (original)
+++ fsf/trunk/libc/sysdeps/unix/sysv/linux/i386/posix_fallocate.c Sun Sep 16 00:03:17 2007
@@ -28,7 +28,7 @@
int __have_fallocate attribute_hidden;
#endif
-extern int __fallocate64 (int fd, int mode, __off64_t offset, __off64_t len)
+extern int __call_fallocate (int fd, int mode, __off64_t offset, __off64_t len)
attribute_hidden;
/* Reserve storage for the data of the file associated with FD. */
@@ -40,7 +40,7 @@
if (__builtin_expect (__have_fallocate >= 0, 1))
# endif
{
- int res = __fallocate64 (fd, 0, offset, len);
+ int res = __call_fallocate (fd, 0, offset, len);
if (! res)
return 0;
Modified: fsf/trunk/libc/sysdeps/unix/sysv/linux/i386/posix_fallocate64.c
==============================================================================
--- fsf/trunk/libc/sysdeps/unix/sysv/linux/i386/posix_fallocate64.c (original)
+++ fsf/trunk/libc/sysdeps/unix/sysv/linux/i386/posix_fallocate64.c Sun Sep 16 00:03:17 2007
@@ -30,7 +30,7 @@
extern int __have_fallocate attribute_hidden;
#endif
-extern int __fallocate64 (int fd, int mode, __off64_t offset, __off64_t len)
+extern int __call_fallocate (int fd, int mode, __off64_t offset, __off64_t len)
attribute_hidden;
/* Reserve storage for the data of the file associated with FD. */
@@ -42,7 +42,7 @@
if (__builtin_expect (__have_fallocate >= 0, 1))
# endif
{
- int res = __fallocate64 (fd, 0, offset, len);
+ int res = __call_fallocate (fd, 0, offset, len);
if (! res)
return 0;
Modified: fsf/trunk/libc/sysdeps/unix/sysv/linux/i386/syscalls.list
==============================================================================
--- fsf/trunk/libc/sysdeps/unix/sysv/linux/i386/syscalls.list (original)
+++ fsf/trunk/libc/sysdeps/unix/sysv/linux/i386/syscalls.list Sun Sep 16 00:03:17 2007
@@ -6,4 +6,3 @@
oldgetrlimit EXTRA getrlimit i:ip __old_getrlimit getrlimit@xxxxxxxxx
oldsetrlimit EXTRA setrlimit i:ip __old_setrlimit setrlimit@xxxxxxxxx
waitpid - waitpid Ci:ipi __waitpid waitpid __libc_waitpid
-fallocate64 - fallocate Vi:iiiiii __fallocate64
Modified: fsf/trunk/libc/sysdeps/unix/sysv/linux/mq_open.c
==============================================================================
--- fsf/trunk/libc/sysdeps/unix/sysv/linux/mq_open.c (original)
+++ fsf/trunk/libc/sysdeps/unix/sysv/linux/mq_open.c Sun Sep 16 00:03:17 2007
@@ -1,4 +1,4 @@
-/* Copyright (C) 2004, 2005 Free Software Foundation, Inc.
+/* Copyright (C) 2004, 2005, 2007 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
@@ -20,6 +20,7 @@
#include <mqueue.h>
#include <stdarg.h>
#include <stddef.h>
+#include <stdio.h>
#include <sysdep.h>
#ifdef __NR_mq_open
@@ -32,7 +33,7 @@
attributes. If the fourth argument is NULL, default attributes are
used. */
mqd_t
-mq_open (const char *name, int oflag, ...)
+__mq_open (const char *name, int oflag, ...)
{
if (name[0] != '/')
{
@@ -54,7 +55,16 @@
return INLINE_SYSCALL (mq_open, 4, name + 1, oflag, mode, attr);
}
+strong_alias (__mq_open, mq_open);
+mqd_t
+__mq_open_2 (const char *name, int oflag)
+{
+ if (oflag & O_CREAT)
+ __fortify_fail ("invalid mq_open call: O_CREAT without mode and attr");
+
+ return __mq_open (name, oflag);
+}
#else
# include <rt/mq_open.c>
#endif