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>2007-10-21 13:32:18 +0400
committerCampbell Barton <ideasman42@gmail.com>2007-10-21 13:32:18 +0400
commitbacfc9eb91f10871a2ba9c3b35e48c3895dffac3 (patch)
tree7332eb5683a36a60604f0ad31fbbd762f4c03aba /source/blender/src/filesel.c
parent3a04520686c19074814c7de363f208459c69dfd1 (diff)
fix for crash's in file selector.
- on unix BLI_diskfree was only using 100 chars for the dir name, and not checking if the name given was longer, increased to FILE_MAXDIR (160) and added a check, return -1 if its too long. The file selector only allowed 80 chars to be typed into the directory entry. Made the file selector check that the path is less then FILE_MIXDIR, if you try and enter a path thats longer it will tell you that the path is too long, before it was writing into other memory and crashing.
Diffstat (limited to 'source/blender/src/filesel.c')
-rw-r--r--source/blender/src/filesel.c22
1 files changed, 15 insertions, 7 deletions
diff --git a/source/blender/src/filesel.c b/source/blender/src/filesel.c
index 1bdca25a88d..d304125ca9a 100644
--- a/source/blender/src/filesel.c
+++ b/source/blender/src/filesel.c
@@ -1039,7 +1039,7 @@ void drawfilespace(ScrArea *sa, void *spacedata)
else loadbutton= 0;
uiBlockBeginAlign(block);
- uiDefBut(block, TEX, B_FS_DIRNAME,"", textrct.xmin + (strp?20:0), filebuty2, textrct.xmax-textrct.xmin-loadbutton - (strp?20:0), 21, sfile->dir, 0.0, (float)FILE_MAXFILE-1, 0, 0, "Directory, enter a directory and press enter to create it"); /* Directory input */
+ uiDefBut(block, TEX, B_FS_DIRNAME,"", textrct.xmin + (strp?20:0), filebuty2, textrct.xmax-textrct.xmin-loadbutton - (strp?20:0), 21, sfile->dir, 0.0, (float)FILE_MAXDIR-1, 0, 0, "Directory, enter a directory and press enter to create it"); /* Directory input */
if(loadbutton) {
uiSetCurFont(block, UI_HELV);
uiDefBut(block, BUT, B_FS_LOAD, sfile->title, textrct.xmax-loadbutton, filebuty2, loadbutton, 21, sfile->dir, 0.0, (float)FILE_MAXFILE-1, 0, 0, "");
@@ -1833,12 +1833,20 @@ void winqreadfilespace(ScrArea *sa, void *spacedata, BWinEvent *evt)
if(act>=0 && act<sfile->totfile) {
if(S_ISDIR(sfile->filelist[act].type)) {
- strcat(sfile->dir, sfile->filelist[act].relname);
- strcat(sfile->dir,"/");
- BLI_cleanup_dir(G.sce, sfile->dir);
- freefilelist(sfile);
- sfile->ofs= 0;
- do_draw= 1;
+ /* the path is too long and we are not going up! */
+ if (strcmp(sfile->filelist[act].relname, ".") &&
+ strcmp(sfile->filelist[act].relname, "..") &&
+ strlen(sfile->dir) + strlen(sfile->filelist[act].relname) >= FILE_MAXDIR )
+ {
+ error("Path too long, cannot enter this directory");
+ } else {
+ strcat(sfile->dir, sfile->filelist[act].relname);
+ strcat(sfile->dir,"/");
+ BLI_cleanup_dir(G.sce, sfile->dir);
+ freefilelist(sfile);
+ sfile->ofs= 0;
+ do_draw= 1;
+ }
}
else {
if( strcmp(sfile->file, sfile->filelist[act].relname)) {