[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [57837] trunk/blender/source/blender/ blenlib/intern/path_util.c: fix for out of bounds read in BLI_path_rel
Campbell Barton
ideasman42 at gmail.com
Thu Jun 27 22:47:59 CEST 2013
Revision: 57837
http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=57837
Author: campbellbarton
Date: 2013-06-27 20:47:59 +0000 (Thu, 27 Jun 2013)
Log Message:
-----------
fix for out of bounds read in BLI_path_rel
Modified Paths:
--------------
trunk/blender/source/blender/blenlib/intern/path_util.c
Modified: trunk/blender/source/blender/blenlib/intern/path_util.c
===================================================================
--- trunk/blender/source/blender/blenlib/intern/path_util.c 2013-06-27 19:52:50 UTC (rev 57836)
+++ trunk/blender/source/blender/blenlib/intern/path_util.c 2013-06-27 20:47:59 UTC (rev 57837)
@@ -530,6 +530,7 @@
* 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 @@
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, '/', '\\');
More information about the Bf-blender-cvs
mailing list