|
From: <sv...@va...> - 2007-01-28 06:32:06
|
Author: sewardj
Date: 2007-01-28 06:32:01 +0000 (Sun, 28 Jan 2007)
New Revision: 6556
Log:
__stpcpy_chk: sync with Dirk's original proposal, and show origins
Modified:
trunk/memcheck/mc_replace_strmem.c
Modified: trunk/memcheck/mc_replace_strmem.c
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D
--- trunk/memcheck/mc_replace_strmem.c 2007-01-27 02:05:38 UTC (rev 6555)
+++ trunk/memcheck/mc_replace_strmem.c 2007-01-28 06:32:01 UTC (rev 6556)
@@ -542,7 +542,8 @@
GLIBC232_RAWMEMCHR(m_libc_soname, rawmemchr)
=20
=20
-/* glibc variant of strcpy that checks the dest is big enough. */
+/* glibc variant of strcpy that checks the dest is big enough.
+ Copied from glibc-2.5/debug/test-strcpy_chk.c. */
#define GLIBC25___STRCPY_CHK(soname,fnname) \
char* VG_REPLACE_FUNCTION_ZU(soname,fnname) \
(char* dst, const char* src, SizeT len); =
\
@@ -568,7 +569,8 @@
GLIBC25___STRCPY_CHK(m_libc_soname, __strcpy_chk)
=20
=20
-/* glibc variant of stpcpy that checks the dest is big enough. */
+/* glibc variant of stpcpy that checks the dest is big enough.
+ Copied from glibc-2.5/debug/test-stpcpy_chk.c. */
#define GLIBC25___STPCPY_CHK(soname,fnname) \
char* VG_REPLACE_FUNCTION_ZU(soname,fnname) \
(char* dst, const char* src, SizeT len); =
\
@@ -576,11 +578,11 @@
(char* dst, const char* src, SizeT len) \
{ \
extern void _exit(int status); \
- do { \
- if (len-- =3D=3D 0) \
+ if (! len) \
+ goto badness; \
+ while ((*dst++ =3D *src++) !=3D '\0') \
+ if (--len =3D=3D 0) \
goto badness; \
- *dst++ =3D *src; \
- } while (*src++ !=3D '\0'); \
return dst - 1; \
badness: \
VALGRIND_PRINTF_BACKTRACE( \
|