|
From: <sv...@va...> - 2007-01-27 00:49:47
|
Author: sewardj
Date: 2007-01-27 00:49:44 +0000 (Sat, 27 Jan 2007)
New Revision: 6553
Log:
Intercept __stpcpy_chk. (Dirk Mueller)
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-24 01:29:25 UTC (rev 6552)
+++ trunk/memcheck/mc_replace_strmem.c 2007-01-27 00:49:44 UTC (rev 6553)
@@ -568,6 +568,31 @@
GLIBC25___STRCPY_CHK(m_libc_soname, __strcpy_chk)
=20
=20
+/* glibc variant of stpcpy that checks the dest is big enough. */
+#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); \
+ do { \
+ if (len-- =3D=3D 0) \
+ goto badness; \
+ *dst++ =3D *src; \
+ } while (*src++ !=3D '\0'); \
+ return dst - 1; \
+ badness: \
+ VALGRIND_PRINTF_BACKTRACE( \
+ "***buffer overflow detected ***: program terminated"); \
+ _exit(127); \
+ /*NOTREACHED*/ \
+ return NULL; \
+ }
+
+GLIBC25___STPCPY_CHK(m_libc_soname, __stpcpy_chk)
+
+
/* mempcpy */
#define GLIBC25_MEMPCPY(soname, fnname) \
void* VG_REPLACE_FUNCTION_ZU(soname,fnname) \
|