From: Julian Seward Date: Mon, 26 Jan 2009 00:06:43 +0000 (+0000) Subject: Intercept and replace calls to calls to strnlen in glibc, for the X-Git-Tag: svn/VALGRIND_3_5_0~1037 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=98c1569aff69e4a0d47a131673ef1d7cfb23b5a9;p=thirdparty%2Fvalgrind.git Intercept and replace calls to calls to strnlen in glibc, for the usual reasons. Also update an expected output (lines numbers in h_intercepts.c should be removed by the regtest system, really). --> 3_4_BRANCH git-svn-id: svn://svn.valgrind.org/valgrind/trunk@9060 --- diff --git a/exp-ptrcheck/h_intercepts.c b/exp-ptrcheck/h_intercepts.c index 48819d4c6f..3ae8c6222e 100644 --- a/exp-ptrcheck/h_intercepts.c +++ b/exp-ptrcheck/h_intercepts.c @@ -69,6 +69,18 @@ +#define STRNLEN(soname, fnname) \ + SizeT VG_REPLACE_FUNCTION_ZU(soname,fnname) ( const char* str, SizeT n ); \ + SizeT VG_REPLACE_FUNCTION_ZU(soname,fnname) ( const char* str, SizeT n ) \ + { \ + SizeT i = 0; \ + while (i < n && str[i] != 0) i++; \ + return i; \ + } + +STRNLEN(m_libc_soname, strnlen) + + // Note that this replacement often doesn't get used because gcc inlines // calls to strlen() with its own built-in version. This can be very // confusing if you aren't expecting it. Other small functions in this file diff --git a/exp-ptrcheck/tests/bad_percentify.stderr.exp-glibc28-amd64 b/exp-ptrcheck/tests/bad_percentify.stderr.exp-glibc28-amd64 index 01c0b9fe4a..572da507d3 100644 --- a/exp-ptrcheck/tests/bad_percentify.stderr.exp-glibc28-amd64 +++ b/exp-ptrcheck/tests/bad_percentify.stderr.exp-glibc28-amd64 @@ -1,6 +1,6 @@ Invalid read of size 1 - at 0x........: strlen (h_intercepts.c:85) + at 0x........: strlen (h_intercepts.c:97) by 0x........: ... by 0x........: ... by 0x........: VG_print_translation_stats (bad_percentify.c:88) @@ -10,7 +10,7 @@ Invalid read of size 1 Actual: unknown Invalid read of size 1 - at 0x........: strlen (h_intercepts.c:85) + at 0x........: strlen (h_intercepts.c:97) by 0x........: ... by 0x........: ... by 0x........: VG_print_translation_stats (bad_percentify.c:93) @@ -20,7 +20,7 @@ Invalid read of size 1 Actual: unknown Invalid read of size 1 - at 0x........: strlen (h_intercepts.c:85) + at 0x........: strlen (h_intercepts.c:97) by 0x........: ... by 0x........: ... by 0x........: VG_print_translation_stats (bad_percentify.c:98)