|
From: <sv...@va...> - 2007-01-29 01:07:25
|
Author: sewardj
Date: 2007-01-29 01:07:21 +0000 (Mon, 29 Jan 2007)
New Revision: 6558
Log:
Merge r6553/6 (Intercept __stpcpy_chk. (Dirk Mueller))
Modified:
branches/VALGRIND_3_2_BRANCH/memcheck/mc_replace_strmem.c
Modified: branches/VALGRIND_3_2_BRANCH/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
--- branches/VALGRIND_3_2_BRANCH/memcheck/mc_replace_strmem.c 2007-01-29 =
00:52:43 UTC (rev 6557)
+++ branches/VALGRIND_3_2_BRANCH/memcheck/mc_replace_strmem.c 2007-01-29 =
01:07:21 UTC (rev 6558)
@@ -547,7 +547,8 @@
GLIBC232_RAWMEMCHR(m_libc_so_star, 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-stpcpy_chk.c. */
#define GLIBC25___STRCPY_CHK(soname,fnname) \
char* VG_REPLACE_FUNCTION_ZU(soname,fnname) \
(char* dst, const char* src, SizeT len); =
\
@@ -573,6 +574,32 @@
GLIBC25___STRCPY_CHK(m_libc_so_star, __strcpy_chk)
=20
=20
+/* 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); =
\
+ char* VG_REPLACE_FUNCTION_ZU(soname,fnname) \
+ (char* dst, const char* src, SizeT len) \
+ { \
+ extern void _exit(int status); \
+ if (! len) \
+ goto badness; \
+ while ((*dst++ =3D *src++) !=3D '\0') \
+ if (--len =3D=3D 0) \
+ goto badness; \
+ return dst - 1; \
+ badness: \
+ VALGRIND_PRINTF_BACKTRACE( \
+ "***buffer overflow detected ***: program terminated"); \
+ _exit(127); \
+ /*NOTREACHED*/ \
+ return NULL; \
+ }
+
+GLIBC25___STPCPY_CHK(m_libc_so_star, __stpcpy_chk)
+
+
/* mempcpy */
#define GLIBC25_MEMPCPY(soname, fnname) \
void* VG_REPLACE_FUNCTION_ZU(soname,fnname) \
|