From f7f092da62c86759cb3d61f44e2a3fbd84126a77 Mon Sep 17 00:00:00 2001 From: Stas Degteff Date: Mon, 21 Feb 2011 13:08:04 +0000 Subject: [PATCH] Prevent potencial bug: use memmove() instead strcpy() for overlap source and destination --- goldlib/gall/gstrutil.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/goldlib/gall/gstrutil.cpp b/goldlib/gall/gstrutil.cpp index 6ec7b8d..0901c86 100644 --- a/goldlib/gall/gstrutil.cpp +++ b/goldlib/gall/gstrutil.cpp @@ -156,7 +156,8 @@ static char* strdel(const char* substr, char* str) { if(!dest) return NULL; char* src = dest + strlen(substr); - strcpy(dest, src); /* Source and destination overlap. This is rigth. */ +// strcpy(dest, src); /* Source and destination overlap. This is rigth. */ + memmove(dest, src, strlen(src)+1); return str; } @@ -171,7 +172,8 @@ static char* stridel(const char* substr, char* str) { if(!dest) return NULL; char* src = dest + strlen(substr); - strcpy(dest, src); +// strcpy(dest, src); + memmove(dest, src, strlen(src)+1); /* Source and destination overlaps. */ return str; }