diff options
author | Campbell Barton <ideasman42@gmail.com> | 2007-10-21 13:32:18 +0400 |
---|---|---|
committer | Campbell Barton <ideasman42@gmail.com> | 2007-10-21 13:32:18 +0400 |
commit | bacfc9eb91f10871a2ba9c3b35e48c3895dffac3 (patch) | |
tree | 7332eb5683a36a60604f0ad31fbbd762f4c03aba /source/blender/blenlib/intern/storage.c | |
parent | 3a04520686c19074814c7de363f208459c69dfd1 (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/blenlib/intern/storage.c')
-rw-r--r-- | source/blender/blenlib/intern/storage.c | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/source/blender/blenlib/intern/storage.c b/source/blender/blenlib/intern/storage.c index a6b91bf489d..1d46679cbf2 100644 --- a/source/blender/blenlib/intern/storage.c +++ b/source/blender/blenlib/intern/storage.c @@ -180,12 +180,15 @@ double BLI_diskfree(char *dir) return (double) (freec*bytesps*sectorspc); #else struct statfs disk; - char name[100],*slash; - - + char name[FILE_MAXDIR],*slash; + int len = strlen(dir); + + if (len >= FILE_MAXDIR) /* path too long */ + return -1; + strcpy(name,dir); - if(strlen(name)){ + if(len){ slash = strrchr(name,'/'); if (slash) slash[1] = 0; } else strcpy(name,"/"); |