Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrecht Van Lommel <brechtvanlommel@pandora.be>2011-08-30 14:07:50 +0400
committerBrecht Van Lommel <brechtvanlommel@pandora.be>2011-08-30 14:07:50 +0400
commitb3704f45c4e165618e898b5b7d1a7391ad14dc50 (patch)
treeede24044252d222084cc59cef98e28ebfe8494c3 /source/blender/editors
parent27ec8d5043f544685001aab3552b9b4b56bc1e1a (diff)
Fixes for snprintf usage:
* replace by BLI_snprintf in various places, note _snprintf on windows does not properly null terminate the string. * fix overflow in sequencer proxy code due to buffer being smaller than specified size. * fix some usage of snprintf as strcpy, this is will go wrong if the string contains % characters. * remove BLI_dynstr_printf function in gpu module, use BLI_dynstr_appendf
Diffstat (limited to 'source/blender/editors')
-rw-r--r--source/blender/editors/physics/physics_fluid.c18
-rw-r--r--source/blender/editors/space_console/space_console.c4
-rw-r--r--source/blender/editors/space_nla/nla_draw.c14
3 files changed, 15 insertions, 21 deletions
diff --git a/source/blender/editors/physics/physics_fluid.c b/source/blender/editors/physics/physics_fluid.c
index 37309f1e07c..bd53de20871 100644
--- a/source/blender/editors/physics/physics_fluid.c
+++ b/source/blender/editors/physics/physics_fluid.c
@@ -41,12 +41,6 @@
#include <string.h>
#include <sys/stat.h>
-#ifdef WIN32 /* Windos */
-#ifndef snprintf
-#define snprintf _snprintf
-#endif
-#endif
-
#include "MEM_guardedalloc.h"
/* types */
@@ -155,8 +149,8 @@ static int fluid_is_animated_mesh(FluidsimSettings *fss)
#if 0
/* helper function */
void fluidsimGetGeometryObjFilename(Object *ob, char *dst) { //, char *srcname) {
- //snprintf(dst,FILE_MAXFILE, "%s_cfgdata_%s.bobj.gz", srcname, ob->id.name);
- snprintf(dst,FILE_MAXFILE, "fluidcfgdata_%s.bobj.gz", ob->id.name);
+ //BLI_snprintf(dst,FILE_MAXFILE, "%s_cfgdata_%s.bobj.gz", srcname, ob->id.name);
+ BLI_snprintf(dst,FILE_MAXFILE, "fluidcfgdata_%s.bobj.gz", ob->id.name);
}
#endif
@@ -888,7 +882,7 @@ static int fluidsimBake(bContext *C, ReportList *reports, Object *fsDomain)
if(getenv(strEnvName)) {
int dlevel = atoi(getenv(strEnvName));
elbeemSetDebugLevel(dlevel);
- snprintf(debugStrBuffer,256,"fluidsimBake::msg: Debug messages activated due to envvar '%s'\n",strEnvName);
+ BLI_snprintf(debugStrBuffer,256,"fluidsimBake::msg: Debug messages activated due to envvar '%s'\n",strEnvName);
elbeemDebugOut(debugStrBuffer);
}
@@ -925,7 +919,7 @@ static int fluidsimBake(bContext *C, ReportList *reports, Object *fsDomain)
/* rough check of settings... */
if(domainSettings->previewresxyz > domainSettings->resolutionxyz) {
- snprintf(debugStrBuffer,256,"fluidsimBake::warning - Preview (%d) >= Resolution (%d)... setting equal.\n", domainSettings->previewresxyz , domainSettings->resolutionxyz);
+ BLI_snprintf(debugStrBuffer,256,"fluidsimBake::warning - Preview (%d) >= Resolution (%d)... setting equal.\n", domainSettings->previewresxyz , domainSettings->resolutionxyz);
elbeemDebugOut(debugStrBuffer);
domainSettings->previewresxyz = domainSettings->resolutionxyz;
}
@@ -945,7 +939,7 @@ static int fluidsimBake(bContext *C, ReportList *reports, Object *fsDomain)
} else {
gridlevels = domainSettings->maxRefine;
}
- snprintf(debugStrBuffer,256,"fluidsimBake::msg: Baking %s, refine: %d\n", fsDomain->id.name , gridlevels );
+ BLI_snprintf(debugStrBuffer,256,"fluidsimBake::msg: Baking %s, refine: %d\n", fsDomain->id.name , gridlevels );
elbeemDebugOut(debugStrBuffer);
@@ -997,7 +991,7 @@ static int fluidsimBake(bContext *C, ReportList *reports, Object *fsDomain)
/* ******** init domain object's matrix ******** */
copy_m4_m4(domainMat, fsDomain->obmat);
if(!invert_m4_m4(invDomMat, domainMat)) {
- snprintf(debugStrBuffer,256,"fluidsimBake::error - Invalid obj matrix?\n");
+ BLI_snprintf(debugStrBuffer,256,"fluidsimBake::error - Invalid obj matrix?\n");
elbeemDebugOut(debugStrBuffer);
BKE_report(reports, RPT_ERROR, "Invalid object matrix.");
diff --git a/source/blender/editors/space_console/space_console.c b/source/blender/editors/space_console/space_console.c
index 52c5100900d..c8fa049f5eb 100644
--- a/source/blender/editors/space_console/space_console.c
+++ b/source/blender/editors/space_console/space_console.c
@@ -169,7 +169,7 @@ static void id_drop_copy(wmDrag *drag, wmDropBox *drop)
BLI_strescape(id_esc, id->name+2, sizeof(id_esc));
- snprintf(text, sizeof(text), "bpy.data.%s[\"%s\"]", BKE_idcode_to_name_plural(GS(id->name)), id_esc);
+ BLI_snprintf(text, sizeof(text), "bpy.data.%s[\"%s\"]", BKE_idcode_to_name_plural(GS(id->name)), id_esc);
/* copy drag path to properties */
RNA_string_set(drop->ptr, "text", text);
@@ -186,7 +186,7 @@ static int path_drop_poll(bContext *UNUSED(C), wmDrag *drag, wmEvent *UNUSED(eve
static void path_drop_copy(wmDrag *drag, wmDropBox *drop)
{
char pathname[FILE_MAXDIR+FILE_MAXFILE+2];
- snprintf(pathname, sizeof(pathname), "\"%s\"", drag->path);
+ BLI_snprintf(pathname, sizeof(pathname), "\"%s\"", drag->path);
RNA_string_set(drop->ptr, "text", pathname);
}
diff --git a/source/blender/editors/space_nla/nla_draw.c b/source/blender/editors/space_nla/nla_draw.c
index 0583f328371..0c9c7877ddc 100644
--- a/source/blender/editors/space_nla/nla_draw.c
+++ b/source/blender/editors/space_nla/nla_draw.c
@@ -468,10 +468,10 @@ static void nla_draw_strip_text (AnimData *adt, NlaTrack *nlt, NlaStrip *strip,
/* just print the name and the range */
if (strip->flag & NLASTRIP_FLAG_TEMP_META) {
- sprintf(str, "%d) Temp-Meta", index);
+ BLI_snprintf(str, sizeof(str), "%d) Temp-Meta", index);
}
else {
- sprintf(str, strip->name);
+ BLI_strncpy(str, strip->name, sizeof(str));
}
/* set text color - if colors (see above) are light, draw black text, otherwise draw white */
@@ -514,7 +514,7 @@ static void nla_draw_strip_frames_text(NlaTrack *UNUSED(nlt), NlaStrip *strip, V
{
const float ytol = 1.0f; /* small offset to vertical positioning of text, for legibility */
const char col[4] = {220, 220, 220, 255}; /* light grey */
- char str[16] = "";
+ char str[32] = "";
/* Always draw times above the strip, whereas sequencer drew below + above.
@@ -524,11 +524,11 @@ static void nla_draw_strip_frames_text(NlaTrack *UNUSED(nlt), NlaStrip *strip, V
* while also preserving some accuracy, since we do use floats
*/
/* start frame */
- sprintf(str, "%.1f", strip->start);
+ BLI_snprintf(str, sizeof(str), "%.1f", strip->start);
UI_view2d_text_cache_add(v2d, strip->start-1.0f, ymaxc+ytol, str, col);
/* end frame */
- sprintf(str, "%.1f", strip->end);
+ BLI_snprintf(str, sizeof(str), "%.1f", strip->end);
UI_view2d_text_cache_add(v2d, strip->end, ymaxc+ytol, str, col);
}
@@ -730,9 +730,9 @@ static void draw_nla_channel_list_gl (bAnimContext *ac, ListBase *anim_data, Vie
special = ICON_ACTION;
if (act)
- sprintf(name, "%s", act->id.name+2);
+ BLI_snprintf(name, sizeof(name), "%s", act->id.name+2);
else
- sprintf(name, "<No Action>");
+ BLI_strncpy(name, "<No Action>", sizeof(name));
// draw manually still
doDraw= 1;