fix for buffer overrun with BLI_split_dirfile(...), was simple to do since many places don't check for filename lengyj of 79 chars which is the limit for the file selector.

Add max dir and file length args.
This commit is contained in:
2011-10-15 03:56:05 +00:00
parent f9c41eaaf8
commit 317b649bb2
15 changed files with 34 additions and 48 deletions

View File

@@ -502,7 +502,7 @@ static PyObject* gPyGetBlendFileList(PyObject*, PyObject* args)
BLI_path_abs(cpath, gp_GamePythonPath);
} else {
/* Get the dir only */
BLI_split_dirfile(gp_GamePythonPath, cpath, NULL);
BLI_split_dirfile(gp_GamePythonPath, cpath, NULL, sizeof(cpath), 0);
}
if((dp = opendir(cpath)) == NULL) {
@@ -1732,7 +1732,7 @@ static void initPySysObjects__append(PyObject *sys_path, char *filename)
PyObject *item;
char expanded[FILE_MAXDIR + FILE_MAXFILE];
BLI_split_dirfile(filename, expanded, NULL); /* get the dir part of filename only */
BLI_split_dirfile(filename, expanded, NULL, sizeof(expanded), 0); /* get the dir part of filename only */
BLI_path_abs(expanded, gp_GamePythonPath); /* filename from lib->filename is (always?) absolute, so this may not be needed but it wont hurt */
BLI_cleanup_file(gp_GamePythonPath, expanded); /* Dont use BLI_cleanup_dir because it adds a slash - BREAKS WIN32 ONLY */
item= PyUnicode_DecodeFSDefault(expanded);