1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
|
From: Ben Spencer <Ben Spencer>
Date: Sat, 15 Feb 2014 22:47:00 +0000
Subject: Use memmove on overlapping strings
strcpy is not guaranteed to work on overlapping strings, and this can lead
to broken paths appearing in tag files. Use memmove instead.
Origin: other, http://sourceforge.net/tracker/?func=detail&aid=3034816&group_id=6556&atid=306556
Forwarded: yes
Last-Update: 2011-02-17
---
routines.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/routines.c b/routines.c
index 83bcdcc..8ebe2e0 100644
--- a/routines.c
+++ b/routines.c
@@ -757,13 +757,13 @@ extern char* absoluteFilename (const char *file)
else if (cp [0] != PATH_SEPARATOR)
cp = slashp;
#endif
- strcpy (cp, slashp + 3);
+ memmove (cp, slashp + 3, strlen(slashp + 3) + 1);
slashp = cp;
continue;
}
else if (slashp [2] == PATH_SEPARATOR || slashp [2] == '\0')
{
- strcpy (slashp, slashp + 2);
+ memmove (slashp, slashp + 2, strlen(slashp + 2) + 1);
continue;
}
}
|