From 608d0ac93823be9b7da40866d487f6b6bcba113e Mon Sep 17 00:00:00 2001 From: Daniel Veillard Date: Thu, 14 Aug 2003 22:44:25 +0000 Subject: [PATCH] fixing an use of strcpy() where both strings overlap pointed out by * uri.c: fixing an use of strcpy() where both strings overlap pointed out by valgrind. Daniel --- ChangeLog | 5 +++++ uri.c | 8 ++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/ChangeLog b/ChangeLog index b8bcac05..e6813ffc 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Fri Aug 15 00:41:58 CEST 2003 Daniel Veillard + + * uri.c: fixing an use of strcpy() where both strings overlap + pointed out by valgrind. + Thu Aug 14 17:10:39 CEST 2003 Daniel Veillard * DOCBparser.c globals.c include/libxml/xmlmemory.h: get rid of diff --git a/uri.c b/uri.c index 6b0aa27b..13c875b3 100644 --- a/uri.c +++ b/uri.c @@ -691,7 +691,7 @@ xmlNormalizeURIPath(char *path) { * "current position" pointer. */ while (1) { - char *segp; + char *segp, *tmp; /* At the beginning of each iteration of this loop, "cur" points to * the first character of the segment we want to examine. @@ -731,7 +731,11 @@ xmlNormalizeURIPath(char *path) { cur[0] = '\0'; break; } - strcpy(cur, segp + 3); + /* Valgrind complained, strcpy(cur, segp + 3); */ + /* string will overlap, do not use strcpy */ + tmp = cur; + segp += 3; + while ((*tmp++ = *segp++) != 0); /* If there are no previous segments, then keep going from here. */ segp = cur;