== bugfix ==
fix for [#6950] Blender crashes when .blog file top line is 160 characters or more - made sure BLI_convertstringcode doesn't return more than 240 chars - went through all callers and fixed places where string passed to BLI_convertstringcode was too short - TODO: look into increasing sample->name and sound->name too, I prevented crashes, but filename might get shortened.
This commit is contained in:
@@ -457,7 +457,7 @@ static int bpymenu_CreateFromFile( void )
|
||||
{
|
||||
FILE *fp;
|
||||
char line[255], w1[255], w2[255], tooltip[255], *tip;
|
||||
char upythondir[FILE_MAXDIR];
|
||||
char upythondir[FILE_MAX];
|
||||
char *homedir = NULL;
|
||||
int parsing, version, is_userdir;
|
||||
short group;
|
||||
@@ -494,13 +494,13 @@ static int bpymenu_CreateFromFile( void )
|
||||
w1[0] = '\0';
|
||||
fscanf( fp, "# User defined scripts dir: %[^\n]\n", w1 );
|
||||
|
||||
BLI_strncpy(upythondir, U.pythondir, FILE_MAXDIR);
|
||||
BLI_convertstringcode(upythondir, G.sce, 0);
|
||||
BLI_strncpy(upythondir, U.pythondir, FILE_MAX);
|
||||
BLI_convertstringcode(upythondir, G.sce, 0);
|
||||
|
||||
if( strcmp( w1, upythondir ) != 0 )
|
||||
return -1;
|
||||
if( strcmp( w1, upythondir ) != 0 )
|
||||
return -1;
|
||||
|
||||
w1[0] = '\0';
|
||||
w1[0] = '\0';
|
||||
|
||||
while( fgets( line, 255, fp ) ) { /* parsing file lines */
|
||||
|
||||
@@ -604,9 +604,9 @@ static void bpymenu_WriteDataFile( void )
|
||||
if (U.pythondir[0] != '\0' &&
|
||||
strcmp(U.pythondir, "/") != 0 && strcmp(U.pythondir, "//") != 0)
|
||||
{
|
||||
char upythondir[FILE_MAXDIR];
|
||||
char upythondir[FILE_MAX];
|
||||
|
||||
BLI_strncpy(upythondir, U.pythondir, FILE_MAXDIR);
|
||||
BLI_strncpy(upythondir, U.pythondir, FILE_MAX);
|
||||
BLI_convertstringcode(upythondir, G.sce, 0);
|
||||
fprintf( fp, "# User defined scripts dir: %s\n", upythondir );
|
||||
}
|
||||
@@ -940,7 +940,7 @@ static int bpymenu_GetStatMTime( const char *name, int is_file, time_t * mtime )
|
||||
|
||||
#ifdef WIN32
|
||||
if (is_file) {
|
||||
result = stat( name, &st );
|
||||
result = stat( name, &st );
|
||||
} else {
|
||||
/* needed for win32 only, remove trailing slash */
|
||||
char name_stat[FILE_MAX];
|
||||
@@ -976,8 +976,8 @@ static int bpymenu_GetStatMTime( const char *name, int is_file, time_t * mtime )
|
||||
int BPyMenu_Init( int usedir )
|
||||
{
|
||||
char fname[FILE_MAXDIR];
|
||||
char dirname[FILE_MAXDIR];
|
||||
char upythondir[FILE_MAXDIR];
|
||||
char dirname[FILE_MAX];
|
||||
char upythondir[FILE_MAX];
|
||||
char *upydir = U.pythondir, *sdir = NULL;
|
||||
time_t time_dir1 = 0, time_dir2 = 0, time_file = 0;
|
||||
int stat_dir1 = 0, stat_dir2 = 0, stat_file = 0;
|
||||
@@ -1005,14 +1005,14 @@ int BPyMenu_Init( int usedir )
|
||||
upydir = NULL;
|
||||
}
|
||||
else {
|
||||
BLI_strncpy(upythondir, upydir, FILE_MAXDIR);
|
||||
BLI_strncpy(upythondir, upydir, FILE_MAX);
|
||||
BLI_convertstringcode(upythondir, G.sce, 0);
|
||||
}
|
||||
|
||||
sdir = bpy_gethome(1);
|
||||
|
||||
if (sdir) {
|
||||
BLI_strncpy(dirname, sdir, FILE_MAXDIR);
|
||||
BLI_strncpy(dirname, sdir, FILE_MAX);
|
||||
stat_dir1 = bpymenu_GetStatMTime( dirname, 0, &time_dir1 );
|
||||
|
||||
if( stat_dir1 < 0 ) {
|
||||
@@ -1098,7 +1098,7 @@ the user defined Python scripts dir.\n", dirname );
|
||||
fprintf(stderr, "Default scripts dir does not seem valid.\n\n");
|
||||
}
|
||||
if( stat_dir2 == 0 ) {
|
||||
BLI_strncpy(dirname, U.pythondir, FILE_MAXDIR);
|
||||
BLI_strncpy(dirname, U.pythondir, FILE_MAX);
|
||||
BLI_convertstringcode(dirname, G.sce, 0);
|
||||
i = bpymenu_ParseDir( dirname, NULL, 1 );
|
||||
if (i == -1 && DEBUG)
|
||||
|
||||
Reference in New Issue
Block a user