2005-03-10  Jakub Jelinek  <jakub@redhat.com>
	* math/test-misc.c (main): Add some more tests.

2005-03-17  Jakub Jelinek  <jakub@redhat.com>

	* posix/regcomp.c (re_compile_fastmap_iter): Fix check for failed
	__wcrtomb.  Check return values of other __wcrtomb calls.
	* posix/regex_internal.c (build_wcs_buffer, re_string_skip_chars):
	Change mbclen type to size_t.
	(build_wcs_upper_buffer): Change mbclen and mbcdlen type to size_t.
	Handle mb chars whose upper case doesn't have multibyte representation
	in locale's charset.

2005-03-15  Jakub Jelinek  <jakub@redhat.com>

	* malloc/malloc.c (_int_icalloc, _int_icomalloc, iALLOc,
	public_iCALLOc, public_iCALLOc, public_iCOMALLOc): Protect with
	#ifndef _LIBC.

	[BZ #779]
	* malloc/malloc.c (public_mTRIm): Initialize malloc if not yet
	initialized.

2005-03-10  Jakub Jelinek  <jakub@redhat.com>

	* misc/sys/cdefs.h (__always_inline): Define.
	* posix/bits/unistd.h (read, pread, pread64, readlink, getcwd, getwd):
	Use __always_inline instead of __inline.
	* socket/bits/socket2.h (recv, recvfrom): Likewise.
	* libio/bits/stdio2.h (gets, fgets, fgets_unlocked): Likewise.
	* string/bits/string3.h (__memcpy_ichk, __memmove_ichk, __mempcpy_ichk,
	__memset_ichk, __strcpy_ichk, __stpcpy_ichk, __strncpy_ichk,
	__strcat_ichk, __strncat_ichk): Use __always_inline instead of
	__inline__ __attribute__ ((__always_inline__)).

2005-03-09  Jakub Jelinek  <jakub@redhat.com>

	* debug/tst-chk1.c: Include sys/socket.h and sys/un.h.
	(do_test): Add new tests for recv, recvfrom, getcwd, getwd and
	readlink.  Add some more tests for read, pread, pread64, fgets and
	fgets_unlocked.

	* posix/bits/unistd.h (read, pread, pread64, readlink,
	getcwd, getwd): Change macros into extern inline functions.
	(__read_alias, __pread_alias, __pread64_alias, __readlink_alias,
	__getcwd_alias, __getwd_alias): New prototypes.
	* socket/bits/socket2.h (recv, recvfrom): Change macros into
	extern inline functions.
	(__recv_alias, __recvfrom_alias): New prototypes.
	* libio/bits/stdio2.h (gets, fgets, fgets_unlocked): Change macros
	into extern inline functions.
	(__gets_alias, __fgets_alias, __fgets_unlocked_alias): New prototypes.

	* debug/pread_chk.c (__pread_chk): Fix order of arguments passed
	to __pread.
	* debug/pread64_chk.c (__pread64_chk): Fix order of arguments passed
	to __pread64.
This commit is contained in:
Ulrich Drepper 2005-03-19 00:28:51 +00:00
parent 60bd9f7c41
commit 88764ae26a
13 changed files with 457 additions and 75 deletions

View File

@ -1,7 +1,65 @@
2005-03-10 Jakub Jelinek <jakub@redhat.com>
* math/test-misc.c (main): Add some more tests.
2005-03-17 Jakub Jelinek <jakub@redhat.com>
* posix/regcomp.c (re_compile_fastmap_iter): Fix check for failed
__wcrtomb. Check return values of other __wcrtomb calls.
* posix/regex_internal.c (build_wcs_buffer, re_string_skip_chars):
Change mbclen type to size_t.
(build_wcs_upper_buffer): Change mbclen and mbcdlen type to size_t.
Handle mb chars whose upper case doesn't have multibyte representation
in locale's charset.
2005-03-15 Jakub Jelinek <jakub@redhat.com>
* malloc/malloc.c (_int_icalloc, _int_icomalloc, iALLOc,
public_iCALLOc, public_iCALLOc, public_iCOMALLOc): Protect with
#ifndef _LIBC.
[BZ #779]
* malloc/malloc.c (public_mTRIm): Initialize malloc if not yet
initialized.
2005-03-10 Jakub Jelinek <jakub@redhat.com>
* misc/sys/cdefs.h (__always_inline): Define.
* posix/bits/unistd.h (read, pread, pread64, readlink, getcwd, getwd):
Use __always_inline instead of __inline.
* socket/bits/socket2.h (recv, recvfrom): Likewise.
* libio/bits/stdio2.h (gets, fgets, fgets_unlocked): Likewise.
* string/bits/string3.h (__memcpy_ichk, __memmove_ichk, __mempcpy_ichk,
__memset_ichk, __strcpy_ichk, __stpcpy_ichk, __strncpy_ichk,
__strcat_ichk, __strncat_ichk): Use __always_inline instead of
__inline__ __attribute__ ((__always_inline__)).
2005-03-09 Jakub Jelinek <jakub@redhat.com>
* debug/tst-chk1.c: Include sys/socket.h and sys/un.h.
(do_test): Add new tests for recv, recvfrom, getcwd, getwd and
readlink. Add some more tests for read, pread, pread64, fgets and
fgets_unlocked.
* posix/bits/unistd.h (read, pread, pread64, readlink,
getcwd, getwd): Change macros into extern inline functions.
(__read_alias, __pread_alias, __pread64_alias, __readlink_alias,
__getcwd_alias, __getwd_alias): New prototypes.
* socket/bits/socket2.h (recv, recvfrom): Change macros into
extern inline functions.
(__recv_alias, __recvfrom_alias): New prototypes.
* libio/bits/stdio2.h (gets, fgets, fgets_unlocked): Change macros
into extern inline functions.
(__gets_alias, __fgets_alias, __fgets_unlocked_alias): New prototypes.
* debug/pread_chk.c (__pread_chk): Fix order of arguments passed
to __pread.
* debug/pread64_chk.c (__pread64_chk): Fix order of arguments passed
to __pread64.
2005-03-18 Daniel Jacobowitz <dan@codesourcery.com>
* configure.in: Use %function instead of @function.
* configure: Regenerated.
2005-03-18 Ulrich Drepper <drepper@redhat.com>

View File

@ -26,5 +26,5 @@ __pread64_chk (int fd, void *buf, size_t nbytes, off64_t offset, size_t buflen)
if (nbytes > buflen)
__chk_fail ();
return __pread64 (fd, buf, offset, nbytes);
return __pread64 (fd, buf, nbytes, offset);
}

View File

@ -26,5 +26,5 @@ __pread_chk (int fd, void *buf, size_t nbytes, off_t offset, size_t buflen)
if (nbytes > buflen)
__chk_fail ();
return __pread (fd, buf, offset, nbytes);
return __pread (fd, buf, nbytes, offset);
}

View File

@ -24,6 +24,8 @@
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <sys/socket.h>
#include <sys/un.h>
#include <unistd.h>
char *temp_filename;
@ -463,11 +465,22 @@ do_test (void)
if (fgets (buf, sizeof (buf), stdin) != buf || memcmp (buf, "ABCDEFGHI", 10))
FAIL ();
rewind (stdin);
if (fgets (buf, l0 + sizeof (buf), stdin) != buf
|| memcmp (buf, "abcdefgh\n", 10))
FAIL ();
#if __USE_FORTIFY_LEVEL >= 1
CHK_FAIL_START
if (fgets (buf, sizeof (buf) + 1, stdin) != buf)
FAIL ();
CHK_FAIL_END
CHK_FAIL_START
if (fgets (buf, l0 + sizeof (buf) + 1, stdin) != buf)
FAIL ();
CHK_FAIL_END
#endif
rewind (stdin);
@ -479,11 +492,22 @@ do_test (void)
|| memcmp (buf, "ABCDEFGHI", 10))
FAIL ();
rewind (stdin);
if (fgets_unlocked (buf, l0 + sizeof (buf), stdin) != buf
|| memcmp (buf, "abcdefgh\n", 10))
FAIL ();
#if __USE_FORTIFY_LEVEL >= 1
CHK_FAIL_START
if (fgets_unlocked (buf, sizeof (buf) + 1, stdin) != buf)
FAIL ();
CHK_FAIL_END
CHK_FAIL_START
if (fgets_unlocked (buf, l0 + sizeof (buf) + 1, stdin) != buf)
FAIL ();
CHK_FAIL_END
#endif
lseek (fileno (stdin), 0, SEEK_SET);
@ -495,6 +519,12 @@ do_test (void)
|| memcmp (buf, "ABCDEFGHI", 9))
FAIL ();
lseek (fileno (stdin), 0, SEEK_SET);
if (read (fileno (stdin), buf, l0 + sizeof (buf) - 1) != sizeof (buf) - 1
|| memcmp (buf, "abcdefgh\n", 9))
FAIL ();
#if __USE_FORTIFY_LEVEL >= 1
CHK_FAIL_START
if (read (fileno (stdin), buf, sizeof (buf) + 1) != sizeof (buf) + 1)
@ -502,12 +532,16 @@ do_test (void)
CHK_FAIL_END
#endif
if (pread (fileno (stdin), buf, sizeof (buf) - 1, sizeof (buf) - 2)
!= sizeof (buf) - 1
|| memcmp (buf, "\nABCDEFGH", 9))
FAIL ();
if (pread (fileno (stdin), buf, sizeof (buf) - 1, 0) != sizeof (buf) - 1
|| memcmp (buf, "abcdefgh\n", 9))
FAIL ();
if (pread (fileno (stdin), buf, sizeof (buf) - 1, sizeof (buf) - 1)
if (pread (fileno (stdin), buf, l0 + sizeof (buf) - 1, sizeof (buf) - 3)
!= sizeof (buf) - 1
|| memcmp (buf, "ABCDEFGHI", 9))
|| memcmp (buf, "h\nABCDEFG", 9))
FAIL ();
#if __USE_FORTIFY_LEVEL >= 1
@ -518,17 +552,21 @@ do_test (void)
CHK_FAIL_END
#endif
if (pread64 (fileno (stdin), buf, sizeof (buf) - 1, sizeof (buf) - 2)
!= sizeof (buf) - 1
|| memcmp (buf, "\nABCDEFGH", 9))
FAIL ();
if (pread64 (fileno (stdin), buf, sizeof (buf) - 1, 0) != sizeof (buf) - 1
|| memcmp (buf, "abcdefgh\n", 9))
FAIL ();
if (pread64 (fileno (stdin), buf, sizeof (buf) - 1, sizeof (buf) - 1)
if (pread64 (fileno (stdin), buf, l0 + sizeof (buf) - 1, sizeof (buf) - 3)
!= sizeof (buf) - 1
|| memcmp (buf, "ABCDEFGHI", 9))
|| memcmp (buf, "h\nABCDEFG", 9))
FAIL ();
#if __USE_FORTIFY_LEVEL >= 1
CHK_FAIL_START
if (pread64 (fileno (stdin), buf, sizeof (buf) + 1, 2 * (sizeof (buf) - 1))
if (pread64 (fileno (stdin), buf, sizeof (buf) + 1, 2 * sizeof (buf))
!= sizeof (buf) + 1)
FAIL ();
CHK_FAIL_END
@ -570,5 +608,188 @@ do_test (void)
snprintf (buf, sizeof (buf), "%3$d\n", 1, 2, 3, 4);
CHK_FAIL2_END
int sp[2];
if (socketpair (PF_UNIX, SOCK_STREAM, 0, sp))
FAIL ();
else
{
const char *sendstr = "abcdefgh\nABCDEFGH\n0123456789\n";
if (send (sp[0], sendstr, strlen (sendstr), 0) != strlen (sendstr))
FAIL ();
char recvbuf[12];
if (recv (sp[1], recvbuf, sizeof recvbuf, MSG_PEEK)
!= sizeof recvbuf
|| memcmp (recvbuf, sendstr, sizeof recvbuf) != 0)
FAIL ();
if (recv (sp[1], recvbuf + 6, l0 + sizeof recvbuf - 7, MSG_PEEK)
!= sizeof recvbuf - 7
|| memcmp (recvbuf + 6, sendstr, sizeof recvbuf - 7) != 0)
FAIL ();
#if __USE_FORTIFY_LEVEL >= 1
CHK_FAIL_START
if (recv (sp[1], recvbuf + 1, sizeof recvbuf, MSG_PEEK)
!= sizeof recvbuf)
FAIL ();
CHK_FAIL_END
CHK_FAIL_START
if (recv (sp[1], recvbuf + 4, l0 + sizeof recvbuf - 3, MSG_PEEK)
!= sizeof recvbuf - 3)
FAIL ();
CHK_FAIL_END
#endif
socklen_t sl;
struct sockaddr_un sa_un;
sl = sizeof (sa_un);
if (recvfrom (sp[1], recvbuf, sizeof recvbuf, MSG_PEEK, &sa_un, &sl)
!= sizeof recvbuf
|| memcmp (recvbuf, sendstr, sizeof recvbuf) != 0)
FAIL ();
sl = sizeof (sa_un);
if (recvfrom (sp[1], recvbuf + 6, l0 + sizeof recvbuf - 7, MSG_PEEK,
&sa_un, &sl) != sizeof recvbuf - 7
|| memcmp (recvbuf + 6, sendstr, sizeof recvbuf - 7) != 0)
FAIL ();
#if __USE_FORTIFY_LEVEL >= 1
CHK_FAIL_START
sl = sizeof (sa_un);
if (recvfrom (sp[1], recvbuf + 1, sizeof recvbuf, MSG_PEEK, &sa_un, &sl)
!= sizeof recvbuf)
FAIL ();
CHK_FAIL_END
CHK_FAIL_START
sl = sizeof (sa_un);
if (recvfrom (sp[1], recvbuf + 4, l0 + sizeof recvbuf - 3, MSG_PEEK,
&sa_un, &sl) != sizeof recvbuf - 3)
FAIL ();
CHK_FAIL_END
#endif
close (sp[0]);
close (sp[1]);
}
char fname[] = "/tmp/tst-chk1-dir-XXXXXX\0foo";
char *enddir = strchr (fname, '\0');
if (mkdtemp (fname) == NULL)
{
printf ("mkdtemp failed: %m\n");
return 1;
}
*enddir = '/';
if (symlink ("bar", fname) != 0)
FAIL ();
char readlinkbuf[4];
if (readlink (fname, readlinkbuf, 4) != 3
|| memcmp (readlinkbuf, "bar", 3) != 0)
FAIL ();
if (readlink (fname, readlinkbuf + 1, l0 + 3) != 3
|| memcmp (readlinkbuf, "bbar", 4) != 0)
FAIL ();
#if __USE_FORTIFY_LEVEL >= 1
CHK_FAIL_START
if (readlink (fname, readlinkbuf + 2, l0 + 3) != 3)
FAIL ();
CHK_FAIL_END
CHK_FAIL_START
if (readlink (fname, readlinkbuf + 3, 4) != 3)
FAIL ();
CHK_FAIL_END
#endif
char *cwd1 = getcwd (NULL, 0);
if (cwd1 == NULL)
FAIL ();
char *cwd2 = getcwd (NULL, 250);
if (cwd2 == NULL)
FAIL ();
if (cwd1 && cwd2)
{
if (strcmp (cwd1, cwd2) != 0)
FAIL ();
*enddir = '\0';
if (chdir (fname))
FAIL ();
char *cwd3 = getcwd (NULL, 0);
if (cwd3 == NULL)
FAIL ();
if (strcmp (fname, cwd3) != 0)
printf ("getcwd after chdir is '%s' != '%s',"
"get{c,}wd tests skipped\n", cwd3, fname);
else
{
char getcwdbuf[sizeof fname - 3];
char *cwd4 = getcwd (getcwdbuf, sizeof getcwdbuf);
if (cwd4 != getcwdbuf
|| strcmp (getcwdbuf, fname) != 0)
FAIL ();
cwd4 = getcwd (getcwdbuf + 1, l0 + sizeof getcwdbuf - 1);
if (cwd4 != getcwdbuf + 1
|| getcwdbuf[0] != fname[0]
|| strcmp (getcwdbuf + 1, fname) != 0)
FAIL ();
#if __USE_FORTIFY_LEVEL >= 1
CHK_FAIL_START
if (getcwd (getcwdbuf + 2, l0 + sizeof getcwdbuf)
!= getcwdbuf + 2)
FAIL ();
CHK_FAIL_END
CHK_FAIL_START
if (getcwd (getcwdbuf + 2, sizeof getcwdbuf)
!= getcwdbuf + 2)
FAIL ();
CHK_FAIL_END
#endif
if (getwd (getcwdbuf) != getcwdbuf
|| strcmp (getcwdbuf, fname) != 0)
FAIL ();
if (getwd (getcwdbuf + 1) != getcwdbuf + 1
|| strcmp (getcwdbuf + 1, fname) != 0)
FAIL ();
#if __USE_FORTIFY_LEVEL >= 1
CHK_FAIL_START
if (getwd (getcwdbuf + 2) != getcwdbuf + 2)
FAIL ();
CHK_FAIL_END
#endif
}
if (chdir (cwd1) != 0)
FAIL ();
free (cwd3);
}
free (cwd1);
free (cwd2);
*enddir = '/';
if (unlink (fname) != 0)
FAIL ();
*enddir = '\0';
if (rmdir (fname) != 0)
FAIL ();
return ret;
}

View File

@ -72,18 +72,45 @@ extern int __vprintf_chk (int __flag, __const char *__restrict __format,
#endif
extern char *__gets_chk (char *__str, size_t);
#define gets(__str) \
((__bos (__str) == (size_t) -1) \
? gets (__str) : __gets_chk (__str, __bos (__str)))
extern char *__gets_chk (char *__str, size_t) __wur;
extern char *__REDIRECT (__gets_alias, (char *__str), gets) __wur;
extern char *__fgets_chk (char *s, size_t size, int n, FILE *stream);
#define fgets(__str, __n, __fp) \
((__bos (__str) == (size_t) -1) \
? fgets (__str, __n, __fp) : __fgets_chk (__str, __bos (__str), __n, __fp))
extern __always_inline __wur char *
gets (char *__str)
{
if (__bos (__str) != (size_t) -1)
return __gets_chk (__str, __bos (__str));
return __gets_alias (__str);
}
extern char *__fgets_unlocked_chk (char *s, size_t size, int n, FILE *stream);
#define fgets_unlocked(__str, __n, __fp) \
((__bos (__str) == (size_t) -1) \
? fgets_unlocked (__str, __n, __fp) \
: __fgets_unlocked_chk (__str, __bos (__str), __n, __fp))
extern char *__fgets_chk (char *__restrict __s, size_t __size, int __n,
FILE *__restrict __stream) __wur;
extern char *__REDIRECT (__fgets_alias,
(char *__restrict __s, int __n,
FILE *__restrict __stream), fgets) __wur;
extern __always_inline __wur char *
fgets (char *__restrict __s, int __n, FILE *__restrict __stream)
{
if (__bos (__s) != (size_t) -1
&& (!__builtin_constant_p (__n) || (size_t) __n > __bos (__s)))
return __fgets_chk (__s, __bos (__s), __n, __stream);
return __fgets_alias (__s, __n, __stream);
}
#ifdef __USE_GNU
extern char *__fgets_unlocked_chk (char *__restrict __s, size_t __size,
int __n, FILE *__restrict __stream) __wur;
extern char *__REDIRECT (__fgets_unlocked_alias,
(char *__restrict __s, int __n,
FILE *__restrict __stream), fgets_unlocked) __wur;
extern __always_inline __wur char *
fgets_unlocked (char *__restrict __s, int __n, FILE *__restrict __stream)
{
if (__bos (__s) != (size_t) -1
&& (!__builtin_constant_p (__n) || (size_t) __n > __bos (__s)))
return __fgets_unlocked_chk (__s, __bos (__s), __n, __stream);
return __fgets_unlocked_alias (__s, __n, __stream);
}
#endif

View File

@ -1006,6 +1006,7 @@ struct mallinfo public_mALLINFo(void);
struct mallinfo public_mALLINFo();
#endif
#ifndef _LIBC
/*
independent_calloc(size_t n_elements, size_t element_size, Void_t* chunks[]);
@ -1129,6 +1130,8 @@ Void_t** public_iCOMALLOc(size_t, size_t*, Void_t**);
Void_t** public_iCOMALLOc();
#endif
#endif /* _LIBC */
/*
pvalloc(size_t n);
@ -1507,8 +1510,10 @@ Void_t* _int_memalign(mstate, size_t, size_t);
Void_t* _int_valloc(mstate, size_t);
static Void_t* _int_pvalloc(mstate, size_t);
/*static Void_t* cALLOc(size_t, size_t);*/
#ifndef _LIBC
static Void_t** _int_icalloc(mstate, size_t, size_t, Void_t**);
static Void_t** _int_icomalloc(mstate, size_t, size_t*, Void_t**);
#endif
static int mTRIm(size_t);
static size_t mUSABLe(Void_t*);
static void mSTATs(void);
@ -2305,7 +2310,9 @@ static void malloc_init_state(av) mstate av;
static Void_t* sYSMALLOc(INTERNAL_SIZE_T, mstate);
static int sYSTRIm(size_t, mstate);
static void malloc_consolidate(mstate);
#ifndef _LIBC
static Void_t** iALLOc(mstate, size_t, size_t*, int, Void_t**);
#endif
#else
static Void_t* sYSMALLOc();
static int sYSTRIm();
@ -3729,6 +3736,8 @@ public_cALLOc(size_t n, size_t elem_size)
return mem;
}
#ifndef _LIBC
Void_t**
public_iCALLOc(size_t n, size_t elem_size, Void_t** chunks)
{
@ -3759,8 +3768,6 @@ public_iCOMALLOc(size_t n, size_t sizes[], Void_t** chunks)
return m;
}
#ifndef _LIBC
void
public_cFREe(Void_t* m)
{
@ -3774,6 +3781,8 @@ public_mTRIm(size_t s)
{
int result;
if(__malloc_initialized < 0)
ptmalloc_init ();
(void)mutex_lock(&main_arena.mutex);
result = mTRIm(s);
(void)mutex_unlock(&main_arena.mutex);
@ -4962,6 +4971,7 @@ Void_t* cALLOc(n_elements, elem_size) size_t n_elements; size_t elem_size;
}
#endif /* 0 */
#ifndef _LIBC
/*
------------------------- independent_calloc -------------------------
*/
@ -5125,6 +5135,7 @@ mstate av; size_t n_elements; size_t* sizes; int opts; Void_t* chunks[];
return marray;
}
#endif /* _LIBC */
/*

View File

@ -1,5 +1,5 @@
/* Miscellaneous tests which don't fit anywhere else.
Copyright (C) 2000, 2001 Free Software Foundation, Inc.
Copyright (C) 2000, 2001, 2004, 2005 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
@ -1143,5 +1143,45 @@ main (void)
}
#endif
/* The tests here are very similar to tests earlier in this file,
the important difference is just that there are no intervening
union variables that cause some GCC versions to hide possible
bugs in nextafter* implementation. */
if (nextafterf (nextafterf (FLT_MIN, FLT_MIN / 2.0), FLT_MIN) != FLT_MIN)
{
puts ("nextafterf FLT_MIN test failed");
result = 1;
}
if (nextafterf (nextafterf (-FLT_MIN, -FLT_MIN / 2.0), -FLT_MIN)
!= -FLT_MIN)
{
puts ("nextafterf -FLT_MIN test failed");
result = 1;
}
if (nextafter (nextafter (DBL_MIN, DBL_MIN / 2.0), DBL_MIN) != DBL_MIN)
{
puts ("nextafter DBL_MIN test failed");
result = 1;
}
if (nextafter (nextafter (-DBL_MIN, -DBL_MIN / 2.0), -DBL_MIN) != -DBL_MIN)
{
puts ("nextafter -DBL_MIN test failed");
result = 1;
}
#ifndef NO_LONG_DOUBLE
if (nextafterl (nextafterl (LDBL_MIN, LDBL_MIN / 2.0), LDBL_MIN)
!= LDBL_MIN)
{
puts ("nextafterl LDBL_MIN test failed");
result = 1;
}
if (nextafterl (nextafterl (-LDBL_MIN, -LDBL_MIN / 2.0), -LDBL_MIN)
!= -LDBL_MIN)
{
puts ("nextafterl -LDBL_MIN test failed");
result = 1;
}
#endif
return result;
}

View File

@ -271,6 +271,13 @@
# define __wur /* Ignore */
#endif
/* Forces a function to be always inlined. */
#if __GNUC_PREREQ (3,2)
# define __always_inline __inline __attribute__ ((__always_inline__))
#else
# define __always_inline __inline
#endif
/* It is possible to compile containing GCC extensions even if GCC is
run in pedantic mode if the uses are carefully marked using the
`__extension__' keyword. But this is not generally available before

View File

@ -26,7 +26,7 @@ extern ssize_t __read_chk (int __fd, void *__buf, size_t __nbytes,
extern ssize_t __REDIRECT (__read_alias, (int __fd, void *__buf,
size_t __nbytes), read) __wur;
extern __inline __wur ssize_t
extern __always_inline __wur ssize_t
read (int __fd, void *__buf, size_t __nbytes)
{
if (__bos0 (__buf) != (size_t) -1
@ -46,8 +46,9 @@ extern ssize_t __REDIRECT (__pread_alias,
extern ssize_t __REDIRECT (__pread64_alias,
(int __fd, void *__buf, size_t __nbytes,
__off64_t __offset), pread64) __wur;
# ifndef __USE_FILE_OFFSET64
extern __inline __wur ssize_t
extern __always_inline __wur ssize_t
pread (int __fd, void *__buf, size_t __nbytes, __off_t __offset)
{
if (__bos0 (__buf) != (size_t) -1
@ -56,7 +57,7 @@ pread (int __fd, void *__buf, size_t __nbytes, __off_t __offset)
return __pread_alias (__fd, __buf, __nbytes, __offset);
}
# else
extern __inline __wur ssize_t
extern __always_inline __wur ssize_t
pread (int __fd, void *__buf, size_t __nbytes, __off_t __offset)
{
if (__bos0 (__buf) != (size_t) -1
@ -67,7 +68,7 @@ pread (int __fd, void *__buf, size_t __nbytes, __off_t __offset)
# endif
# ifdef __USE_LARGEFILE64
extern __inline __wur ssize_t
extern __always_inline __wur ssize_t
pread64 (int __fd, void *__buf, size_t __nbytes, __off64_t __offset)
{
if (__bos0 (__buf) != (size_t) -1
@ -87,7 +88,8 @@ extern int __REDIRECT_NTH (__readlink_alias,
(__const char *__restrict __path,
char *__restrict __buf, size_t __len), readlink)
__nonnull ((1, 2)) __wur;
extern __inline __nonnull ((1, 2)) __wur int
extern __always_inline __nonnull ((1, 2)) __wur int
__NTH (readlink (__const char *__restrict __path, char *__restrict __buf,
size_t __len))
{
@ -102,7 +104,8 @@ extern char *__getcwd_chk (char *__buf, size_t __size, size_t __buflen)
__THROW __wur;
extern char *__REDIRECT_NTH (__getcwd_alias,
(char *__buf, size_t __size), getcwd) __wur;
extern __inline __wur char *
extern __always_inline __wur char *
__NTH (getcwd (char *__buf, size_t __size))
{
if (__bos (__buf) != (size_t) -1
@ -116,7 +119,8 @@ extern char *__getwd_chk (char *__buf, size_t buflen)
__THROW __nonnull ((1)) __wur;
extern char *__REDIRECT_NTH (__getwd_alias, (char *__buf), getwd)
__nonnull ((1)) __wur;
extern __inline __nonnull ((1)) __attribute_deprecated__ __wur char *
extern __always_inline __nonnull ((1)) __attribute_deprecated__ __wur char *
__NTH (getwd (char *__buf))
{
if (__bos (__buf) != (size_t) -1)

View File

@ -359,7 +359,8 @@ re_compile_fastmap_iter (bufp, init_state, fastmap)
memset (&state, 0, sizeof (state));
if (mbrtowc (&wc, (const char *) buf, p - buf,
&state) == p - buf
&& __wcrtomb ((char *) buf, towlower (wc), &state) > 0)
&& (__wcrtomb ((char *) buf, towlower (wc), &state)
!= (size_t) -1))
re_set_fastmap (fastmap, 0, buf[0]);
}
#endif
@ -409,12 +410,13 @@ re_compile_fastmap_iter (bufp, init_state, fastmap)
char buf[256];
mbstate_t state;
memset (&state, '\0', sizeof (state));
__wcrtomb (buf, cset->mbchars[i], &state);
re_set_fastmap (fastmap, icase, *(unsigned char *) buf);
if (__wcrtomb (buf, cset->mbchars[i], &state) != (size_t) -1)
re_set_fastmap (fastmap, icase, *(unsigned char *) buf);
if ((bufp->syntax & RE_ICASE) && dfa->mb_cur_max > 1)
{
__wcrtomb (buf, towlower (cset->mbchars[i]), &state);
re_set_fastmap (fastmap, 0, *(unsigned char *) buf);
if (__wcrtomb (buf, towlower (cset->mbchars[i]), &state)
!= (size_t) -1)
re_set_fastmap (fastmap, 0, *(unsigned char *) buf);
}
}
}

View File

@ -220,7 +220,8 @@ build_wcs_buffer (pstr)
unsigned char buf[64];
#endif
mbstate_t prev_st;
int byte_idx, end_idx, mbclen, remain_len;
int byte_idx, end_idx, remain_len;
size_t mbclen;
/* Build the buffers from pstr->valid_len to either pstr->len or
pstr->bufs_len. */
@ -281,7 +282,8 @@ build_wcs_upper_buffer (pstr)
re_string_t *pstr;
{
mbstate_t prev_st;
int src_idx, byte_idx, end_idx, mbclen, remain_len;
int src_idx, byte_idx, end_idx, remain_len;
size_t mbclen;
#ifdef _LIBC
char buf[MB_CUR_MAX];
assert (MB_CUR_MAX >= pstr->mb_cur_max);
@ -318,12 +320,12 @@ build_wcs_upper_buffer (pstr)
mbclen = mbrtowc (&wc,
((const char *) pstr->raw_mbs + pstr->raw_mbs_idx
+ byte_idx), remain_len, &pstr->cur_state);
if (BE (mbclen > 0, 1))
if (BE (mbclen + 2 > 2, 1))
{
wchar_t wcu = wc;
if (iswlower (wc))
{
int mbcdlen;
size_t mbcdlen;
wcu = towupper (wc);
mbcdlen = wcrtomb (buf, wcu, &prev_st);
@ -386,20 +388,20 @@ build_wcs_upper_buffer (pstr)
else
p = (const char *) pstr->raw_mbs + pstr->raw_mbs_idx + src_idx;
mbclen = mbrtowc (&wc, p, remain_len, &pstr->cur_state);
if (BE (mbclen > 0, 1))
if (BE (mbclen + 2 > 2, 1))
{
wchar_t wcu = wc;
if (iswlower (wc))
{
int mbcdlen;
size_t mbcdlen;
wcu = towupper (wc);
mbcdlen = wcrtomb ((char *) buf, wcu, &prev_st);
if (BE (mbclen == mbcdlen, 1))
memcpy (pstr->mbs + byte_idx, buf, mbclen);
else
else if (mbcdlen != (size_t) -1)
{
int i;
size_t i;
if (byte_idx + mbcdlen > pstr->bufs_len)
{
@ -416,7 +418,7 @@ build_wcs_upper_buffer (pstr)
}
if (!pstr->offsets_needed)
{
for (i = 0; i < byte_idx; ++i)
for (i = 0; i < (size_t) byte_idx; ++i)
pstr->offsets[i] = i;
pstr->offsets_needed = 1;
}
@ -439,13 +441,15 @@ build_wcs_upper_buffer (pstr)
src_idx += mbclen;
continue;
}
else
memcpy (pstr->mbs + byte_idx, p, mbclen);
}
else
memcpy (pstr->mbs + byte_idx, p, mbclen);
if (BE (pstr->offsets_needed != 0, 0))
{
int i;
size_t i;
for (i = 0; i < mbclen; ++i)
pstr->offsets[byte_idx + i] = src_idx + i;
}
@ -496,7 +500,8 @@ re_string_skip_chars (pstr, new_raw_idx, last_wc)
wint_t *last_wc;
{
mbstate_t prev_st;
int rawbuf_idx, mbclen;
int rawbuf_idx;
size_t mbclen;
wchar_t wc = 0;
/* Skip the characters which are not necessary to check. */

View File

@ -23,18 +23,34 @@
extern ssize_t __recv_chk (int __fd, void *__buf, size_t __n, size_t __buflen,
int __flags);
#define recv(fd, buf, n, flags) \
(__bos0 (buf) != (size_t) -1 \
&& (!__builtin_constant_p (n) || (n) > __bos0 (buf)) \
? __recv_chk (fd, buf, n, __bos0 (buf), flags) \
: recv (fd, buf, n, flags))
extern ssize_t __REDIRECT (__recv_alias, (int __fd, void *__buf, size_t __n,
int __flags), recv);
extern __always_inline ssize_t
recv (int __fd, void *__buf, size_t __n, int __flags)
{
if (__bos0 (__buf) != (size_t) -1
&& (!__builtin_constant_p (__n) || __n > __bos0 (__buf)))
return __recv_chk (__fd, __buf, __n, __bos0 (__buf), __flags);
return __recv_alias (__fd, __buf, __n, __flags);
}
extern ssize_t __recvfrom_chk (int __fd, void *__restrict __buf, size_t __n,
size_t __buflen, int __flags,
__SOCKADDR_ARG __addr,
socklen_t *__restrict __addr_len);
#define recvfrom(fd, buf, n, flags, addr, addr_len) \
(__bos0 (buf) != (size_t) -1 \
&& (!__builtin_constant_p (n) || (n) > __bos0 (buf)) \
? __recvfrom_chk (fd, buf, n, __bos0 (buf), flags, addr, addr_len) \
: recvfrom (fd, buf, n, flags, addr, addr_len))
extern ssize_t __REDIRECT (__recvfrom_alias,
(int __fd, void *__restrict __buf, size_t __n,
int __flags, __SOCKADDR_ARG __addr,
socklen_t *__restrict __addr_len), recvfrom);
extern __always_inline ssize_t
recvfrom (int __fd, void *__buf, size_t __n, int __flags,
__SOCKADDR_ARG __addr, socklen_t *__restrict __addr_len)
{
if (__bos0 (__buf) != (size_t) -1
&& (!__builtin_constant_p (__n) || __n > __bos0 (__buf)))
return __recvfrom_chk (__fd, __buf, __n, __bos0 (__buf), __flags,
__addr, __addr_len);
return __recvfrom_alias (__fd, __buf, __n, __flags, __addr, __addr_len);
}

View File

@ -44,8 +44,7 @@
((__bos0 (dest) != (size_t) -1) \
? __builtin___memcpy_chk (dest, src, len, __bos0 (dest)) \
: __memcpy_ichk (dest, src, len))
static __inline__ void *
__attribute__ ((__always_inline__))
static __always_inline void *
__memcpy_ichk (void *__restrict __dest, const void *__restrict __src,
size_t __len)
{
@ -57,8 +56,7 @@ __memcpy_ichk (void *__restrict __dest, const void *__restrict __src,
((__bos0 (dest) != (size_t) -1) \
? __builtin___memmove_chk (dest, src, len, __bos0 (dest)) \
: __memmove_ichk (dest, src, len))
static __inline__ void *
__attribute__ ((__always_inline__))
static __always_inline void *
__memmove_ichk (void *__dest, const void *__src, size_t __len)
{
return __builtin___memmove_chk (__dest, __src, __len, __bos0 (__dest));
@ -70,8 +68,7 @@ __memmove_ichk (void *__dest, const void *__src, size_t __len)
((__bos0 (dest) != (size_t) -1) \
? __builtin___mempcpy_chk (dest, src, len, __bos0 (dest)) \
: __mempcpy_ichk (dest, src, len))
static __inline__ void *
__attribute__ ((__always_inline__))
static __always_inline void *
__mempcpy_ichk (void *__restrict __dest, const void *__restrict __src,
size_t __len)
{
@ -93,8 +90,7 @@ __warndecl (__warn_memset_zero_len,
: ((__bos0 (dest) != (size_t) -1) \
? __builtin___memset_chk (dest, ch, len, __bos0 (dest)) \
: __memset_ichk (dest, ch, len)))
static __inline__ void *
__attribute__ ((__always_inline__))
static __always_inline void *
__memset_ichk (void *__dest, int __ch, size_t __len)
{
return __builtin___memset_chk (__dest, __ch, __len, __bos0 (__dest));
@ -116,8 +112,7 @@ __memset_ichk (void *__dest, int __ch, size_t __len)
((__bos (dest) != (size_t) -1) \
? __builtin___strcpy_chk (dest, src, __bos (dest)) \
: __strcpy_ichk (dest, src))
static __inline__ char *
__attribute__ ((__always_inline__))
static __always_inline char *
__strcpy_ichk (char *__restrict __dest, const char *__restrict __src)
{
return __builtin___strcpy_chk (__dest, __src, __bos (__dest));
@ -129,8 +124,7 @@ __strcpy_ichk (char *__restrict __dest, const char *__restrict __src)
((__bos (dest) != (size_t) -1) \
? __builtin___stpcpy_chk (dest, src, __bos (dest)) \
: __stpcpy_ichk (dest, src))
static __inline__ char *
__attribute__ ((__always_inline__))
static __always_inline char *
__stpcpy_ichk (char *__restrict __dest, const char *__restrict __src)
{
return __builtin___stpcpy_chk (__dest, __src, __bos (__dest));
@ -142,8 +136,7 @@ __stpcpy_ichk (char *__restrict __dest, const char *__restrict __src)
((__bos (dest) != (size_t) -1) \
? __builtin___strncpy_chk (dest, src, len, __bos (dest)) \
: __strncpy_ichk (dest, src, len))
static __inline__ char *
__attribute__ ((__always_inline__))
static __always_inline char *
__strncpy_ichk (char *__restrict __dest, const char *__restrict __src,
size_t __len)
{
@ -155,8 +148,7 @@ __strncpy_ichk (char *__restrict __dest, const char *__restrict __src,
((__bos (dest) != (size_t) -1) \
? __builtin___strcat_chk (dest, src, __bos (dest)) \
: __strcat_ichk (dest, src))
static __inline__ char *
__attribute__ ((__always_inline__))
static __always_inline char *
__strcat_ichk (char *__restrict __dest, const char *__restrict __src)
{
return __builtin___strcat_chk (__dest, __src, __bos (__dest));
@ -167,8 +159,7 @@ __strcat_ichk (char *__restrict __dest, const char *__restrict __src)
((__bos (dest) != (size_t) -1) \
? __builtin___strncat_chk (dest, src, len, __bos (dest)) \
: __strncat_ichk (dest, src, len))
static __inline__ char *
__attribute__ ((__always_inline__))
static __always_inline char *
__strncat_ichk (char *__restrict __dest, const char *__restrict __src,
size_t __len)
{