mirror of
https://sourceware.org/git/glibc.git
synced 2025-09-05 14:24:06 +03:00
Update.
2004-10-18 Jakub Jelinek <jakub@redhat.com> * sysdeps/generic/strcpy_chk.c (__strcpy_chk): Speed up by checking destlen only every 4 bytes.
This commit is contained in:
@@ -1,3 +1,8 @@
|
|||||||
|
2004-10-18 Jakub Jelinek <jakub@redhat.com>
|
||||||
|
|
||||||
|
* sysdeps/generic/strcpy_chk.c (__strcpy_chk): Speed up by checking
|
||||||
|
destlen only every 4 bytes.
|
||||||
|
|
||||||
2004-10-19 Ulrich Drepper <drepper@redhat.com>
|
2004-10-19 Ulrich Drepper <drepper@redhat.com>
|
||||||
|
|
||||||
* nss/getent.c (hosts_keys): Let inet_pton decide whether the
|
* nss/getent.c (hosts_keys): Let inet_pton decide whether the
|
||||||
|
@@ -31,14 +31,36 @@ __strcpy_chk (dest, src, destlen)
|
|||||||
{
|
{
|
||||||
reg_char c;
|
reg_char c;
|
||||||
char *s = (char *) src;
|
char *s = (char *) src;
|
||||||
const ptrdiff_t off = dest - s - 1;
|
const ptrdiff_t off = dest - s;
|
||||||
|
|
||||||
|
while (__builtin_expect (destlen >= 4, 0))
|
||||||
|
{
|
||||||
|
c = s[0];
|
||||||
|
s[off] = c;
|
||||||
|
if (c == '\0')
|
||||||
|
return dest;
|
||||||
|
c = s[1];
|
||||||
|
s[off + 1] = c;
|
||||||
|
if (c == '\0')
|
||||||
|
return dest;
|
||||||
|
c = s[2];
|
||||||
|
s[off + 2] = c;
|
||||||
|
if (c == '\0')
|
||||||
|
return dest;
|
||||||
|
c = s[3];
|
||||||
|
s[off + 3] = c;
|
||||||
|
if (c == '\0')
|
||||||
|
return dest;
|
||||||
|
destlen -= 4;
|
||||||
|
s += 4;
|
||||||
|
}
|
||||||
|
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
if (__builtin_expect (destlen-- == 0, 0))
|
if (__builtin_expect (destlen-- == 0, 0))
|
||||||
__chk_fail ();
|
__chk_fail ();
|
||||||
c = *s++;
|
c = *s;
|
||||||
s[off] = c;
|
*(s++ + off) = c;
|
||||||
}
|
}
|
||||||
while (c != '\0');
|
while (c != '\0');
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user