fix for possible (but unlikely) problem with strncpy not adding \0 and then extending...
authorCampbell Barton <ideasman42@gmail.com>
Sat, 12 Feb 2011 09:58:28 +0000 (09:58 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Sat, 12 Feb 2011 09:58:28 +0000 (09:58 +0000)
source/blender/blenkernel/intern/particle_system.c
source/blender/makesrna/intern/rna_fluidsim.c

index 4d3a908edb0c9e7e0d03a4c8d9db4be015bb8195..2e2decdf84d084c9ef80db602907cff813702994 100644 (file)
@@ -3744,8 +3744,6 @@ static void particles_fluid_step(ParticleSimulationData *sim, int UNUSED(cfra))
                        FluidsimSettings *fss= fluidmd->fss;
                        ParticleSettings *part = psys->part;
                        ParticleData *pa=NULL;
-                       const char *suffix  = "fluidsurface_particles_####";
-                       const char *suffix2 = ".gz";
                        char filename[256];
                        char debugStrBuffer[256];
                        int  curFrame = sim->scene->r.cfra -1; // warning - sync with derived mesh fsmesh loading
@@ -3755,14 +3753,13 @@ static void particles_fluid_step(ParticleSimulationData *sim, int UNUSED(cfra))
        
 // XXX                 if(ob==G.obedit) // off...
 //                             return;
-       
+
                        // ok, start loading
-                       strcpy(filename, fss->surfdataPath);
-                       strcat(filename, suffix);
+                       BLI_snprintf(filename, sizeof(filename), "%sfluidsurface_particles_####.gz", fss->surfdataPath);
+                       
                        BLI_path_abs(filename, G.main->name);
                        BLI_path_frame(filename, curFrame, 0); // fixed #frame-no 
-                       strcat(filename, suffix2);
-       
+
                        gzf = gzopen(filename, "rb");
                        if (!gzf) {
                                snprintf(debugStrBuffer,256,"readFsPartData::error - Unable to open file for reading '%s' \n", filename); 
index 81b4b75aa0385228798ac610516ec4d320d9752f..55045a927bc79e71f1a18bccf79afa4d293ce68e 100644 (file)
@@ -85,14 +85,12 @@ static int fluidsim_find_lastframe(FluidsimSettings *fss)
        char targetDir[FILE_MAXFILE+FILE_MAXDIR], targetFile[FILE_MAXFILE+FILE_MAXDIR];
        int curFrame = 1;
 
-       strncpy(targetDir, fss->surfdataPath, FILE_MAXDIR);
-       strcat(targetDir,"fluidsurface_final_####");
+       BLI_snprintf(targetDir, sizeof(targetDir), "%sfluidsurface_final_####.bobj.gz", fss->surfdataPath);
        BLI_path_abs(targetDir, G.main->name);
 
        do {
-               strcpy(targetFile,targetDir);
+               BLI_strncpy(targetFile, targetDir, sizeof(targetFile));
                BLI_path_frame(targetFile, curFrame++, 0);
-               strcat(targetFile, ".bobj.gz");
        } while(BLI_exist(targetFile));
 
        return curFrame - 1;