Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2013-06-28 00:47:59 +0400
committerCampbell Barton <ideasman42@gmail.com>2013-06-28 00:47:59 +0400
commiteba9b4f6c18c1249f353fa752050ced9e9e5f7d1 (patch)
tree6355e092d633758172ee0ff2e5ade52b212e77a3 /source/blender/blenlib/intern/path_util.c
parentd1f4827a40aaf19ad7bcac2c86c9dc4e52dea733 (diff)
fix for out of bounds read in BLI_path_rel
Diffstat (limited to 'source/blender/blenlib/intern/path_util.c')
-rw-r--r--source/blender/blenlib/intern/path_util.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/source/blender/blenlib/intern/path_util.c b/source/blender/blenlib/intern/path_util.c
index fe50c2abcc1..1e76a7f3164 100644
--- a/source/blender/blenlib/intern/path_util.c
+++ b/source/blender/blenlib/intern/path_util.c
@@ -530,6 +530,7 @@ void BLI_path_rel(char *file, const char *relfile)
* This is replaced by the two slashes at the beginning */
char *p = temp;
char *q = file;
+ char *r = res;
#ifdef WIN32
while (tolower(*p) == tolower(*q))
@@ -557,20 +558,23 @@ void BLI_path_rel(char *file, const char *relfile)
while ( (p >= temp) && (*p != '/') ) { --p; --q; }
}
- strcpy(res, "//");
+ r += BLI_strcpy_rlen(r, "//");
/* p now points to the slash that is at the beginning of the part
* where the path is different from the relative path.
* We count the number of directories we need to go up in the
* hierarchy to arrive at the common 'prefix' of the path
*/
+ if (p < temp) p = temp;
while (p && p < lslash) {
- if (*p == '/')
- strcat(res, "../");
+ if (*p == '/') {
+ r += BLI_strcpy_rlen(r, "../");
+ }
p++;
}
- strcat(res, q + 1); /* don't copy the slash at the beginning */
+ /* don't copy the slash at the beginning */
+ r += BLI_strcpy_rlen(r, q + 1);
#ifdef WIN32
BLI_char_switch(res + 2, '/', '\\');