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