[Bf-committers] Safe string copies and concatenations and path lengths (Related to tracker ID 2096)

Jacques Beaurain jbeaurain at istop.com
Tue Jan 11 13:32:50 CET 2005


Here is my notes from the tracker. Because it does not only concern the 
crash, I am interested in your thoughts on the path issue.

I don't think this is windows related only, it may not crash on other 
platforms but it happens because of buffer overruns due to unsafe 
strcpys in BLI_split_dirfile.

The pathcrash.patch here fixes the problem (I also introduced a safe 
BLI_strncat function at this stage):


I cannot for some reason attach any files to tracker ID's unless I 
created them myself.

One question about path lengths; This patch will not crash blender but 
the non-existing filename will be truncated. The FILE_MAXDIR and 
FILE_MAXDIR are defined as 160 and 80 resp.
They are also defined in three places.

IMO there should really be only one define FILE_MAXPATH that is platform 
dependent. For windows (and possible other platforms) this will be 
defined as:

#define FILE_MAXPATH MAX_PATH // == 260 on Windows

which should replace all occurrences of:


This will result in less of these kind of problems and if combined with 
safe string copies will result in a stabler blender.



More information about the Bf-committers mailing list