From: Julian Seward Date: Wed, 21 Aug 2002 22:29:14 +0000 (+0000) Subject: Fix for the following: X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=0cb50c90f7c017221bed9a0f1a33b2f6f73292f5;p=thirdparty%2Fvalgrind.git Fix for the following: vg_mylibc:VG_(strncpy)() behaves dubiously -- it can write a '\0' past the end of the given array. Possibly accounting for some strange behaviour in the g++3 demangler? git-svn-id: svn://svn.valgrind.org/valgrind/branches/VALGRIND_1_0_BRANCH@613 --- diff --git a/vg_mylibc.c b/vg_mylibc.c index da63d4c2e8..38f5a3dd42 100644 --- a/vg_mylibc.c +++ b/vg_mylibc.c @@ -765,7 +765,13 @@ void VG_(strncpy_safely) ( Char* dest, const Char* src, Int ndest ) void VG_(strncpy) ( Char* dest, const Char* src, Int ndest ) { - VG_(strncpy_safely)( dest, src, ndest+1 ); + Int i = 0; + while (True) { + if (src[i] == 0) return; + if (i >= ndest) return; + dest[i] = src[i]; + i++; + } }