bugfix [#23263] Changing view crashes blender
authorCampbell Barton <ideasman42@gmail.com>
Thu, 12 Aug 2010 03:37:45 +0000 (03:37 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Thu, 12 Aug 2010 03:37:45 +0000 (03:37 +0000)
source/blender/blenlib/intern/path_util.c

index 260f59aa03c7bc6eaee4c107471e32fe2b92d958..cf773d575e52f231ede21d938e6ddee43f972a92 100644 (file)
@@ -586,7 +586,7 @@ int BLI_path_abs(char *path, const char *basepath)
                BLI_strncpy(tmp, path, FILE_MAX);
        }
 #else
-       BLI_strncpy(tmp, path, FILE_MAX);
+       BLI_strncpy(tmp, path, sizeof(tmp));
        
        /* Check for loading a windows path on a posix system
         * in this case, there is no use in trying C:/ since it 
@@ -603,7 +603,7 @@ int BLI_path_abs(char *path, const char *basepath)
        
 #endif
 
-       BLI_strncpy(base, basepath, FILE_MAX);
+       BLI_strncpy(base, basepath, sizeof(base));
        
        BLI_cleanup_file(NULL, base);
        
@@ -626,13 +626,13 @@ int BLI_path_abs(char *path, const char *basepath)
                        BLI_strncpy(path, tmp+2, FILE_MAX);
                        
                        memcpy(tmp, base, baselen);
-                       strcpy(tmp+baselen, path);
-                       strcpy(path, tmp);
+                       BLI_strncpy(tmp+baselen, path, sizeof(tmp)-baselen);
+                       BLI_strncpy(path, tmp, FILE_MAX);
                } else {
-                       strcpy(path, tmp+2);
+                       BLI_strncpy(path, tmp+2, FILE_MAX);
                }
        } else {
-               strcpy(path, tmp);
+               BLI_strncpy(path, tmp, FILE_MAX);
        }
        
        if (path[0]!='\0') {
@@ -1162,7 +1162,7 @@ void BLI_make_existing_file(char *name)
 {
        char di[FILE_MAXDIR+FILE_MAXFILE], fi[FILE_MAXFILE];
 
-       strcpy(di, name);
+       BLI_strncpy(di, name, sizeof(di));
        BLI_splitdirstring(di, fi);
        
        /* test exist */