From 3396f73c1719db18500d4741d4fc21d6bba9423c Mon Sep 17 00:00:00 2001 From: Campbell Barton Date: Sat, 12 Feb 2011 09:58:28 +0000 Subject: [PATCH] fix for possible (but unlikely) problem with strncpy not adding \0 and then extending the string with strcat. use BLI_snprintf instead. --- source/blender/blenkernel/intern/particle_system.c | 11 ++++------- source/blender/makesrna/intern/rna_fluidsim.c | 6 ++---- 2 files changed, 6 insertions(+), 11 deletions(-) diff --git a/source/blender/blenkernel/intern/particle_system.c b/source/blender/blenkernel/intern/particle_system.c index 4d3a908edb0..2e2decdf84d 100644 --- a/source/blender/blenkernel/intern/particle_system.c +++ b/source/blender/blenkernel/intern/particle_system.c @@ -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); diff --git a/source/blender/makesrna/intern/rna_fluidsim.c b/source/blender/makesrna/intern/rna_fluidsim.c index 81b4b75aa03..55045a927bc 100644 --- a/source/blender/makesrna/intern/rna_fluidsim.c +++ b/source/blender/makesrna/intern/rna_fluidsim.c @@ -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;