From dc4bb1c2be1370fafd597602eb2b009cf10c025b Mon Sep 17 00:00:00 2001 From: Ulrich Drepper Date: Mon, 8 Aug 2005 19:04:11 +0000 Subject: [PATCH] * posix/bits/unistd.h (confstr, getgroups, ttyname_r, gethostname, getdomainname): Add __NTH. * stdlib/bits/stdlib.h (ptsname_r, wctomb, mbstowcs, wcstombs): Likewise. (realpath): Likewise. Use __const instead of const. Add __restrict keywords. * socket/bits/socket2.h (recvfrom): Add __restrict keyword to __buf. * wcsmbs/bits/wchar2.h (wmemcpy, wmemmove, wmempcpy, wmemset, wcscpy, wcpcpy, wcsncpy, wcpncpy, wcscat, wcsncat, vswprintf, wcrtomb, mbsrtowcs, wcsrtombs, mbsnrtowcs, wcsnrtombs): Add __NTH. * string/bits/string3.h (__memset_ichk): Likewise. (__memcpy_ichk, __memmove_ichk, __mempcpy_ichk, __strcpy_ichk, __stpcpy_ichk, __strncpy_ichk, stpncpy, __strcat_ichk, __strncat_ichk): Likewise. Use __const instead of const. (__stpncpy_chk): Use __const instead of const. (__stpncpy_alias): Use __REDIRECT_NTH instead of __REDIRECT. 2005-08-08 Ulrich Drepper Jakub Jelinek * nscd/mem.c (BLOCK_ALIGN_LOG, BLOCK_ALIGN, BLOCK_ALIGN_M1): Move definitions to... * nscd/nscd.h (BLOCK_ALIGN_LOG, BLOCK_ALIGN, BLOCK_ALIGN_M1): ...here. * nscd/connections.c (usekey): New enum. (check_use, verify_persistent_db): New functions. (nscd_init): If persistent database is corrupted, unlink it and recreate rather than falling back to non-persistent database. Call verify_persistent_db. Avoid overflows in total computation. 2005-08-08 Ulrich Drepper * iconvdata/utf-16.c (PREPARE_LOOP): Minor cleanups to make code better readable. Avoid passing var to loop function, it's not necessary at all. --- ChangeLog | 37 +++++++++ iconvdata/utf-16.c | 36 ++++---- nscd/connections.c | 221 +++++++++++++++++++++++++++++++++++++++++++++++++- nscd/mem.c | 10 +-- nscd/nscd.h | 7 +- posix/bits/unistd.h | 10 +-- socket/bits/socket2.h | 2 +- stdlib/bits/stdlib.h | 14 ++-- string/bits/string3.h | 35 ++++---- wcsmbs/bits/wchar2.h | 48 +++++------ 10 files changed, 333 insertions(+), 87 deletions(-) diff --git a/ChangeLog b/ChangeLog index c81a30f..73cb66b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,40 @@ +2005-08-08 Jakub Jelinek + + * posix/bits/unistd.h (confstr, getgroups, ttyname_r, gethostname, + getdomainname): Add __NTH. + * stdlib/bits/stdlib.h (ptsname_r, wctomb, mbstowcs, wcstombs): + Likewise. + (realpath): Likewise. Use __const instead of const. Add __restrict + keywords. + * socket/bits/socket2.h (recvfrom): Add __restrict keyword to __buf. + * wcsmbs/bits/wchar2.h (wmemcpy, wmemmove, wmempcpy, wmemset, + wcscpy, wcpcpy, wcsncpy, wcpncpy, wcscat, wcsncat, vswprintf, wcrtomb, + mbsrtowcs, wcsrtombs, mbsnrtowcs, wcsnrtombs): Add __NTH. + * string/bits/string3.h (__memset_ichk): Likewise. + (__memcpy_ichk, __memmove_ichk, __mempcpy_ichk, __strcpy_ichk, + __stpcpy_ichk, __strncpy_ichk, stpncpy, __strcat_ichk, + __strncat_ichk): Likewise. Use __const instead of const. + (__stpncpy_chk): Use __const instead of const. + (__stpncpy_alias): Use __REDIRECT_NTH instead of __REDIRECT. + +2005-08-08 Ulrich Drepper + Jakub Jelinek + + * nscd/mem.c (BLOCK_ALIGN_LOG, BLOCK_ALIGN, BLOCK_ALIGN_M1): Move + definitions to... + * nscd/nscd.h (BLOCK_ALIGN_LOG, BLOCK_ALIGN, BLOCK_ALIGN_M1): ...here. + * nscd/connections.c (usekey): New enum. + (check_use, verify_persistent_db): New functions. + (nscd_init): If persistent database is corrupted, unlink it and + recreate rather than falling back to non-persistent database. + Call verify_persistent_db. Avoid overflows in total computation. + +2005-08-08 Ulrich Drepper + + * iconvdata/utf-16.c (PREPARE_LOOP): Minor cleanups to make code + better readable. Avoid passing var to loop function, it's not + necessary at all. + 2005-08-07 Ulrich Drepper * elf/elf.h (DT_ALPHA_PLTRO): Use symbolic name in DT_ALPHA_PLTRO diff --git a/iconvdata/utf-16.c b/iconvdata/utf-16.c index 6b0dd9c..7f6c760 100644 --- a/iconvdata/utf-16.c +++ b/iconvdata/utf-16.c @@ -1,5 +1,5 @@ /* Conversion module for UTF-16. - Copyright (C) 1999, 2000-2002, 2003 Free Software Foundation, Inc. + Copyright (C) 1999, 2000-2002, 2003, 2005 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper , 1999. @@ -44,10 +44,9 @@ #define PREPARE_LOOP \ enum direction dir = ((struct utf16_data *) step->__data)->dir; \ enum variant var = ((struct utf16_data *) step->__data)->var; \ - int swap; \ - if (FROM_DIRECTION && var == UTF_16) \ + if (__builtin_expect (data->__invocation_counter == 0, 0) && var == UTF_16) \ { \ - if (data->__invocation_counter == 0) \ + if (FROM_DIRECTION) \ { \ /* We have to find out which byte order the file is encoded in. */ \ if (inptr + 2 > inend) \ @@ -63,19 +62,18 @@ *inptrp = inptr += 2; \ } \ } \ - } \ - else if (!FROM_DIRECTION && var == UTF_16 && !data->__internal_use \ - && data->__invocation_counter == 0) \ - { \ - /* Emit the Byte Order Mark. */ \ - if (__builtin_expect (outbuf + 2 > outend, 0)) \ - return __GCONV_FULL_OUTPUT; \ + else if (!FROM_DIRECTION && !data->__internal_use) \ + { \ + /* Emit the Byte Order Mark. */ \ + if (__builtin_expect (outbuf + 2 > outend, 0)) \ + return __GCONV_FULL_OUTPUT; \ \ - put16u (outbuf, BOM); \ - outbuf += 2; \ + put16u (outbuf, BOM); \ + outbuf += 2; \ + } \ } \ - swap = ((struct utf16_data *) step->__data)->swap; -#define EXTRA_LOOP_ARGS , var, swap + int swap = ((struct utf16_data *) step->__data)->swap; +#define EXTRA_LOOP_ARGS , swap /* Direction of the transformation. */ @@ -267,7 +265,7 @@ gconv_end (struct __gconv_step *data) } #define LOOP_NEED_FLAGS #define EXTRA_LOOP_DECLS \ - , enum variant var, int swap + , int swap #include @@ -328,8 +326,6 @@ gconv_end (struct __gconv_step *data) } \ else \ { \ - uint16_t u2; \ - \ /* It's a surrogate character. At least the first word says \ it is. */ \ if (__builtin_expect (inptr + 4 > inend, 0)) \ @@ -341,7 +337,7 @@ gconv_end (struct __gconv_step *data) } \ \ inptr += 2; \ - u2 = get16 (inptr); \ + uint16_t u2 = get16 (inptr); \ if (__builtin_expect (u2 < 0xdc00, 0) \ || __builtin_expect (u2 > 0xdfff, 0)) \ { \ @@ -358,7 +354,7 @@ gconv_end (struct __gconv_step *data) } #define LOOP_NEED_FLAGS #define EXTRA_LOOP_DECLS \ - , enum variant var, int swap + , int swap #include diff --git a/nscd/connections.c b/nscd/connections.c index 347862e..808ea33 100644 --- a/nscd/connections.c +++ b/nscd/connections.c @@ -199,6 +199,210 @@ writeall (int fd, const void *buf, size_t len) } +enum usekey + { + use_not = 0, + /* The following three are not really used, they are symbolic constants. */ + use_first = 16, + use_begin = 32, + use_end = 64, + + use_he = 1, + use_he_begin = use_he | use_begin, + use_he_end = use_he | use_end, +#if SEPARATE_KEY + use_key = 2, + use_key_begin = use_key | use_begin, + use_key_end = use_key | use_end, + use_key_first = use_key_begin | use_first, +#endif + use_data = 3, + use_data_begin = use_data | use_begin, + use_data_end = use_data | use_end, + use_data_first = use_data_begin | use_first + }; + + +static int +check_use (const char *data, nscd_ssize_t first_free, uint8_t *usemap, + enum usekey use, ref_t start, size_t len) +{ + assert (len >= 2); + + if (start > first_free || start + len > first_free + || (start & BLOCK_ALIGN_M1)) + return 0; + + if (usemap[start] == use_not) + { + /* Add the start marker. */ + usemap[start] = use | use_begin; + use &= ~use_first; + + while (--len > 0) + if (usemap[++start] != use_not) + return 0; + else + usemap[start] = use; + + /* Add the end marker. */ + usemap[start] = use | use_end; + } + else if ((usemap[start] & ~use_first) == ((use | use_begin) & ~use_first)) + { + /* Hash entries can't be shared. */ + if (use == use_he) + return 0; + + usemap[start] |= (use & use_first); + use &= ~use_first; + + while (--len > 1) + if (usemap[++start] != use) + return 0; + + if (usemap[++start] != (use | use_end)) + return 0; + } + else + /* Points to a wrong object or somewhere in the middle. */ + return 0; + + return 1; +} + + +/* Verify data in persistent database. */ +static int +verify_persistent_db (void *mem, struct database_pers_head *readhead, int dbnr) +{ + assert (dbnr == pwddb || dbnr == grpdb || dbnr == hstdb); + + time_t now = time (NULL); + + struct database_pers_head *head = mem; + struct database_pers_head head_copy = *head; + + /* Check that the header that was read matches the head in the database. */ + if (readhead != NULL && memcmp (head, readhead, sizeof (*head)) != 0) + return 0; + + /* First some easy tests: make sure the database header is sane. */ + if (head->version != DB_VERSION + || head->header_size != sizeof (*head) + /* We allow a timestamp to be one hour ahead of the current time. + This should cover daylight saving time changes. */ + || head->timestamp > now + 60 * 60 + 60 + || (head->gc_cycle & 1) + || (size_t) head->module > INT32_MAX / sizeof (ref_t) + || (size_t) head->data_size > INT32_MAX - head->module * sizeof (ref_t) + || head->first_free < 0 + || head->first_free > head->data_size + || (head->first_free & BLOCK_ALIGN_M1) != 0 + || head->maxnentries < 0 + || head->maxnsearched < 0) + return 0; + + uint8_t *usemap = calloc (head->first_free, 1); + if (usemap == NULL) + return 0; + + const char *data = (char *) &head->array[roundup (head->module, + ALIGN / sizeof (ref_t))]; + + nscd_ssize_t he_cnt = 0; + for (nscd_ssize_t cnt = 0; cnt < head->module; ++cnt) + { + ref_t work = head->array[cnt]; + + while (work != ENDREF) + { + if (! check_use (data, head->first_free, usemap, use_he, work, + sizeof (struct hashentry))) + goto fail; + + /* Now we know we can dereference the record. */ + struct hashentry *here = (struct hashentry *) (data + work); + + ++he_cnt; + + /* Make sure the record is for this type of service. */ + if (here->type >= LASTREQ + || serv2db[here->type] != &dbs[dbnr]) + goto fail; + + /* Validate boolean field value. */ + if (here->first != false && here->first != true) + goto fail; + + if (here->len < 0) + goto fail; + + /* Now the data. */ + if (here->packet < 0 + || here->packet > head->first_free + || here->packet + sizeof (struct datahead) > head->first_free) + goto fail; + + struct datahead *dh = (struct datahead *) (data + here->packet); + + if (! check_use (data, head->first_free, usemap, + use_data | (here->first ? use_first : 0), + here->packet, dh->allocsize)) + goto fail; + + if (dh->allocsize < sizeof (struct datahead) + || dh->recsize > dh->allocsize + || (dh->notfound != false && dh->notfound != true) + || (dh->usable != false && dh->usable != true)) + goto fail; + + if (here->key < here->packet + sizeof (struct datahead) + || here->key > here->packet + dh->allocsize + || here->key + here->len > here->packet + dh->allocsize) + { +#if SEPARATE_KEY + /* If keys can appear outside of data, this should be done + instead. But gc doesn't mark the data in that case. */ + if (! check_use (data, head->first_free, usemap, + use_key | (here->first ? use_first : 0), + here->key, here->len)) +#endif + goto fail; + } + + work = here->next; + } + } + + if (he_cnt != head->nentries) + goto fail; + + /* See if all data and keys had at least one reference from + he->first == true hashentry. */ + for (ref_t idx = 0; idx < head->first_free; ++idx) + { +#if SEPARATE_KEY + if (usemap[idx] == use_key_begin) + goto fail; +#endif + if (usemap[idx] == use_data_begin) + goto fail; + } + + /* Finally, make sure the database hasn't changed since the first test. */ + if (memcmp (mem, &head_copy, sizeof (*head)) != 0) + goto fail; + + free (usemap); + return 1; + +fail: + free (usemap); + return 0; +} + + /* Initialize database information structures. */ void nscd_init (void) @@ -242,7 +446,7 @@ nscd_init (void) fail_db: dbg_log (_("invalid persistent database file \"%s\": %s"), dbs[cnt].db_filename, strerror (errno)); - dbs[cnt].persistent = 0; + unlink (dbs[cnt].db_filename); } else if (head.module == 0 && head.data_size == 0) { @@ -255,22 +459,31 @@ nscd_init (void) dbg_log (_("invalid persistent database file \"%s\": %s"), dbs[cnt].db_filename, _("header size does not match")); - dbs[cnt].persistent = 0; + unlink (dbs[cnt].db_filename); } else if ((total = (sizeof (head) + roundup (head.module * sizeof (ref_t), ALIGN) + head.data_size)) - > st.st_size) + > st.st_size + || total < sizeof (head)) { dbg_log (_("invalid persistent database file \"%s\": %s"), dbs[cnt].db_filename, _("file size does not match")); - dbs[cnt].persistent = 0; + unlink (dbs[cnt].db_filename); } else if ((mem = mmap (NULL, total, PROT_READ | PROT_WRITE, MAP_SHARED, fd, 0)) == MAP_FAILED) goto fail_db; + else if (!verify_persistent_db (mem, &head, cnt)) + { + munmap (mem, total); + dbg_log (_("invalid persistent database file \"%s\": %s"), + dbs[cnt].db_filename, + _("verification failed")); + unlink (dbs[cnt].db_filename); + } else { /* Success. We have the database. */ diff --git a/nscd/mem.c b/nscd/mem.c index c3a0f96..a1108f3 100644 --- a/nscd/mem.c +++ b/nscd/mem.c @@ -1,5 +1,5 @@ /* Cache memory handling. - Copyright (C) 2004 Free Software Foundation, Inc. + Copyright (C) 2004, 2005 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Ulrich Drepper , 2004. @@ -34,12 +34,6 @@ #include "nscd.h" -/* Maximum alignment requirement we will encounter. */ -#define BLOCK_ALIGN_LOG 3 -#define BLOCK_ALIGN (1 << BLOCK_ALIGN_LOG) -#define BLOCK_ALIGN_M1 (BLOCK_ALIGN - 1) - - static int sort_he (const void *p1, const void *p2) { @@ -194,7 +188,7 @@ gc (struct database_dyn *db) highref -= BLOCK_ALIGN; } - /* No we can iterate over the MARK array and find bits which are not + /* Now we can iterate over the MARK array and find bits which are not set. These represent memory which can be recovered. */ size_t byte = 0; /* Find the first gap. */ diff --git a/nscd/nscd.h b/nscd/nscd.h index d5dc613..25a4b38 100644 --- a/nscd/nscd.h +++ b/nscd/nscd.h @@ -1,4 +1,4 @@ -/* Copyright (c) 1998, 1999, 2000, 2001, 2003, 2004 +/* Copyright (c) 1998, 1999, 2000, 2001, 2003, 2004, 2005 Free Software Foundation, Inc. This file is part of the GNU C Library. Contributed by Thorsten Kukuk , 1998. @@ -94,6 +94,11 @@ struct database_dyn /* Path used when not using persistent storage. */ #define _PATH_NSCD_XYZ_DB_TMP "/var/run/nscd/dbXXXXXX" +/* Maximum alignment requirement we will encounter. */ +#define BLOCK_ALIGN_LOG 3 +#define BLOCK_ALIGN (1 << BLOCK_ALIGN_LOG) +#define BLOCK_ALIGN_M1 (BLOCK_ALIGN - 1) + /* Global variables. */ extern struct database_dyn dbs[lastdb]; diff --git a/posix/bits/unistd.h b/posix/bits/unistd.h index b6c756a..b72b7c7 100644 --- a/posix/bits/unistd.h +++ b/posix/bits/unistd.h @@ -135,7 +135,7 @@ extern size_t __REDIRECT_NTH (__confstr_alias, (int __name, char *__buf, size_t __len), confstr); extern __always_inline size_t -confstr (int __name, char *__buf, size_t __len) +__NTH (confstr (int __name, char *__buf, size_t __len)) { if (__bos (__buf) != (size_t) -1 && (!__builtin_constant_p (__len) || __bos (__buf) < __len)) @@ -150,7 +150,7 @@ extern int __REDIRECT_NTH (__getgroups_alias, (int __size, __gid_t __list[]), getgroups) __wur; extern __always_inline int -getgroups (int __size, __gid_t __list[]) +__NTH (getgroups (int __size, __gid_t __list[])) { if (__bos (__list) != (size_t) -1 && (!__builtin_constant_p (__size) @@ -167,7 +167,7 @@ extern int __REDIRECT_NTH (__ttyname_r_alias, (int __fd, char *__buf, __nonnull ((2)); extern __always_inline int -ttyname_r (int __fd, char *__buf, size_t __buflen) +__NTH (ttyname_r (int __fd, char *__buf, size_t __buflen)) { if (__bos (__buf) != (size_t) -1 && (!__builtin_constant_p (__buflen) || __buflen > __bos (__buf))) @@ -200,7 +200,7 @@ extern int __REDIRECT_NTH (__gethostname_alias, (char *__buf, size_t __buflen), gethostname) __nonnull ((1)); extern __always_inline int -gethostname (char *__buf, size_t __buflen) +__NTH (gethostname (char *__buf, size_t __buflen)) { if (__bos (__buf) != (size_t) -1 && (!__builtin_constant_p (__buflen) || __buflen > __bos (__buf))) @@ -218,7 +218,7 @@ extern int __REDIRECT_NTH (__getdomainname_alias, (char *__buf, getdomainname) __nonnull ((1)) __wur; extern __always_inline int -getdomainname (char *__buf, size_t __buflen) +__NTH (getdomainname (char *__buf, size_t __buflen)) { if (__bos (__buf) != (size_t) -1 && (!__builtin_constant_p (__buflen) || __buflen > __bos (__buf))) diff --git a/socket/bits/socket2.h b/socket/bits/socket2.h index a88c154..2543ea3 100644 --- a/socket/bits/socket2.h +++ b/socket/bits/socket2.h @@ -45,7 +45,7 @@ extern ssize_t __REDIRECT (__recvfrom_alias, socklen_t *__restrict __addr_len), recvfrom); extern __always_inline ssize_t -recvfrom (int __fd, void *__buf, size_t __n, int __flags, +recvfrom (int __fd, void *__restrict __buf, size_t __n, int __flags, __SOCKADDR_ARG __addr, socklen_t *__restrict __addr_len) { if (__bos0 (__buf) != (size_t) -1 diff --git a/stdlib/bits/stdlib.h b/stdlib/bits/stdlib.h index 9ff8f62..9e2519d 100644 --- a/stdlib/bits/stdlib.h +++ b/stdlib/bits/stdlib.h @@ -29,7 +29,7 @@ extern char *__REDIRECT_NTH (__realpath_alias, char *__restrict __resolved), realpath) __wur; extern __always_inline __wur char * -realpath (const char *__name, char *__resolved) +__NTH (realpath (__const char *__restrict __name, char *__restrict __resolved)) { if (__bos (__resolved) != (size_t) -1) return __realpath_chk (__name, __resolved, __bos (__resolved)); @@ -45,7 +45,7 @@ extern int __REDIRECT_NTH (__ptsname_r_alias, (int __fd, char *__buf, __nonnull ((2)); extern __always_inline int -ptsname_r (int __fd, char *__buf, size_t __buflen) +__NTH (ptsname_r (int __fd, char *__buf, size_t __buflen)) { if (__bos (__buf) != (size_t) -1 && (!__builtin_constant_p (__buflen) || __buflen > __bos (__buf))) @@ -60,7 +60,7 @@ extern int __REDIRECT_NTH (__wctomb_alias, (char *__s, wchar_t __wchar), wctomb) __wur; extern __always_inline __wur int -wctomb (char *__s, wchar_t __wchar) +__NTH (wctomb (char *__s, wchar_t __wchar)) { /* We would have to include to get a definition of MB_LEN_MAX. But this would only disturb the namespace. So we define our own @@ -84,8 +84,8 @@ extern size_t __REDIRECT_NTH (__mbstowcs_alias, size_t __len), mbstowcs); extern __always_inline size_t -mbstowcs (wchar_t *__restrict __dst, __const char *__restrict __src, - size_t __len) +__NTH (mbstowcs (wchar_t *__restrict __dst, __const char *__restrict __src, + size_t __len)) { if (__bos (__dst) != (size_t) -1 && (!__builtin_constant_p (__len) @@ -104,8 +104,8 @@ extern size_t __REDIRECT_NTH (__wcstombs_alias, size_t __len), wcstombs); extern __always_inline size_t -wcstombs (char *__restrict __dst, __const wchar_t *__restrict __src, - size_t __len) +__NTH (wcstombs (char *__restrict __dst, __const wchar_t *__restrict __src, + size_t __len)) { if (__bos (__dst) != (size_t) -1 && (!__builtin_constant_p (__len) || __len > __bos (__dst))) diff --git a/string/bits/string3.h b/string/bits/string3.h index 8da73ff..041ac11 100644 --- a/string/bits/string3.h +++ b/string/bits/string3.h @@ -45,8 +45,8 @@ ? __builtin___memcpy_chk (dest, src, len, __bos0 (dest)) \ : __memcpy_ichk (dest, src, len)) static __always_inline void * -__memcpy_ichk (void *__restrict __dest, const void *__restrict __src, - size_t __len) +__NTH (__memcpy_ichk (void *__restrict __dest, __const void *__restrict __src, + size_t __len)) { return __builtin___memcpy_chk (__dest, __src, __len, __bos0 (__dest)); } @@ -57,7 +57,7 @@ __memcpy_ichk (void *__restrict __dest, const void *__restrict __src, ? __builtin___memmove_chk (dest, src, len, __bos0 (dest)) \ : __memmove_ichk (dest, src, len)) static __always_inline void * -__memmove_ichk (void *__dest, const void *__src, size_t __len) +__NTH (__memmove_ichk (void *__dest, __const void *__src, size_t __len)) { return __builtin___memmove_chk (__dest, __src, __len, __bos0 (__dest)); } @@ -69,8 +69,8 @@ __memmove_ichk (void *__dest, const void *__src, size_t __len) ? __builtin___mempcpy_chk (dest, src, len, __bos0 (dest)) \ : __mempcpy_ichk (dest, src, len)) static __always_inline void * -__mempcpy_ichk (void *__restrict __dest, const void *__restrict __src, - size_t __len) +__NTH (__mempcpy_ichk (void *__restrict __dest, + __const void *__restrict __src, size_t __len)) { return __builtin___mempcpy_chk (__dest, __src, __len, __bos0 (__dest)); } @@ -91,7 +91,7 @@ __warndecl (__warn_memset_zero_len, ? __builtin___memset_chk (dest, ch, len, __bos0 (dest)) \ : __memset_ichk (dest, ch, len))) static __always_inline void * -__memset_ichk (void *__dest, int __ch, size_t __len) +__NTH (__memset_ichk (void *__dest, int __ch, size_t __len)) { return __builtin___memset_chk (__dest, __ch, __len, __bos0 (__dest)); } @@ -113,7 +113,7 @@ __memset_ichk (void *__dest, int __ch, size_t __len) ? __builtin___strcpy_chk (dest, src, __bos (dest)) \ : __strcpy_ichk (dest, src)) static __always_inline char * -__strcpy_ichk (char *__restrict __dest, const char *__restrict __src) +__NTH (__strcpy_ichk (char *__restrict __dest, __const char *__restrict __src)) { return __builtin___strcpy_chk (__dest, __src, __bos (__dest)); } @@ -125,7 +125,7 @@ __strcpy_ichk (char *__restrict __dest, const char *__restrict __src) ? __builtin___stpcpy_chk (dest, src, __bos (dest)) \ : __stpcpy_ichk (dest, src)) static __always_inline char * -__stpcpy_ichk (char *__restrict __dest, const char *__restrict __src) +__NTH (__stpcpy_ichk (char *__restrict __dest, __const char *__restrict __src)) { return __builtin___stpcpy_chk (__dest, __src, __bos (__dest)); } @@ -137,21 +137,22 @@ __stpcpy_ichk (char *__restrict __dest, const char *__restrict __src) ? __builtin___strncpy_chk (dest, src, len, __bos (dest)) \ : __strncpy_ichk (dest, src, len)) static __always_inline char * -__strncpy_ichk (char *__restrict __dest, const char *__restrict __src, - size_t __len) +__NTH (__strncpy_ichk (char *__restrict __dest, __const char *__restrict __src, + size_t __len)) { return __builtin___strncpy_chk (__dest, __src, __len, __bos (__dest)); } // XXX We have no corresponding builtin yet. -extern char *__stpncpy_chk (char *__dest, const char *__src, size_t __n, +extern char *__stpncpy_chk (char *__dest, __const char *__src, size_t __n, size_t __destlen) __THROW; -extern char *__REDIRECT (__stpncpy_alias, (char *__dest, const char *__src, - size_t __n), stpncpy) __THROW; +extern char *__REDIRECT_NTH (__stpncpy_alias, (char *__dest, + __const char *__src, + size_t __n), stpncpy); extern __always_inline char * -stpncpy (char *__dest, const char *__src, size_t __n) +__NTH (stpncpy (char *__dest, __const char *__src, size_t __n)) { if (__bos (__dest) != (size_t) -1 && (!__builtin_constant_p (__n) || __n <= __bos (__dest))) @@ -165,7 +166,7 @@ stpncpy (char *__dest, const char *__src, size_t __n) ? __builtin___strcat_chk (dest, src, __bos (dest)) \ : __strcat_ichk (dest, src)) static __always_inline char * -__strcat_ichk (char *__restrict __dest, const char *__restrict __src) +__NTH (__strcat_ichk (char *__restrict __dest, __const char *__restrict __src)) { return __builtin___strcat_chk (__dest, __src, __bos (__dest)); } @@ -176,8 +177,8 @@ __strcat_ichk (char *__restrict __dest, const char *__restrict __src) ? __builtin___strncat_chk (dest, src, len, __bos (dest)) \ : __strncat_ichk (dest, src, len)) static __always_inline char * -__strncat_ichk (char *__restrict __dest, const char *__restrict __src, - size_t __len) +__NTH (__strncat_ichk (char *__restrict __dest, __const char *__restrict __src, + size_t __len)) { return __builtin___strncat_chk (__dest, __src, __len, __bos (__dest)); } diff --git a/wcsmbs/bits/wchar2.h b/wcsmbs/bits/wchar2.h index ec61aac..fba18d9 100644 --- a/wcsmbs/bits/wchar2.h +++ b/wcsmbs/bits/wchar2.h @@ -31,8 +31,8 @@ extern wchar_t *__REDIRECT_NTH (__wmemcpy_alias, wmemcpy); extern __always_inline wchar_t * -wmemcpy (wchar_t *__restrict __s1, __const wchar_t *__restrict __s2, - size_t __n) +__NTH (wmemcpy (wchar_t *__restrict __s1, __const wchar_t *__restrict __s2, + size_t __n)) { if (__bos0 (__s1) != (size_t) -1) return __wmemcpy_chk (__s1, __s2, __n, __bos0 (__s1) / sizeof (wchar_t)); @@ -47,8 +47,8 @@ extern wchar_t *__REDIRECT_NTH (__wmemmove_alias, (wchar_t *__s1, size_t __n), wmemmove); extern __always_inline wchar_t * -wmemmove (wchar_t *__restrict __s1, __const wchar_t *__restrict __s2, - size_t __n) +__NTH (wmemmove (wchar_t *__restrict __s1, __const wchar_t *__restrict __s2, + size_t __n)) { if (__bos0 (__s1) != (size_t) -1) return __wmemmove_chk (__s1, __s2, __n, __bos0 (__s1) / sizeof (wchar_t)); @@ -66,8 +66,8 @@ extern wchar_t *__REDIRECT_NTH (__wmempcpy_alias, size_t __n), wmempcpy); extern __always_inline wchar_t * -wmempcpy (wchar_t *__restrict __s1, __const wchar_t *__restrict __s2, - size_t __n) +__NTH (wmempcpy (wchar_t *__restrict __s1, __const wchar_t *__restrict __s2, + size_t __n)) { if (__bos0 (__s1) != (size_t) -1) return __wmempcpy_chk (__s1, __s2, __n, __bos0 (__s1) / sizeof (wchar_t)); @@ -82,7 +82,7 @@ extern wchar_t *__REDIRECT_NTH (__wmemset_alias, (wchar_t *__s, wchar_t __c, size_t __n), wmemset); extern __always_inline wchar_t * -wmemset (wchar_t *__restrict __s, wchar_t __c, size_t __n) +__NTH (wmemset (wchar_t *__restrict __s, wchar_t __c, size_t __n)) { if (__bos0 (__s) != (size_t) -1) return __wmemset_chk (__s, __c, __n, __bos0 (__s) / sizeof (wchar_t)); @@ -98,7 +98,7 @@ extern wchar_t *__REDIRECT_NTH (__wcscpy_alias, __const wchar_t *__restrict __src), wcscpy); extern __always_inline wchar_t * -wcscpy (wchar_t *__dest, __const wchar_t *__src) +__NTH (wcscpy (wchar_t *__dest, __const wchar_t *__src)) { if (__bos (__dest) != (size_t) -1) return __wcscpy_chk (__dest, __src, __bos (__dest) / sizeof (wchar_t)); @@ -113,7 +113,7 @@ extern wchar_t *__REDIRECT_NTH (__wcpcpy_alias, (wchar_t *__dest, wcpcpy); extern __always_inline wchar_t * -wcpcpy (wchar_t *__dest, __const wchar_t *__src) +__NTH (wcpcpy (wchar_t *__dest, __const wchar_t *__src)) { if (__bos (__dest) != (size_t) -1) return __wcpcpy_chk (__dest, __src, __bos (__dest) / sizeof (wchar_t)); @@ -130,7 +130,7 @@ extern wchar_t *__REDIRECT_NTH (__wcsncpy_alias, size_t __n), wcsncpy); extern __always_inline wchar_t * -wcsncpy (wchar_t *__dest, __const wchar_t *__src, size_t __n) +__NTH (wcsncpy (wchar_t *__dest, __const wchar_t *__src, size_t __n)) { if (__bos (__dest) != (size_t) -1 && (!__builtin_constant_p (__n) || __bos (__dest) >= __n)) @@ -149,7 +149,7 @@ extern wchar_t *__REDIRECT_NTH (__wcpncpy_alias, size_t __n), wcpncpy); extern __always_inline wchar_t * -wcpncpy (wchar_t *__dest, __const wchar_t *__src, size_t __n) +__NTH (wcpncpy (wchar_t *__dest, __const wchar_t *__src, size_t __n)) { if (__bos (__dest) != (size_t) -1 && (!__builtin_constant_p (__n) || __bos (__dest) >= __n)) @@ -167,7 +167,7 @@ extern wchar_t *__REDIRECT_NTH (__wcscat_alias, __const wchar_t *__restrict __src), wcscat); extern __always_inline wchar_t * -wcscat (wchar_t *__dest, __const wchar_t *__src) +__NTH (wcscat (wchar_t *__dest, __const wchar_t *__src)) { if (__bos (__dest) != (size_t) -1) return __wcscat_chk (__dest, __src, __bos (__dest) / sizeof (wchar_t)); @@ -184,7 +184,7 @@ extern wchar_t *__REDIRECT_NTH (__wcsncat_alias, size_t __n), wcsncat); extern __always_inline wchar_t * -wcsncat (wchar_t *__dest, __const wchar_t *__src, size_t __n) +__NTH (wcsncat (wchar_t *__dest, __const wchar_t *__src, size_t __n)) { if (__bos (__dest) != (size_t) -1) return __wcsncat_chk (__dest, __src, __n, @@ -218,8 +218,8 @@ extern int __REDIRECT_NTH (__vswprintf_alias, extern __always_inline int -vswprintf (wchar_t *__s, size_t __n, __const wchar_t *__format, - __gnuc_va_list __arg) +__NTH (vswprintf (wchar_t *__s, size_t __n, __const wchar_t *__format, + __gnuc_va_list __arg)) { if (__bos (__s) != (size_t) -1 || __USE_FORTIFY_LEVEL > 1) return __vswprintf_chk (__s, __n, __USE_FORTIFY_LEVEL - 1, __bos (__s), @@ -293,7 +293,7 @@ extern size_t __REDIRECT_NTH (__wcrtomb_alias, mbstate_t *__restrict __ps), wcrtomb) __wur; extern __always_inline __wur size_t -wcrtomb (char *__s, wchar_t __wchar, mbstate_t *__ps) +__NTH (wcrtomb (char *__s, wchar_t __wchar, mbstate_t *__ps)) { /* We would have to include to get a definition of MB_LEN_MAX. But this would only disturb the namespace. So we define our own @@ -319,8 +319,8 @@ extern size_t __REDIRECT_NTH (__mbsrtowcs_alias, mbsrtowcs); extern __always_inline size_t -mbsrtowcs (wchar_t *__restrict __dst, __const char **__restrict __src, - size_t __len, mbstate_t *__restrict __ps) +__NTH (mbsrtowcs (wchar_t *__restrict __dst, __const char **__restrict __src, + size_t __len, mbstate_t *__restrict __ps)) { if (__bos (__dst) != (size_t) -1 && (!__builtin_constant_p (__len) @@ -341,8 +341,8 @@ extern size_t __REDIRECT_NTH (__wcsrtombs_alias, wcsrtombs); extern __always_inline size_t -wcsrtombs (char *__restrict __dst, __const wchar_t **__restrict __src, - size_t __len, mbstate_t *__restrict __ps) +__NTH (wcsrtombs (char *__restrict __dst, __const wchar_t **__restrict __src, + size_t __len, mbstate_t *__restrict __ps)) { if (__bos (__dst) != (size_t) -1 && (!__builtin_constant_p (__len) || __len > __bos (__dst))) @@ -363,8 +363,8 @@ extern size_t __REDIRECT_NTH (__mbsnrtowcs_alias, mbsnrtowcs); extern __always_inline size_t -mbsnrtowcs (wchar_t *__restrict __dst, __const char **__restrict __src, - size_t __nmc, size_t __len, mbstate_t *__restrict __ps) +__NTH (mbsnrtowcs (wchar_t *__restrict __dst, __const char **__restrict __src, + size_t __nmc, size_t __len, mbstate_t *__restrict __ps)) { if (__bos (__dst) != (size_t) -1 && (!__builtin_constant_p (__len) @@ -386,8 +386,8 @@ extern size_t __REDIRECT_NTH (__wcsnrtombs_alias, mbstate_t *__restrict __ps), wcsnrtombs); extern __always_inline size_t -wcsnrtombs (char *__restrict __dst, __const wchar_t **__restrict __src, - size_t __nwc, size_t __len, mbstate_t *__restrict __ps) +__NTH (wcsnrtombs (char *__restrict __dst, __const wchar_t **__restrict __src, + size_t __nwc, size_t __len, mbstate_t *__restrict __ps)) { if (__bos (__dst) != (size_t) -1 && (!__builtin_constant_p (__len) || __len > __bos (__dst))) -- 2.7.4