summaryrefslogtreecommitdiff
path: root/debug/strncpy_chk.c
diff options
context:
space:
mode:
authorOndřej Bílka <neleai@seznam.cz>2013-12-04 02:02:25 +0100
committerOndřej Bílka <neleai@seznam.cz>2013-12-04 02:41:12 +0100
commitd674f0ef3898c0d1fd5cec76c1c736d9cd9bc7d1 (patch)
treeb6a4f57e8e469c61fb3b81e7903961d50a4203f3 /debug/strncpy_chk.c
parent6905a19f7a8443950f105b6716f6b4b1f98c4dbd (diff)
Refactor several debug routines.
To simplify additions of debug routines we replace a custom function implementation by a simple call.
Diffstat (limited to 'debug/strncpy_chk.c')
-rw-r--r--debug/strncpy_chk.c57
1 files changed, 1 insertions, 56 deletions
diff --git a/debug/strncpy_chk.c b/debug/strncpy_chk.c
index d067bd9ac3..2e078b1e4f 100644
--- a/debug/strncpy_chk.c
+++ b/debug/strncpy_chk.c
@@ -26,63 +26,8 @@ __strncpy_chk (s1, s2, n, s1len)
size_t n;
size_t s1len;
{
- char c;
- char *s = s1;
-
if (__builtin_expect (s1len < n, 0))
__chk_fail ();
- --s1;
-
- if (n >= 4)
- {
- size_t n4 = n >> 2;
-
- for (;;)
- {
- c = *s2++;
- *++s1 = c;
- if (c == '\0')
- break;
- c = *s2++;
- *++s1 = c;
- if (c == '\0')
- break;
- c = *s2++;
- *++s1 = c;
- if (c == '\0')
- break;
- c = *s2++;
- *++s1 = c;
- if (c == '\0')
- break;
- if (--n4 == 0)
- goto last_chars;
- }
- n = n - (s1 - s) - 1;
- if (n == 0)
- return s;
- goto zero_fill;
- }
-
- last_chars:
- n &= 3;
- if (n == 0)
- return s;
-
- do
- {
- c = *s2++;
- *++s1 = c;
- if (--n == 0)
- return s;
- }
- while (c != '\0');
-
- zero_fill:
- do
- *++s1 = '\0';
- while (--n > 0);
-
- return s;
+ return strncpy (s1, s2, n);
}