Commit Graph

25 Commits

Author SHA1 Message Date
Nobody 790298dd8d glibc with MCST patches (25.014.1) 2022-08-11 21:25:08 +03:00
Zack Weinberg ea1bd74def New string function explicit_bzero (from OpenBSD).
explicit_bzero(s, n) is the same as memset(s, 0, n), except that the
compiler is not allowed to delete a call to explicit_bzero even if the
memory pointed to by 's' is dead after the call.  Right now, this effect
is achieved externally by having explicit_bzero be a function whose
semantics are unknown to the compiler, and internally, with a no-op
asm statement that clobbers memory.  This does mean that small
explicit_bzero operations cannot be expanded inline as small memset
operations can, but on the other hand, small memset operations do get
deleted by the compiler.  Hopefully full compiler support for
explicit_bzero will happen relatively soon.

There are two new tests: test-explicit_bzero.c verifies the
visible semantics in the same way as the existing test-bzero.c,
and tst-xbzero-opt.c verifies the not-being-optimized-out property.
The latter is conceptually based on a test written by Matthew Dempsky
for the OpenBSD regression suite.

The crypt() implementation has an immediate use for this new feature.
We avoid having to add a GLIBC_PRIVATE alias for explicit_bzero
by running all of libcrypt's calls through the fortified variant,
__explicit_bzero_chk, which is in the impl namespace anyway.  Currently
I'm not aware of anything in libc proper that needs this, but the
glue is all in place if it does become necessary.  The legacy DES
implementation wasn't bothering to clear its buffers, so I added that,
mostly for consistency's sake.

	* string/explicit_bzero.c: New routine.
	* string/test-explicit_bzero.c, string/tst-xbzero-opt.c: New tests.
	* string/Makefile (routines, strop-tests, tests): Add them.
	* string/test-memset.c: Add ifdeffage for testing explicit_bzero.
	* string/string.h [__USE_MISC]: Declare explicit_bzero.

	* debug/explicit_bzero_chk.c: New routine.
	* debug/Makefile (routines): Add it.
	* debug/tst-chk1.c: Test fortification of explicit_bzero.
	* string/bits/string3.h: Fortify explicit_bzero.

	* manual/string.texi: Document explicit_bzero.
	* NEWS: Mention addition of explicit_bzero.

	* crypt/crypt-entry.c (__crypt_r): Clear key-dependent intermediate
	data before returning, using explicit_bzero.
	* crypt/md5-crypt.c (__md5_crypt_r): Likewise.
	* crypt/sha256-crypt.c (__sha256_crypt_r): Likewise.
	* crypt/sha512-crypt.c (__sha512_crypt_r): Likewise.

	* include/string.h: Redirect internal uses of explicit_bzero
	to __explicit_bzero_chk[_internal].
	* string/Versions [GLIBC_2.25]: Add explicit_bzero.
	* debug/Versions [GLIBC_2.25]: Add __explicit_bzero_chk.
	* sysdeps/arm/nacl/libc.abilist
	* sysdeps/unix/sysv/linux/aarch64/libc.abilist
	* sysdeps/unix/sysv/linux/alpha/libc.abilist
	* sysdeps/unix/sysv/linux/arm/libc.abilist
	* sysdeps/unix/sysv/linux/hppa/libc.abilist
	* sysdeps/unix/sysv/linux/i386/libc.abilist
	* sysdeps/unix/sysv/linux/ia64/libc.abilist
	* sysdeps/unix/sysv/linux/m68k/coldfire/libc.abilist
	* sysdeps/unix/sysv/linux/m68k/m680x0/libc.abilist
	* sysdeps/unix/sysv/linux/microblaze/libc.abilist
	* sysdeps/unix/sysv/linux/mips/mips32/fpu/libc.abilist
	* sysdeps/unix/sysv/linux/mips/mips32/nofpu/libc.abilist
	* sysdeps/unix/sysv/linux/mips/mips64/n32/libc.abilist
	* sysdeps/unix/sysv/linux/mips/mips64/n64/libc.abilist
	* sysdeps/unix/sysv/linux/nios2/libc.abilist
	* sysdeps/unix/sysv/linux/powerpc/powerpc32/fpu/libc.abilist
	* sysdeps/unix/sysv/linux/powerpc/powerpc32/nofpu/libc.abilist
	* sysdeps/unix/sysv/linux/powerpc/powerpc64/libc-le.abilist
	* sysdeps/unix/sysv/linux/powerpc/powerpc64/libc.abilist
	* sysdeps/unix/sysv/linux/s390/s390-32/libc.abilist
	* sysdeps/unix/sysv/linux/s390/s390-64/libc.abilist
	* sysdeps/unix/sysv/linux/sh/libc.abilist
	* sysdeps/unix/sysv/linux/sparc/sparc32/libc.abilist
	* sysdeps/unix/sysv/linux/sparc/sparc64/libc.abilist
	* sysdeps/unix/sysv/linux/tile/tilegx/tilegx32/libc.abilist
	* sysdeps/unix/sysv/linux/tile/tilegx/tilegx64/libc.abilist
	* sysdeps/unix/sysv/linux/tile/tilepro/libc.abilist
	* sysdeps/unix/sysv/linux/x86_64/64/libc.abilist
	* sysdeps/unix/sysv/linux/x86_64/x32/libc.abilist:
	Add entries for explicit_bzero and __explicit_bzero_chk.
2016-12-16 16:21:54 -05:00
Roland McGrath ee586a6d5c Move getlogin_r_chk to login/ subdir. 2013-05-06 15:58:44 -07:00
Roland McGrath bd9ffde61a Move ptsname_r_chk to login/ subdir. 2013-05-06 15:19:14 -07:00
Ulrich Drepper d9a216c037 Add checking versions of poll and ppoll 2012-01-08 11:55:32 -05:00
Ulrich Drepper a0f33f996f Add range checking for FD_SET, FD_CLR, and FD_ISSET 2011-09-08 19:48:47 -04:00
Ulrich Drepper b50f8e42ba Check for valid stack frame in longjmp.
If longjmp restores the stack frame to an address which is beyond
the stack frame at the time of the longjmp call it would install
an uninitialized stack frame.  If compiled with _FORTIFY_SOURCE
defined, longjmp will now bail out in this situation.
2009-05-15 19:37:13 -07:00
Ulrich Drepper dff3751503 * 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.
2008-03-05 07:05:13 +00:00
Ulrich Drepper 3a50811c2f * 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-15 22:35:27 +00:00
Ulrich Drepper 3586b2b60b * libio/bits/stdio2.h (__fread_chk, __fread_unlocked_chk): New
prototypes.
	(__fread_alias, __fread_unlocked_alias): New aliases.
	(fread): New extern inline.
	(fread_unlocked): Likewise.  Undef macro before definition of
	the inline function.
	* debug/Makefile (routines): Add fread_chk and fread_u_chk.
	(CFLAGS-fread_chk.c, CFLAGS-fread_u_chk.c): Add.
	* debug/Versions (libc): Export __fread_chk@@GLIBC_2.7
	and __fread_unlocked_chk@@GLIBC_2.7.
	* debug/fread_chk.c: New file.
	* debug/fread_u_chk.c: New file.
	* debug/tst-chk1.c (do_test): Add fread and fread_unlocked tests.
2007-08-28 20:33:49 +00:00
Ulrich Drepper a346370d58 * posix/bits/unistd.h (__readlinkat_chk): New prototype.
(__readlinkat_alias): New alias.
	(readlinkat): New inline function.
	* include/unistd.h (readlinkat): Add libc_hidden_proto.
	* sysdeps/unix/sysv/linux/readlinkat.c (readlinkat): Add
	libc_hidden_def.
	* io/readlinkat.c (readlinkat): Likewise.
	* debug/readlinkat_chk.c: New file.
	* debug/Makefile (routines): Add readlinkat_chk.
	* debug/Versions (libc): Export __readlinkat_chk@@GLIBC_2.5.
	* debug/tst-chk1.c (do_test): Add readlinkat tests.

	* nis/nss_nisplus/nisplus-netgrp.c: Cleanups.
	code is possible.  Move compatibility code in .text.compat section.
	over gaih array.  There is only one function to call in the moment.
2006-04-24 17:01:40 +00:00
Ulrich Drepper 02ca3541ce * debug/mbstowcs_chk.c: New file.
* debug/wcstombs_chk.c: New file.
	* debug/Makefile (routines): Add mbstowcs_chk and wcstombs_chk.
	* debug/Versions: Add __mbstowcs_chk and __wcstombs_chk.
	* stdlib/bits/stdlib.h: Add definitions for mbstowcs and wcstombs.

	* wcsmbs/bits/wchar2.h (mbsrtowcs): Pretty printing.

	* string/test-memset.c (test_main): Use negative byte value in
2005-07-25 21:41:45 +00:00
Ulrich Drepper df6f89692f * wcsmbs/bits/wchar2.h: Add definitions for wcrtomb, mbsrtowcs,
wcsrtombs, mbsnrtowcs, and wcsnrtombs.
	* debug/Makefile (routines): Add wcrtomb_chk, mbsrtowcs_chk,
	wcsrtombs_chk, mbsnrtowcs_chk, and wcsnrtombs_chk.
	* debug/Versions: Add __wcrtomb_chk, __mbsrtowcs_chk,
	__wcsrtombs_chk, __mbsnrtowcs_chk, and __wcsnrtombs_chk.
	* debug/tst-chk1.c: Add tests for new functions.
	* debug/mbsnrtowcs_chk.c: New file.
	* debug/mbsrtowcs_chk.c: New file.
	* debug/wcrtomb_chk.c: New file.
	* debug/wcsnrtombs_chk.c: New file.
	* debug/wcsrtombs_chk.c: New file.

	* include/stdio.h: Add declaration for __fxprintf.
2005-07-20 07:43:27 +00:00
Ulrich Drepper 9f3731cf7f * nscd/grpcache.c (cache_addgr): Use correct maximum for group ID
length.  Patch by Ivan Gyurdiev <ivg2@cornell.edu>.

	* debug/confstr_chk.c: New file.
	* debug/getdomainname_chk.c: New file.
	* debug/getgroups_chk.c: New file.
	* debug/gethostname_chk.c: New file.
	* debug/getlogin_r_chk.c: New file.
	* debug/ttyname_r_chk.c: New file.
	* posix/bits/unistd.h: Add definitions for new debug versions.
	* debug/tst-chk1.c: Add tests for new functions.
	* debug/Versions: Export new functions.
	* debug/Makefile (routines): Add new files.

	* stdlib/bits/stdlib.h: Fix typo.

	* manual/Makefile (libc/index.html): Depend on dir-add.texi.
2005-07-18 21:07:28 +00:00
Ulrich Drepper 8215c9ecf2 * wcsmbs/bits/wchar2.h: New file.
* include/bits/wchar2.h: New file.
	* wcsmbs/wchar.h: Include <bits/wchar2.h> if fortification is
	requested.
	* wcsmbs/wcsncpy.c: Add __wcsncpy alias.
	* string/bits/string3.h: Add fortified stpncpy definitions.
	* sysdeps/generic/stpncpy_chk.c: New file.
	* libio/vswprintf.c: Move _IO_wstrnfile definition to strfile.h.
	Export _IO_wstrn_jumps.
	* libio/strfile.h: Define _IO_wstrnfile and declare _IO_wstrn_jumps.
	* include/wchar.h: Declare __wcsncpy and __vswprintf_chk.
	* debug/fgetws_chk.c: New file.
	* debug/fgetws_u_chk.c: New file.
	* debug/fwprintf_chk.c: New file.
	* debug/swprintf_chk.c: New file.
	* debug/vfwprintf_chk.c: New file.
	* debug/vswprintf_chk.c: New file.
	* debug/vwprintf_chk.c: New file.
	* debug/wcpcpy_chk.c: New file.
	* debug/wcpncpy_chk.c: New file.
	* debug/wcscat_chk.c: New file.
	* debug/wcscpy_chk.c: New file.
	* debug/wcsncat_chk.c: New file.
	* debug/wcsncpy_chk.c: New file.
	* debug/wmemcpy_chk.c: New file.
	* debug/wmemmove_chk.c: New file.
	* debug/wmempcpy_chk.c: New file.
	* debug/wmemset_chk.c: New file.
	* debug/wprintf_chk.c: New file.
	* debug/tst-chk1.c: Add tests for new functions.
	* debug/Versions: Export new functions.
	* debug/Makefile (routines): Add new functions.
2005-07-15 10:32:45 +00:00
Ulrich Drepper b799f91ddd * stdlib/bits/stdlib.h: New file.
* stdlib/stdlib.h: Include <bits/stdlib.h> if fortification is
	requested.
	* Makefile (headers): Add bits/stdlib.h.
	* include/bits/stdlib.h: New file.
	* debug/Depend: New file.
	* debug/ptsname_r_chk.c: New file.
	* debug/realpath_chk.c: New file.
	* debug/wctomb_chk.c: New file.
	* debug/Makefile (routines): Add ptsname_r_chk, realpath_chk, and
	wctomb_chk.
	* debug/Versions: Export __ptsname_r_chk, __realpath_chk, and
	__wctomb_chk.
	* debug/tst-chk1.c: Add tests for __ptsname_r_chk, __realpath_chk, and
	__wctomb_chk.
2005-07-13 06:09:58 +00:00
Ulrich Drepper 35f1e82763 * Versions.def (ld): Add GLIBC_2.4.
* configure.in: Add --enable-stackguard-randomization option.
	(ENABLE_STACKGUARD_RANDOMIZE): New define.
	* config.h.in (ENABLE_STACKGUARD_RANDOMIZE): Add.
	* sysdeps/unix/sysv/linux/dl-osinfo.h: Include stdint.h.
	(_dl_setup_stack_chk_guard): New inline function.
	* sysdeps/generic/dl-osinfo.h: Include stdint.h.
	(_dl_setup_stack_chk_guard): New inline function.
	* elf/rtld.c (__stack_chk_guard): New variable.
	(dl_main): Remove all traces of TLS_INIT_TP_EXPENSIVE.
	Set __stack_chk_guard to _dl_setup_stack_chk_guard (),
	use THREAD_SET_STACK_GUARD if defined.
	* elf/Versions (ld): Export __stack_chk_guard@@GLIBC_2.4.
	* sysdeps/generic/libc-start.c (__stack_chk_guard): New variable.
	(__libc_start_main): Set __stack_chk_guard to
	_dl_setup_stack_chk_guard (), use THREAD_SET_STACK_GUARD if defined.
	* sysdeps/generic/libc-tls.c (__libc_setup_tls): Remove all
	traces of TLS_INIT_TP_EXPENSIVE.
	* debug/Versions (libc): Export __stack_chk_fail@@GLIBC_2.4.
	* debug/Makefile (routines): Add stack_chk_fail.
	(static-only-routines): Add stack_chk_fail_local.
	* debug/stack_chk_fail_local.c: New file.
	* debug/stack_chk_fail.c: New file.
	* elf/Makefile: Add rules to build and run tst-stackguard1{,-static}
	tests.
	* elf/tst-stackguard1.c: New file.
	* elf/tst-stackguard1-static.c: New file.
	* elf/stackguard-macros.h: New file.
2005-06-26 18:14:26 +00:00
Ulrich Drepper 61062f5630 * posix/bits/unistd.h: Avoid calling __*_chk variants if we can
determine the call will never trigger a failure.

	* sysdeps/i386/i686/memset_chk.S: Remove alias and warning.
	* sysdeps/x86_64/memset_chk.S: Likewise.

2005-02-24  Roland McGrath  <roland@redhat.com>

	* debug/Versions (libc: GLIBC_2.4): Remove
	__memset_zero_constant_len_parameter.
	* sysdeps/generic/memset_chk.c: Remove alias and warning.
	* misc/sys/cdefs.h (__warndecl): New macro.
	* debug/warning-nop.c: New file.
	* string/bits/string3.h (memset): Call __warn_memset_zero_len with no
	arguments, instead of calling __memset_zero_constant_len_parameter.
	Use __warndecl for __warn_memset_zero_len.
	* debug/Makefile (routines): Add $(static-only-routines).
	(static-only-routines): New variable.
2005-03-01 00:35:23 +00:00
Ulrich Drepper 553cc5f9ad * sysdeps/unix/sysv/linux/libc_fatal.c: Print backtrace and memory
map if requested.
	* debug/chk_fail.c: Request backtrace and memory map dump.

	* Versions.def: Add GLIBC_2.4 for libc.
	* debug/fgets_chk.c: New file.
	* debug/fgets_u_chk.c: New file.
	* debug/getcwd_chk.c: New file.
	* debug/getwd_chk.c: New file.
	* debug/readlink_chk.c: New file.
	* debug/read_chk.c: New file.
	* debug/pread_chk.c: New file.
	* debug/pread64_chk.c: New file.
	* debug/recv_chk.c: New file.
	* debug/recvfrom_chk.c: New file.
	* debug/Versions: Add all new functions with version GLIBC_2.4.
	* debug/Makefile (routines): Add fgets_chk, fgets_u_chk, read_chk,
	pread_chk, pread64_chk, recv_chk, recvfrom_chk, readlink_chk,
	getwd_chk, and getcwd_chk.  Plus appropriate CFLAGS definitions.
	* debug/tst-chk1.c: Add more tests.
	* libio/bits/stdio2.h: Add macros for fgets and fgets_unlocked.
	* include/stdio.h: Declare __fgets_chk and __fgets_unlocked_chk.
	* posix/unistd.h: Include <bits/unistd.h> for fortification.
	* posix/bits/unistd.h: New file.
	* posix/Makefile (headers): Add bits/unistd.h.
	* socket/sys/socket.h: Include <bits/socket2.h> for fortification.
	* socket/bits/socket2.h: New file.
	* socket/Makefile (headers): Add bits/socket2.h.

	* string/bits/string3.h: Extend memset macro to check for zero 3rd
	parameter and use __memset_zero_constant_len_parameter in that case.
	* sysdeps/generic/memset_chk.c: Add
	__memset_zero_constant_len_parameter alias and linker warning.
	* debug/Versions: Add __memset_zero_constant_len_parameter to libc
	with version GLIBC_2.4.

	* sysdeps/generic/bits/types.h: Don't unnecessarily use __extension__
	in __STD_TYPE definition.

2005-02-21  Jakub Jelinek  <jakub@redhat.com>

	* malloc/malloc.c (malloc_printerr): If MALLOC_CHECK_={5,7}, print
	the error message rather than program name.

2005-02-21  Ulrich Drepper  <drepper@redhat.com>
2005-02-21 23:14:10 +00:00
Ulrich Drepper a334319f65 (CFLAGS-tst-align.c): Add -mpreferred-stack-boundary=4. 2004-12-22 20:10:10 +00:00
Jakub Jelinek 0ecb606cb6 2.5-18.1 2007-07-12 18:26:36 +00:00
Ulrich Drepper b5cc329c4f 2004-10-15 Jakub Jelinek <jakub@redhat.com>
* elf/dl-minimal.c (__chk_fail): New.  Add rtld_hidden_def.
	* sysdeps/unix/sysv/linux/readonly-area.c: New file.
	* sysdeps/i386/i686/memmove.S (__memmove_chk): Add checking
	routine.
	* sysdeps/i386/i686/memcpy.S (__memcpy_chk): Likewise.
	* sysdeps/i386/i686/mempcpy.S (__mempcpy_chk): Likewise.
	* sysdeps/i386/i686/memset.S (__memset_chk): Likewise.
	* sysdeps/i386/i686/memmove-chk.S: New file.
	* sysdeps/i386/i686/memcpy-chk.S: Likewise.
	* sysdeps/i386/i686/mempcpy-chk.S: Likewise.
	* sysdeps/i386/i686/memset-chk.S: Likewise.
	* sysdeps/generic/strcat-chk.c (__strcat_chk): Don't __chk_fail
	if exactly fitting into buffer.
	* sysdeps/generic/strncat-chk.c (__strncat_chk): Likewise.
	* sysdeps/generic/readonly-area.c: New file.
	* sysdeps/generic/strncpy-chk.c (__strncpy_chk): Only test
	destlen once.
	* sysdeps/x86_64/memset.S (__memset_chk): Add checking routine.
	* sysdeps/x86_64/memcpy.S (__memcpy_chk): Likewise.
	* sysdeps/x86_64/mempcpy.S (__memcpy_chk): Define to __mempcpy_chk.
	* sysdeps/x86_64/memcpy-chk.S: New file.
	* sysdeps/x86_64/mempcpy-chk.S: Likewise.
	* sysdeps/x86_64/memset-chk.S: Likewise.
	* sysdeps/x86_64/strcpy-chk.S: Likewise.
	* sysdeps/x86_64/stpcpy-chk.S: Likewise.
	* argp/argp-xinl.c (__OPTIMIZE__): Define to 1 instead of nothing.
	* argp/argp-fs-xinl.c (__OPTIMIZE__): Likewise.
	* debug/tst-chk1.c: New test.
	* debug/tst-chk2.c: Likewise.
	* debug/tst-chk3.c: Likewise.
	* debug/test-strcpy_chk.c: Likewise.
	* debug/test-stpcpy_chk.c: Likewise.
	* debug/vsprintf_chk.c (__vsprintf_chk): If flags > 0, request
	_IO_FLAGS2_CHECK_PERCENT_N.  Add libc_hidden_def.
	* debug/Makefile (routines): Add printf_chk, fprintf_chk, vprintf_chk,
	vfprintf_chk, gets_chk and readonly-area.
	(CFLAGS-*_chk.c): Set.
	(tests): Add tst-chk1, tst-chk2, tst-chk3, test-strcpy_chk and
	test-stpcpy_chk.
	* debug/vprintf_chk.c: New file.
	* debug/printf_chk.c: Likewise.
	* debug/vfprintf_chk.c: Likewise.
	* debug/fprintf_chk.c: Likewise.
	* debug/gets_chk.c: Likewise.
	* debug/chk_fail.c (__chk_fail): Add libc_hidden_def.
	* debug/snprintf_chk.c (__snprintf_chk): Fix order of arguments
	passed to __vsnprintf_chk.
	* debug/Versions (libc): Export __printf_chk, __fprintf_chk,
	__vprintf_chk, __vfprintf_chk and __gets_chk @GLIBC_2.3.4.
	* debug/vsnprintf_chk.c (__vsnprintf_chk): Don't call
	__vsnprintf, instead create a temporary file with
	_IO_strn_jumps jumptable.  If flags > 0, request
	_IO_FLAGS2_CHECK_PERCENT_N.  Add libc_hidden_def.
	* libio/Makefile (headers): Add bits/stdio2.h.
	* libio/stdio.h: Include <bits/stdio2.h> if __USE_FORTIFY_LEVEL.
	(sprintf, snprintf, vsprintf, vsnprintf): Remove defines.
	* libio/strfile.h (_IO_strnfile): New type.
	(_IO_strn_jumps): New extern.
	* libio/vsnprintf.c (_IO_strnfile): Remove.
	(_IO_strn_jumps): Remove static.
	* libio/bits/stdio2.h: New file.
	* libio/vswprintf.c (_IO_strnfile): Rename type to...
	(_IO_wstrnfile): ...this.  Adjust all uses.
	* libio/libio.h (_IO_FLAGS2_CHECK_PERCENT_N): Define.
	* stdio-common/vfprintf.c (STR_LEN): Define.
	(vfprintf): Add readonly_format variable.
	Handle _IO_FLAGS2_CHECK_PERCENT_N.
	(buffered_vfprintf): Copy _flags2.
	* include/stdio.h (__sprintf_chk, __snprintf_chk, __vsprintf_chk,
	__vsnprintf_chk, __printf_chk, __fprintf_chk, __vprintf_chk,
	__vfprintf_chk): New prototypes.
	(__vsprintf_chk, __vsnprintf_chk): Add libc_hidden_proto.
	* include/string.h (__memcpy_chk, __memmove_chk, __mempcpy_chk,
	__memset_chk, __strcpy_chk, __stpcpy_chk, __strncpy_chk, __strcat_chk,
	__strncat_chk): New prototypes.
	* include/bits/string3.h: New file.
	* include/sys/cdefs.h (__chk_fail): Add libc_hidden_proto
	and rtld_hidden_proto.
	* string/Makefile (headers): Add bits/string3.h.
	* string/bits/string3.h (bcopy, bzero): New defines.
	(memset, memcpy, memmove, strcpy, strncpy, strcat, strncat): Change
	macros so that inlines are used only if unknown destination size
	or side-effects in destination argument.
	(mempcpy, stpcpy): Likewise.  Protect with #ifdef __USE_GNU.

2004-09-16  Ulrich Drepper  <drepper@redhat.com>

	* debug/Makefile (routines): Add *_chk.
	* debug/Versions (libc): Export __chk_fail, __memcpy_chk,
	__memmove_chk, __mempcpy_chk, __memset_chk, __stpcpy_chk,
	__strcat_chk, __strcpy_chk, __strncat_chk, __strncpy_chk,
	__sprintf_chk, __vsprintf_chk, __snprintf_chk, __vsnprintf_chk
	@GLIBC_2.3.4.
	* debug/chk_fail.c: New file.
	* debug/snprintf_chk.c: Likewise.
	* debug/sprintf_chk.c: Likewise.
	* debug/vsnprintf_chk.c: Likewise.
	* debug/vsprintf_chk.c: Likewise.
	* include/features.h (_FORTIFY_SOURCE): Document, handle.
	(__USE_FORTIFY_LEVEL): Define.
	(__GNUC_PREREQ): Move to earlier location.
	* include/sys/cdefs.h (__chk_fail): New prototype.
	* libio/bits/stdio.h (sprintf, vsprintf, snprintf, vsnprintf):
	Define if __USE_FORTIFY_LEVEL.
	* misc/sys/cdefs.h (__bos, __bos0): Define.
	* string/string.h: Include <bits/string3.h> if __USE_FORTIFY_LEVEL.
	* bits/string/string3.h: New header.
	* sysdeps/generic/memcpy_chk.c: New file.
	* sysdeps/generic/memmove_chk.c: Likewise.
	* sysdeps/generic/mempcpy_chk.c: Likewise.
	* sysdeps/generic/memset_chk.c: Likewise.
	* sysdeps/generic/stpcpy_chk.c: Likewise.
	* sysdeps/generic/strcat_chk.c: Likewise.
	* sysdeps/generic/strcpy_chk.c: Likewise.
	* sysdeps/generic/strncat_chk.c: Likewise.
	* sysdeps/generic/strncpy_chk.c: Likewise.
2004-10-15  Jakub Jelinek  <jakub@redhat.com>

	* elf/dl-minimal.c (__chk_fail): New.  Add rtld_hidden_def.
	* sysdeps/unix/sysv/linux/readonly-area.c: New file.
	* sysdeps/i386/i686/memmove.S (__memmove_chk): Add checking
	routine.
	* sysdeps/i386/i686/memcpy.S (__memcpy_chk): Likewise.
	* sysdeps/i386/i686/mempcpy.S (__mempcpy_chk): Likewise.
	* sysdeps/i386/i686/memset.S (__memset_chk): Likewise.
	* sysdeps/i386/i686/memmove-chk.S: New file.
	* sysdeps/i386/i686/memcpy-chk.S: Likewise.
	* sysdeps/i386/i686/mempcpy-chk.S: Likewise.
	* sysdeps/i386/i686/memset-chk.S: Likewise.
	* sysdeps/generic/strcat-chk.c (__strcat_chk): Don't __chk_fail
	if exactly fitting into buffer.
	* sysdeps/generic/strncat-chk.c (__strncat_chk): Likewise.
	* sysdeps/generic/readonly-area.c: New file.
	* sysdeps/generic/strncpy-chk.c (__strncpy_chk): Only test
	destlen once.
	* sysdeps/x86_64/memset.S (__memset_chk): Add checking routine.
	* sysdeps/x86_64/memcpy.S (__memcpy_chk): Likewise.
	* sysdeps/x86_64/mempcpy.S (__memcpy_chk): Define to __mempcpy_chk.
	* sysdeps/x86_64/memcpy-chk.S: New file.
	* sysdeps/x86_64/mempcpy-chk.S: Likewise.
	* sysdeps/x86_64/memset-chk.S: Likewise.
	* sysdeps/x86_64/strcpy-chk.S: Likewise.
	* sysdeps/x86_64/stpcpy-chk.S: Likewise.
	* argp/argp-xinl.c (__OPTIMIZE__): Define to 1 instead of nothing.
	* argp/argp-fs-xinl.c (__OPTIMIZE__): Likewise.
	* debug/tst-chk1.c: New test.
	* debug/tst-chk2.c: Likewise.
	* debug/tst-chk3.c: Likewise.
	* debug/test-strcpy_chk.c: Likewise.
	* debug/test-stpcpy_chk.c: Likewise.
	* debug/vsprintf_chk.c (__vsprintf_chk): If flags > 0, request
	_IO_FLAGS2_CHECK_PERCENT_N.  Add libc_hidden_def.
	* debug/Makefile (routines): Add printf_chk, fprintf_chk, vprintf_chk,
	vfprintf_chk, gets_chk and readonly-area.
	(CFLAGS-*_chk.c): Set.
	(tests): Add tst-chk1, tst-chk2, tst-chk3, test-strcpy_chk and
	test-stpcpy_chk.
	* debug/vprintf_chk.c: New file.
	* debug/printf_chk.c: Likewise.
	* debug/vfprintf_chk.c: Likewise.
	* debug/fprintf_chk.c: Likewise.
	* debug/gets_chk.c: Likewise.
	* debug/chk_fail.c (__chk_fail): Add libc_hidden_def.
	* debug/snprintf_chk.c (__snprintf_chk): Fix order of arguments
	passed to __vsnprintf_chk.
	* debug/Versions (libc): Export __printf_chk, __fprintf_chk,
	__vprintf_chk, __vfprintf_chk and __gets_chk @GLIBC_2.3.4.
	* debug/vsnprintf_chk.c (__vsnprintf_chk): Don't call
	__vsnprintf, instead create a temporary file with
	_IO_strn_jumps jumptable.  If flags > 0, request
	_IO_FLAGS2_CHECK_PERCENT_N.  Add libc_hidden_def.
	* libio/Makefile (headers): Add bits/stdio2.h.
	* libio/stdio.h: Include <bits/stdio2.h> if __USE_FORTIFY_LEVEL.
	(sprintf, snprintf, vsprintf, vsnprintf): Remove defines.
	* libio/strfile.h (_IO_strnfile): New type.
	(_IO_strn_jumps): New extern.
	* libio/vsnprintf.c (_IO_strnfile): Remove.
	(_IO_strn_jumps): Remove static.
	* libio/bits/stdio2.h: New file.
	* libio/vswprintf.c (_IO_strnfile): Rename type to...
	(_IO_wstrnfile): ...this.  Adjust all uses.
	* libio/libio.h (_IO_FLAGS2_CHECK_PERCENT_N): Define.
	* stdio-common/vfprintf.c (STR_LEN): Define.
	(vfprintf): Add readonly_format variable.
	Handle _IO_FLAGS2_CHECK_PERCENT_N.
	(buffered_vfprintf): Copy _flags2.
	* include/stdio.h (__sprintf_chk, __snprintf_chk, __vsprintf_chk,
	__vsnprintf_chk, __printf_chk, __fprintf_chk, __vprintf_chk,
	__vfprintf_chk): New prototypes.
	(__vsprintf_chk, __vsnprintf_chk): Add libc_hidden_proto.
	* include/string.h (__memcpy_chk, __memmove_chk, __mempcpy_chk,
	__memset_chk, __strcpy_chk, __stpcpy_chk, __strncpy_chk, __strcat_chk,
	__strncat_chk): New prototypes.
	* include/bits/string3.h: New file.
	* include/sys/cdefs.h (__chk_fail): Add libc_hidden_proto
	and rtld_hidden_proto.
	* string/Makefile (headers): Add bits/string3.h.
	* string/bits/string3.h (bcopy, bzero): New defines.
	(memset, memcpy, memmove, strcpy, strncpy, strcat, strncat): Change
	macros so that inlines are used only if unknown destination size
	or side-effects in destination argument.
	(mempcpy, stpcpy): Likewise.  Protect with #ifdef __USE_GNU.

2004-09-16  Ulrich Drepper  <drepper@redhat.com>

	* debug/Makefile (routines): Add *_chk.
	* debug/Versions (libc): Export __chk_fail, __memcpy_chk,
	__memmove_chk, __mempcpy_chk, __memset_chk, __stpcpy_chk,
	__strcat_chk, __strcpy_chk, __strncat_chk, __strncpy_chk,
	__sprintf_chk, __vsprintf_chk, __snprintf_chk, __vsnprintf_chk
	@GLIBC_2.3.4.
	* debug/chk_fail.c: New file.
	* debug/snprintf_chk.c: Likewise.
	* debug/sprintf_chk.c: Likewise.
	* debug/vsnprintf_chk.c: Likewise.
	* debug/vsprintf_chk.c: Likewise.
	* include/features.h (_FORTIFY_SOURCE): Document, handle.
	(__USE_FORTIFY_LEVEL): Define.
	(__GNUC_PREREQ): Move to earlier location.
	* include/sys/cdefs.h (__chk_fail): New prototype.
	* libio/bits/stdio.h (sprintf, vsprintf, snprintf, vsnprintf):
	Define if __USE_FORTIFY_LEVEL.
	* misc/sys/cdefs.h (__bos, __bos0): Define.
	* string/string.h: Include <bits/string3.h> if __USE_FORTIFY_LEVEL.
	* bits/string/string3.h: New header.
	* sysdeps/generic/memcpy_chk.c: New file.
	* sysdeps/generic/memmove_chk.c: Likewise.
	* sysdeps/generic/mempcpy_chk.c: Likewise.
	* sysdeps/generic/memset_chk.c: Likewise.
	* sysdeps/generic/stpcpy_chk.c: Likewise.
	* sysdeps/generic/strcat_chk.c: Likewise.
	* sysdeps/generic/strcpy_chk.c: Likewise.
	* sysdeps/generic/strncat_chk.c: Likewise.
	* sysdeps/generic/strncpy_chk.c: Likewise.
2004-10-18 04:17:19 +00:00
Ulrich Drepper 219aa9e9f9 Update.
1999-08-18  Ulrich Drepper  <drepper@cygnus.com>

	* Rules: When generating stdio_lim.h also rewrite IOV_MAX definition.
	* stdio-common/stdio_lim.h.in: Add IOV_MAX template.
	* include/bits/xopen_lim.h: Don't define IOV_MAX here, get it from
	stdio_lim.h.  Define LONG_BIT and WORD_BIT.

	* include/features.h: Define __USE_XOPEN2K if _XOPEN_SOURCE == 600.

	* libio/stdio.h: Don't declare cuserid and getopt for X/Open issue 6.

	* misc/search.h: Don't define NULL.

	* posix/sys/types.h: Define blksize_t if it hasn't happened.
	Only define key_t and blkcnt_t if it hasn't happened before.
	Define blksize_t if not happened before.
	* io/sys/stat.h: Don't define pid_t.  Define blkcnt_t and blksize_t.
	* sysdeps/generic/bits/types.h: Define __blksize_t.
	* sysdeps/unix/sysv/linux/alpha/bits/types.h: Likewise.
	* sysdeps/unix/sysv/linux/bits/types.h: Likewise.
	* sysdeps/unix/sysv/linux/mips/bits/types.h: Likewise.
	* sysdeps/unix/sysv/linux/sparc/bits/types.h: Likewise.
	* sysdeps/unix/sysv/sysv4/solaris2/bits/types.h: Likewise.
	* sysdeps/mach/hurd/bits/stat.h (struct stat): Use __blksize_t for
	st_blksize member.
	(struct stat64): Likewise.
	* sysdeps/unix/bsd/bits/stat.h: Likewise.
	* sysdeps/unix/bsd/osf/alpha/bits/stat.h: Likewise.
	* sysdeps/unix/sysv/linux/alpha/bits/stat.h: Likewise.
	* sysdeps/unix/sysv/linux/bits/stat.h: Likewise.
	* sysdeps/unix/sysv/linux/mips/bits/stat.h: Likewise.
	* sysdeps/unix/sysv/sysv4/i386/bist/stat.h: Likewise.
	* sysdeps/unix/sysv/sysv4/solaris2/bits/stat.h: Likewise.

	* stdlib/getsubopt.c: Correct type of second argument.
	* stdlib/stdlib.h: Likewise.

	* stdlib/monetary.h: Don't include sys/types.h.  Define only size_t
	and ssize_t.

	* sysdeps/generic/putenv.c: Correct type of parameter.
	* stdlib/stdlib.h: Likewise.

	* sysdeps/generic/msgsnd.c: Correct type of second parameter.
	* sysdeps/unix/sysv/linux/msgsnd.c: Likewise.
	* sysvips/sys/msg.h: Likewise.

	* sysdeps/generic/semop.c: Correct type of third parameter.
	* sysdeps/unix/sysv/linux/semop.c: Likewise.
	* sysvipc/sys/sem.h: Likewise.  Don't include sys/types.h, define
	size_t.

	* sysdeps/generic/shmget.c: Correct type of second parameter.
	* sysdeps/unix/sysv/linux/shmget.c: Likewise.
	* sysvips/sys/shm.h: Likewise.  Don't include unistd.h and sys/types.h.
	Declare __getpagesize here.

	* sysdeps/generic/bits/ipc.h: Include bits/types.h instead of
	sys/types.h.
	* sysdeps/gnu/bits/ipc.h: Likewise.
	* sysdeps/unix/sysv/linux/alpha/bits/ipc.h: Likewise.
	* sysdeps/unix/sysv/linux/mips/bits/ipc.h: Likewise.
	* sysdeps/unix/sysv/linux/powerpc/bits/ipc.h: Likewise.
	* sysvipc/sys/ipc.h: Define uid_t, gid_t, mode_t, and key_t if not
	already done.

	* sysdeps/unix/bsd/usleep.c: Correct type of parameter.

	* debug/versions: Export __cyg_profile_func_enter and
	__cyg_profile_func_exit.

	* math/bits/mathcalls.h: Pretty print.
1999-08-18 07:53:35 +00:00
Ulrich Drepper 107f813141 Update.
1998-07-16 20:01  Ulrich Drepper  <drepper@cygnus.com>

	* debug/Makefile (routines): Add backtracesymsfd.
	Add rules to generate libSegFault.
	* debug/Versions: Add __backtrace_symbols_fd and backtrace_symbols_fd.
	* debug/execinfo.h: Declare backtrace_symbols_fd.
	* sysdeps/generic/backtracesymsfd.c: New file.
	* sysdeps/generic/elf/backtracesymsfd.c: New file.
	* sysdeps/generic/segfault.c: New file.
	* sysdeps/generic/sigcontextinfo.h: New file.
	* sysdeps/unix/sysv/linux/i386/sigcontextinfo.h: New file.

	* sysdeps/generic/elf/backtracesyms.c: Remove unneeded +.
1998-07-16 20:08:44 +00:00
Ulrich Drepper b0b67c47a5 Update.
1998-07-02 21:51  Ulrich Drepper  <drepper@cygnus.com>

	* Makeconfig: Define list of subdirs as all-subdirs and make subdirs
	a copy.
	* Makefile: Add rules to generate map files.
	(distribute): Remove libc.map, add Versions.def and versions.awk.
	* Makerules: Change rules to find map files on common-objpfx.
	* elf/Makefile: Likewise.
	* md5-crypt/Makefile: Likewise.
	* nis/Makefile (libnsl-map): Remove.
	* Versions.def: New file.
	* versions.awk: New file.
	* argp/Versions: New file.
	* assert/Versions: New file.
	* catgets/Versions: New file.
	* csu/Versions: New file.
	* ctype/Versions: New file.
	* db/Versions: New file.
	* debug/Versions: New file.
	* dirent/Versions: New file.
	* elf/Versions: New file.
	* gmon/Versions: New file.
	* grp/Versions: New file.
	* hesiod/Versions: New file.
	* hurd/Versions: New file.
	* iconv/Versions: New file.
	* inet/Versions: New file.
	* intl/Versions: New file.
	* io/Versions: New file.
	* libio/Versions: New file.
	* linuxthreads/Versions: New file.
	* locale/Versions: New file.
	* login/Versions: New file.
	* malloc/Versions: New file.
	* math/Versions: New file.
	* md5-crypt/Versions: New file.
	* misc/Versions: New file.
	* nis/Versions: New file.
	* nss/Versions: New file.
	* posix/Versions: New file.
	* pwd/Versions: New file.
	* resolv/Versions: New file.
	* resource/Versions: New file.
	* rt/Versions: New file.
	* setjmp/Versions: New file.
	* shadow/Versions: New file.
	* signal/Versions: New file.
	* socket/Versions: New file.
	* stdio/Versions: New file.
	* stdio-common/Versions: New file.
	* stdlib/Versions: New file.
	* streams/Versions: New file.
	* string/Versions: New file.
	* sunrpc/Versions: New file.
	* sysdeps/alpha/Versions: New file.
	* sysdeps/alpha/fpu/Versions: New file.
	* sysdeps/i386/Versions: New file.
	* sysdeps/sparc/Versions: New file.
	* sysdeps/unix/sysv/Versions: New file.
	* sysdeps/unix/sysv/linux/Versions: New file.
	* sysdeps/unix/sysv/linux/alpha/Versions: New file.
	* sysdeps/unix/sysv/linux/i386/Versions: New file.
	* sysdeps/unix/sysv/linux/mips/Versions: New file.
	* sysvipc/Versions: New file.
	* termios/Versions: New file.
	* time/Versions: New file.
	* wcsmbs/Versions: New file.
	* wctype/Versions: New file.
	* libc.map: Removed.
	* db/libdb.map: Removed.
	* elf/libdl.map: Removed.
	* hesiod/libnss_hesiod.map: Removed.
	* hurd/libhurduser.map: Removed.
	* hurd/libmachuser.map: Removed.
	* linuxthreads/libpthread.map: Removed.
	* locale/libBrokenLocale.map: Removed.
	* login/libutil.map: Removed.
	* math/libm.map: Removed.
	* md5-crypt/libcrypt.map: Removed.
	* nis/libnsl.map: Removed.
	* nis/libnsl_compat.map: Removed.
	* nis/libnss_nis.map: Removed.
	* nis/libnss_nisplus.map: Removed.
	* nss/libnss_db.map: Removed.
	* nss/libnss_files.map: Removed.
	* resolv/libnss_dns.map: Removed.
	* resolv/libresolv.map: Removed.
	* rt/librt.map: Removed.

	* elf/dl-load.c (fillin_rpath): Fix test for trusted directory.
	Fix typos.

	* elf/rtld.c (process_dl_debug): Recognize 'all'.
	(process_envvars): LD_BIND_NOW must be followed by y, Y, or 1.

	* sysdeps/generic/elf/backtracesyms.c: Allocate string memory of
	correct size.

	* sysdeps/unix/sysv/linux/getsysstats.c (get_proc_path): Fix typo
	in comment.
1998-07-02 22:51:40 +00:00