[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [29180] trunk/blender/source/blender/ blenlib/intern/path_util.c: fix for buffer overrun with making a path relative.
Campbell Barton
ideasman42 at gmail.com
Thu Jun 3 15:05:45 CEST 2010
Revision: 29180
http://projects.blender.org/plugins/scmsvn/viewcvs.php?view=rev&root=bf-blender&revision=29180
Author: campbellbarton
Date: 2010-06-03 15:05:45 +0200 (Thu, 03 Jun 2010)
Log Message:
-----------
fix for buffer overrun with making a path relative.
would only happen when the names of the path and the relative location matched which isnt likely but happened today when Soenke somehow made a file link to its self.
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 2010-06-03 11:20:46 UTC (rev 29179)
+++ trunk/blender/source/blender/blenlib/intern/path_util.c 2010-06-03 13:05:45 UTC (rev 29180)
@@ -354,8 +354,6 @@
void BLI_path_rel(char *file, const char *relfile)
{
- char * p;
- char * q;
char * lslash;
char temp[FILE_MAXDIR+FILE_MAXFILE];
char res[FILE_MAXDIR+FILE_MAXFILE];
@@ -403,11 +401,18 @@
{
/* find the prefix of the filename that is equal for both filenames.
This is replaced by the two slashes at the beginning */
- p = temp;
- q = file;
- while (*p == *q) {
+ char *p= temp;
+ char *q= file;
+
+ while ((*p == *q)) {
++p; ++q;
+ /* dont search beyond the end of the string
+ * in the rare case they match */
+ if ((*p=='\0') || (*q=='\0')) {
+ break;
+ }
}
+
/* we might have passed the slash when the beginning of a dir matches
so we rewind. Only check on the actual filename
*/
More information about the Bf-blender-cvs
mailing list