use BLI_strncpy and BLI_snprintf when the size of the string is known.
authorCampbell Barton <ideasman42@gmail.com>
Wed, 11 Jan 2012 12:33:51 +0000 (12:33 +0000)
committerCampbell Barton <ideasman42@gmail.com>
Wed, 11 Jan 2012 12:33:51 +0000 (12:33 +0000)
fix for sequencer unique naming which was missed with string length update.

52 files changed:
source/blender/blenfont/BLF_api.h
source/blender/blenkernel/intern/boids.c
source/blender/blenkernel/intern/deform.c
source/blender/blenkernel/intern/dynamicpaint.c
source/blender/blenkernel/intern/image.c
source/blender/blenkernel/intern/ipo.c
source/blender/blenkernel/intern/material.c
source/blender/blenkernel/intern/packedFile.c
source/blender/blenkernel/intern/particle.c
source/blender/blenkernel/intern/pointcache.c
source/blender/blenkernel/intern/property.c
source/blender/blenkernel/intern/seqeffects.c
source/blender/blenkernel/intern/sequencer.c
source/blender/blenkernel/intern/texture.c
source/blender/blenkernel/intern/tracking.c
source/blender/blenkernel/intern/writeffmpeg.c
source/blender/blenlib/intern/path_util.c
source/blender/blenlib/intern/storage.c
source/blender/blenloader/intern/readfile.c
source/blender/editors/animation/anim_ipo_utils.c
source/blender/editors/armature/editarmature_retarget.c
source/blender/editors/armature/meshlaplacian.c
source/blender/editors/armature/poseSlide.c
source/blender/editors/armature/poselib.c
source/blender/editors/armature/reeb.c
source/blender/editors/curve/editcurve.c
source/blender/editors/gpencil/gpencil_buttons.c
source/blender/editors/interface/interface_style.c
source/blender/editors/interface/interface_templates.c
source/blender/editors/interface/view2d.c
source/blender/editors/physics/physics_fluid.c
source/blender/editors/screen/area.c
source/blender/editors/space_file/file_draw.c
source/blender/editors/space_file/filelist.c
source/blender/editors/space_graph/graph_buttons.c
source/blender/editors/space_image/image_buttons.c
source/blender/editors/space_image/image_draw.c
source/blender/editors/space_info/info_ops.c
source/blender/editors/space_logic/logic_window.c
source/blender/editors/space_nla/nla_draw.c
source/blender/editors/space_outliner/outliner_edit.c
source/blender/editors/space_text/text_draw.c
source/blender/editors/space_view3d/drawobject.c
source/blender/editors/space_view3d/view3d_draw.c
source/blender/editors/transform/transform_constraints.c
source/blender/editors/util/ed_util.c
source/blender/editors/util/numinput.c
source/blender/editors/uvedit/uvedit_unwrap_ops.c
source/blender/gpu/intern/gpu_material.c
source/blender/imbuf/intern/anim_movie.c
source/blender/nodes/composite/node_composite_tree.c
source/blender/windowmanager/intern/wm_operators.c

index 7490502c605190147f806edda8c8cecfba716819..a045f47cb40293717d15c478173f91fd1a874252 100644 (file)
@@ -198,6 +198,8 @@ void BLF_dir_free(char **dirs, int count);
 #define BLF_MATRIX (1<<4)
 #define BLF_ASPECT (1<<5)
 
+#define BLF_DRAW_STR_DUMMY_MAX 1024
+
 // XXX, bad design
 extern int blf_mono_font;
 extern int blf_mono_font_render; // dont mess drawing with render threads.
index ec2e6b3c0782b7bc8f557ca8e334f1f034cd5df6..d454bef3184268cbc1993e10628b824697061262 100644 (file)
@@ -1503,7 +1503,7 @@ BoidState *boid_new_state(BoidSettings *boids)
 
        state->id = boids->last_state_id++;
        if(state->id)
-               sprintf(state->name, "State %i", state->id);
+               BLI_snprintf(state->name, sizeof(state->name), "State %i", state->id);
        else
                strcpy(state->name, "State");
 
index 6fb4164d6c6efd87383e1c467ecffb0ab360560e..3f3e3b80042a14ec93e1b387306b58796ab71489 100644 (file)
@@ -476,22 +476,22 @@ void flip_side_name(char name[MAX_VGROUP_NAME], const char from_name[MAX_VGROUP_
                switch(name[0]) {
                        case 'l':
                                strcpy(replace, "r");
-                               strcpy(suffix, name+1);
+                               BLI_strncpy(suffix, name+1, sizeof(suffix));
                                prefix[0]= 0;
                                break;
                        case 'r':
                                strcpy(replace, "l");
-                               strcpy(suffix, name+1);
+                               BLI_strncpy(suffix, name+1, sizeof(suffix));
                                prefix[0]= 0;
                                break;
                        case 'L':
                                strcpy(replace, "R");
-                               strcpy(suffix, name+1);
+                               BLI_strncpy(suffix, name+1, sizeof(suffix));
                                prefix[0]= 0;
                                break;
                        case 'R':
                                strcpy(replace, "L");
-                               strcpy(suffix, name+1);
+                               BLI_strncpy(suffix, name+1, sizeof(suffix));
                                prefix[0]= 0;
                                break;
                }
@@ -501,29 +501,29 @@ void flip_side_name(char name[MAX_VGROUP_NAME], const char from_name[MAX_VGROUP_
                index = BLI_strcasestr(prefix, "right");
                if (index==prefix || index==prefix+len-5) {
                        if (index[0]=='r')
-                               strcpy (replace, "left");
+                               strcpy(replace, "left");
                        else {
                                if (index[1]=='I')
-                                       strcpy (replace, "LEFT");
+                                       strcpy(replace, "LEFT");
                                else
-                                       strcpy (replace, "Left");
+                                       strcpy(replace, "Left");
                        }
                        *index= 0;
-                       strcpy (suffix, index+5);
+                       BLI_strncpy(suffix, index+5, sizeof(suffix));
                }
                else {
                        index = BLI_strcasestr(prefix, "left");
                        if (index==prefix || index==prefix+len-4) {
                                if (index[0]=='l')
-                                       strcpy (replace, "right");
+                                       strcpy(replace, "right");
                                else {
                                        if (index[1]=='E')
-                                               strcpy (replace, "RIGHT");
+                                               strcpy(replace, "RIGHT");
                                        else
-                                               strcpy (replace, "Right");
+                                               strcpy(replace, "Right");
                                }
                                *index= 0;
-                               strcpy (suffix, index+4);
+                               BLI_strncpy(suffix, index + 4, sizeof(suffix));
                        }
                }
        }
index fb114aa54c65d45b7aa8d18f53a256f0128fc067..89d1534dbf1a6f3904025195c709c74485f850ac 100644 (file)
@@ -361,8 +361,8 @@ void dynamicPaintSurface_updateType(struct DynamicPaintSurface *surface)
                surface->depth_clamp = 1.0f;
        }
        else {
-               sprintf(surface->output_name, "dp_");
-               strcpy(surface->output_name2,surface->output_name);
+               strcpy(surface->output_name, "dp_");
+               strcpy(surface->output_name2, surface->output_name);
                surface->flags &= ~MOD_DPAINT_ANTIALIAS;
                surface->depth_clamp = 0.0f;
        }
index 6ee2da9f7dc90823717e5721e542ffe70a720e70..5b3b9b4e1c4fadce922c899c38386eab2d159abb 100644 (file)
@@ -1168,7 +1168,7 @@ static void stampdata(Scene *scene, Object *camera, StampData *stamp_data, int d
                char *name = scene_find_last_marker_name(scene, CFRA);
 
                if (name)       BLI_strncpy(text, name, sizeof(text));
-               else            strcpy(text, "<none>");
+               else            BLI_strncpy(text, "<none>", sizeof(text));
 
                BLI_snprintf(stamp_data->marker, sizeof(stamp_data->marker), do_prefix ? "Marker %s":"%s", text);
        } else {
@@ -1224,7 +1224,7 @@ static void stampdata(Scene *scene, Object *camera, StampData *stamp_data, int d
                if (camera && camera->type == OB_CAMERA) {
                        BLI_snprintf(text, sizeof(text), "%.2f", ((Camera *)camera->data)->lens);
                }
-               else            strcpy(text, "<none>");
+               else            BLI_strncpy(text, "<none>", sizeof(text));
 
                BLI_snprintf(stamp_data->cameralens, sizeof(stamp_data->cameralens), do_prefix ? "Lens %s":"%s", text);
        } else {
@@ -1241,7 +1241,7 @@ static void stampdata(Scene *scene, Object *camera, StampData *stamp_data, int d
                Sequence *seq= seq_foreground_frame_get(scene, scene->r.cfra);
        
                if (seq)        BLI_strncpy(text, seq->name+2, sizeof(text));
-               else            strcpy(text, "<none>");
+               else            BLI_strncpy(text, "<none>", sizeof(text));
 
                BLI_snprintf(stamp_data->strip, sizeof(stamp_data->strip), do_prefix ? "Strip %s":"%s", text);
        } else {
index 9890a2629fc6d60fa1ad49470dc6b546bc1b2102..40fe36268488a772fadde42751a17086f1190b61 100644 (file)
@@ -328,9 +328,9 @@ static char *shapekey_adrcodes_to_paths (int adrcode, int *UNUSED(array_index))
        /* block will be attached to ID_KE block, and setting that we alter is the 'value' (which sets keyblock.curval) */
        // XXX adrcode 0 was dummy 'speed' curve 
        if (adrcode == 0) 
-               sprintf(buf, "speed");
+               strcpy(buf, "speed");
        else
-               sprintf(buf, "key_blocks[%d].value", adrcode);
+               BLI_snprintf(buf, sizeof(buf), "key_blocks[%d].value", adrcode);
        return buf;
 }
 
@@ -915,7 +915,7 @@ static char *get_rna_access (int blocktype, int adrcode, char actname[], char co
        /* note, strings are not escapted and they should be! */
        if ((actname && actname[0]) && (constname && constname[0])) {
                /* Constraint in Pose-Channel */
-               sprintf(buf, "pose.bones[\"%s\"].constraints[\"%s\"]", actname, constname);
+               BLI_snprintf(buf, sizeof(buf), "pose.bones[\"%s\"].constraints[\"%s\"]", actname, constname);
        }
        else if (actname && actname[0]) {
                if ((blocktype == ID_OB) && strcmp(actname, "Object")==0) {
@@ -928,16 +928,16 @@ static char *get_rna_access (int blocktype, int adrcode, char actname[], char co
                }
                else {
                        /* Pose-Channel */
-                       sprintf(buf, "pose.bones[\"%s\"]", actname);
+                       BLI_snprintf(buf, sizeof(buf), "pose.bones[\"%s\"]", actname);
                }
        }
        else if (constname && constname[0]) {
                /* Constraint in Object */
-               sprintf(buf, "constraints[\"%s\"]", constname);
+               BLI_snprintf(buf, sizeof(buf), "constraints[\"%s\"]", constname);
        }
        else if (seq) {
                /* Sequence names in Scene */
-               sprintf(buf, "sequence_editor.sequences_all[\"%s\"]", seq->name+2);
+               BLI_snprintf(buf, sizeof(buf), "sequence_editor.sequences_all[\"%s\"]", seq->name+2);
        }
        else {
                buf[0]= '\0'; /* empty string */
@@ -954,7 +954,7 @@ static char *get_rna_access (int blocktype, int adrcode, char actname[], char co
        
        /* if there was no array index pointer provided, add it to the path */
        if (array_index == NULL) {
-               sprintf(buf, "[\"%d\"]", dummy_index);
+               BLI_snprintf(buf, sizeof(buf), "[\"%d\"]", dummy_index);
                BLI_dynstr_append(path, buf);
        }
        
index 4fda85a3247c60f45e20eeee6708f08158e4cd0d..f685d0ec1515ff6c373c0aec523c6b97b084d79c 100644 (file)
@@ -51,6 +51,7 @@
 #include "BLI_listbase.h"              
 #include "BLI_utildefines.h"
 #include "BLI_bpath.h"
+#include "BLI_string.h"
 
 #include "BKE_animsys.h"
 #include "BKE_displist.h"
@@ -1614,7 +1615,7 @@ static void calculate_tface_materialname(char *matname, char *newname, int flag)
        int digits = integer_getdigits(flag);
        /* clamp the old name, remove the MA prefix and add the .TF.flag suffix
        e.g. matname = "MALoooooooooooooongName"; newname = "Loooooooooooooon.TF.2" */
-       sprintf(newname, "%.*s.TF.%0*d", MAX_ID_NAME-(digits+5), matname, digits, flag);
+       BLI_snprintf(newname, MAX_ID_NAME, "%.*s.TF.%0*d", MAX_ID_NAME-(digits+5), matname, digits, flag);
 }
 
 /* returns -1 if no match */
@@ -1661,8 +1662,8 @@ static short convert_tfacenomaterial(Main *main, Mesh *me, MTFace *tf, int flag)
        short mat_nr= -1;
        
        /* new material, the name uses the flag*/
-       sprintf(idname, "MAMaterial.TF.%0*d", integer_getdigits(flag), flag);
-       
+       BLI_snprintf(idname, sizeof(idname), "MAMaterial.TF.%0*d", integer_getdigits(flag), flag);
+
        if ((ma= BLI_findstring(&main->mat, idname+2, offsetof(ID, name)+2))) {
                mat_nr= mesh_getmaterialnumber(me, ma);
                /* assign the material to the mesh */
index 7be8aefc883a2600ed25d8254b8104bbbc026006..2decc40da8110f8297ab98e7d53d529cb6e4aec0 100644 (file)
@@ -251,7 +251,7 @@ static char *find_new_name(char *name)
        
        if (fop_exists(name)) {
                for (number = 1; number <= 999; number++) {
-                       sprintf(tempname, "%s.%03d", name, number);
+                       BLI_snprintf(tempname, sizeof(tempname), "%s.%03d", name, number);
                        if (! fop_exists(tempname)) {
                                break;
                        }
index ce50c58a6e100229423340ab145ef6552a7d2c86..3a4ae5797a0b58671ec025ec119288236ea40d3a 100644 (file)
@@ -3409,14 +3409,14 @@ ModifierData *object_add_particle_system(Scene *scene, Object *ob, const char *n
        psys->part = psys_new_settings("ParticleSettings", NULL);
 
        if(BLI_countlist(&ob->particlesystem)>1)
-               sprintf(psys->name, "ParticleSystem %i", BLI_countlist(&ob->particlesystem));
+               BLI_snprintf(psys->name, sizeof(psys->name), "ParticleSystem %i", BLI_countlist(&ob->particlesystem));
        else
                strcpy(psys->name, "ParticleSystem");
 
        md= modifier_new(eModifierType_ParticleSystem);
 
        if(name)        BLI_strncpy(md->name, name, sizeof(md->name));
-       else            sprintf(md->name, "ParticleSystem %i", BLI_countlist(&ob->particlesystem));
+       else            BLI_snprintf(md->name, sizeof(md->name), "ParticleSystem %i", BLI_countlist(&ob->particlesystem));
        modifier_unique_name(&ob->modifiers, md);
 
        psmd= (ParticleSystemModifierData*) md;
index 411e77de858ee94f1da18750521263cde20a6978..6fd89db10e73f6589eca29c664985b11bfac16c9 100644 (file)
@@ -3096,7 +3096,7 @@ void BKE_ptcache_disk_cache_rename(PTCacheID *pid, const char *name_src, const c
        }
        closedir(dir);
 
-       strcpy(pid->cache->name, old_name);
+       BLI_strncpy(pid->cache->name, old_name, sizeof(pid->cache->name));
 }
 
 void BKE_ptcache_load_external(PTCacheID *pid)
@@ -3217,11 +3217,11 @@ void BKE_ptcache_update_info(PTCacheID *pid)
 
                /* smoke doesn't use frame 0 as info frame so can't check based on totpoint */
                if(pid->type == PTCACHE_TYPE_SMOKE_DOMAIN && totframes)
-                       sprintf(cache->info, "%i frames found!", totframes);
+                       BLI_snprintf(cache->info, sizeof(cache->info), "%i frames found!", totframes);
                else if(totframes && cache->totpoint)
-                       sprintf(cache->info, "%i points found!", cache->totpoint);
+                       BLI_snprintf(cache->info, sizeof(cache->info), "%i points found!", cache->totpoint);
                else
-                       sprintf(cache->info, "No valid data to read!");
+                       BLI_snprintf(cache->info, sizeof(cache->info), "No valid data to read!");
                return;
        }
 
@@ -3231,9 +3231,9 @@ void BKE_ptcache_update_info(PTCacheID *pid)
                        int totpoint = pid->totpoint(pid->calldata, 0);
 
                        if(cache->totpoint > totpoint)
-                               sprintf(mem_info, "%i cells + High Resolution cached", totpoint);
+                               BLI_snprintf(mem_info, sizeof(mem_info), "%i cells + High Resolution cached", totpoint);
                        else
-                               sprintf(mem_info, "%i cells cached", totpoint);
+                               BLI_snprintf(mem_info, sizeof(mem_info), "%i cells cached", totpoint);
                }
                else {
                        int cfra = cache->startframe;
@@ -3243,7 +3243,7 @@ void BKE_ptcache_update_info(PTCacheID *pid)
                                        totframes++;
                        }
 
-                       sprintf(mem_info, "%i frames on disk", totframes);
+                       BLI_snprintf(mem_info, sizeof(mem_info), "%i frames on disk", totframes);
                }
        }
        else {
@@ -3267,20 +3267,21 @@ void BKE_ptcache_update_info(PTCacheID *pid)
 
                mb = (bytes > 1024.0f * 1024.0f);
 
-               sprintf(mem_info, "%i frames in memory (%.1f %s)",
+               BLI_snprintf(mem_info, sizeof(mem_info), "%i frames in memory (%.1f %s)",
                        totframes,
                        bytes / (mb ? 1024.0f * 1024.0f : 1024.0f),
                        mb ? "Mb" : "kb");
        }
 
        if(cache->flag & PTCACHE_OUTDATED) {
-               sprintf(cache->info, "%s, cache is outdated!", mem_info);
+               BLI_snprintf(cache->info, sizeof(cache->info), "%s, cache is outdated!", mem_info);
        }
        else if(cache->flag & PTCACHE_FRAMES_SKIPPED) {
-               sprintf(cache->info, "%s, not exact since frame %i.", mem_info, cache->last_exact);
+               BLI_snprintf(cache->info, sizeof(cache->info), "%s, not exact since frame %i.", mem_info, cache->last_exact);
+       }
+       else {
+               BLI_snprintf(cache->info, sizeof(cache->info), "%s.", mem_info);
        }
-       else
-               sprintf(cache->info, "%s.", mem_info);
 }
 
 void BKE_ptcache_validate(PointCache *cache, int framenr)
index d6c4b5f3a2e27e09b4e58ff0a6d0e2dce2305ef5..5668907b0941abbdc03deb17e16c5872a24d2e1a 100644 (file)
@@ -171,7 +171,7 @@ void unique_property(bProperty *first, bProperty *prop, int force)
                        i= 0;
 
                        do { /* ensure we have enough chars for the new number in the name */
-                               sprintf(num, "%d", i++);
+                               BLI_snprintf(num, sizeof(num), "%d", i++);
                                BLI_strncpy(new_name, base_name, sizeof(prop->name) - strlen(num));
                                strcat(new_name, num);
                        } while(get_property__internal(first, prop, new_name));
index b13e451b689db046e2e886510b78f8db0c26efe3..a8f89b0a1eb176453178028eea78b25df2bd9bd1 100644 (file)
@@ -306,7 +306,7 @@ static struct ImBuf * do_plugin_effect(
                /* XXX: it's crappy to limit copying buffer by it's lemgth,
                 *      but assuming plugin stuff is using correct buffer size
                 *      it should be fine */
-               if(cp) strncpy(cp, seq->name+2, sizeof(seq->name));
+               if(cp) strncpy(cp, seq->name+2, sizeof(seq->name)-2);
 
                if (seq->plugin->current_private_data) {
                        *seq->plugin->current_private_data 
index fe99c76575d3ffbc2a7f52687bb8020fd1526381..71377799651b2c8b483c99e3e001cb3b36ca73db 100644 (file)
@@ -850,7 +850,8 @@ static void seqbase_unique_name(ListBase *seqbasep, SeqUniqueInfo *sui)
        Sequence *seq;
        for(seq=seqbasep->first; seq; seq= seq->next) {
                if (sui->seq != seq && strcmp(sui->name_dest, seq->name+2)==0) {
-                       sprintf(sui->name_dest, "%.17s.%03d",  sui->name_src, sui->count++); /*24 - 2 for prefix, -1 for \0 */
+                       /* SEQ_NAME_MAXSTR - 2 for prefix, -1 for \0, -4 for the number */
+                       BLI_snprintf(sui->name_dest, sizeof(sui->name_dest), "%.59s.%03d",  sui->name_src, sui->count++);
                        sui->match= 1; /* be sure to re-scan */
                }
        }
index 7051376a1f41ef0c78f53a3416f8eacc39d94cbf..88858c9ff518136e6afb38f39b11931344d508b9 100644 (file)
@@ -168,7 +168,7 @@ PluginTex *add_plugin_tex(char *str)
        
        pit= MEM_callocN(sizeof(PluginTex), "plugintex");
        
-       strcpy(pit->name, str);
+       BLI_strncpy(pit->name, str, sizeof(pit->name));
        open_plugin_tex(pit);
        
        if(pit->doit==NULL) {
index 1957f20c8bf02708b21786ee0a1ccce6929845d9..2f9689bfe0e0181236d6b2b77f10f877ab7dbfa4 100644 (file)
@@ -669,7 +669,7 @@ static TracksMap *tracks_map_new(const char *object_name, int is_camera, int num
 {
        TracksMap *map= MEM_callocN(sizeof(TracksMap), "TrackingsMap");
 
-       strcpy(map->object_name, object_name);
+       BLI_strncpy(map->object_name, object_name, sizeof(map->object_name));
        map->is_camera= is_camera;
 
        map->num_tracks= num_tracks;
@@ -1784,7 +1784,7 @@ MovieReconstructContext* BKE_tracking_reconstruction_context_new(MovieTracking *
        int sfra= INT_MAX, efra= INT_MIN;
        MovieTrackingTrack *track;
 
-       strcpy(context->object_name, object->name);
+       BLI_strncpy(context->object_name, object->name, sizeof(context->object_name));
        context->is_camera = object->flag&TRACKING_OBJECT_CAMERA;
 
        context->tracks_map= tracks_map_new(context->object_name, context->is_camera, num_tracks, 0);
index bf547584b9e9360c2cf4b71ff66ee30a967e8ed8..bcdd93ed70be1bd8093a3a154eeec2c4c5882228 100644 (file)
@@ -1077,9 +1077,9 @@ IDProperty *ffmpeg_property_add(RenderData *rd, const char *type, int opt_index,
        }
 
        if (parent_index) {
-               sprintf(name, "%s:%s", parent->name, o->name);
+               BLI_snprintf(name, sizeof(name), "%s:%s", parent->name, o->name);
        } else {
-               strcpy(name, o->name);
+               BLI_strncpy(name, o->name, sizeof(name));
        }
 
        fprintf(stderr, "ffmpeg_property_add: %s %d %d %s\n",
index 9adb39f09efdd4a447b9b6d6a2565639d6914409..6d63105149664b0350c3d24ecb1a8f45243c3119 100644 (file)
@@ -627,8 +627,10 @@ int BLI_path_frame_range(char *path, int sta, int end, int digits)
 
        if (stringframe_chars(path, &ch_sta, &ch_end)) { /* warning, ch_end is the last # +1 */
                char tmp[FILE_MAX];
-               sprintf(tmp, "%.*s%.*d-%.*d%s", ch_sta, path, ch_end-ch_sta, sta, ch_end-ch_sta, end, path+ch_end);
-               strcpy(path, tmp);
+               BLI_snprintf(tmp, sizeof(tmp),
+                            "%.*s%.*d-%.*d%s",
+                            ch_sta, path, ch_end-ch_sta, sta, ch_end-ch_sta, end, path+ch_end);
+               BLI_strncpy(path, tmp, FILE_MAX);
                return 1;
        }
        return 0;
index c5b6f46b3bc4dddfeecc07f415aac755612bc274..df0634e4fcff59076935b622bc86a7735442fffa 100644 (file)
@@ -203,7 +203,7 @@ static void bli_builddir(const char *dirname, const char *relname)
        char buf[256];
        DIR *dir;
 
-       strcpy(buf,relname);
+       BLI_strncpy(buf, relname, sizeof(buf));
        rellen=strlen(relname);
 
        if (rellen){
@@ -220,7 +220,7 @@ static void bli_builddir(const char *dirname, const char *relname)
                while ((fname = (struct dirent*) readdir(dir)) != NULL) {
                        dlink = (struct dirlink *)malloc(sizeof(struct dirlink));
                        if (dlink){
-                               strcpy(buf+rellen,fname->d_name);
+                               BLI_strncpy(buf + rellen ,fname->d_name, sizeof(buf) - rellen);
                                dlink->name = BLI_strdup(buf);
                                BLI_addhead(dirbase,dlink);
                                newnum++;
@@ -343,8 +343,8 @@ static void bli_adddirstrings(void)
                tm= localtime(&file->s.st_mtime);
                // prevent impossible dates in windows
                if(tm==NULL) tm= localtime(&zero);
-               strftime(file->time, 8, "%H:%M", tm);
-               strftime(file->date, 16, "%d-%b-%y", tm);
+               strftime(file->time, sizeof(file->time), "%H:%M", tm);
+               strftime(file->date, sizeof(file->date), "%d-%b-%y", tm);
 
                /*
                 * Seems st_size is signed 32-bit value in *nix and Windows.  This
@@ -354,38 +354,43 @@ static void bli_adddirstrings(void)
                st_size= file->s.st_size;
 
                if (st_size > 1024*1024*1024) {
-                       sprintf(file->size, "%.2f GB", ((double)st_size)/(1024*1024*1024));     
+                       BLI_snprintf(file->size, sizeof(file->size), "%.2f GB", ((double)st_size)/(1024*1024*1024));
                }
                else if (st_size > 1024*1024) {
-                       sprintf(file->size, "%.1f MB", ((double)st_size)/(1024*1024));
+                       BLI_snprintf(file->size, sizeof(file->size), "%.1f MB", ((double)st_size)/(1024*1024));
                }
                else if (st_size > 1024) {
-                       sprintf(file->size, "%d KB", (int)(st_size/1024));
+                       BLI_snprintf(file->size, sizeof(file->size), "%d KB", (int)(st_size/1024));
                }
                else {
-                       sprintf(file->size, "%d B", (int)st_size);
+                       BLI_snprintf(file->size, sizeof(file->size), "%d B", (int)st_size);
                }
 
-               strftime(datum, 32, "%d-%b-%y %H:%M", tm);
+               strftime(datum, 32, "%d-%b-%y %H:%M", tm); /* XXX, is this used? - campbell */
 
                if (st_size < 1000) {
-                       sprintf(size, "%10d", (int) st_size);
-               } else if (st_size < 1000 * 1000) {
-                       sprintf(size, "%6d %03d", (int) (st_size / 1000), (int) (st_size % 1000));
-               } else if (st_size < 100 * 1000 * 1000) {
-                       sprintf(size, "%2d %03d %03d", (int) (st_size / (1000 * 1000)), (int) ((st_size / 1000) % 1000), (int) ( st_size % 1000));
-               } else {
-                       sprintf(size, "> %4.1f M", (double) (st_size / (1024.0 * 1024.0)));
-                       sprintf(size, "%10d", (int) st_size);
+                       BLI_snprintf(size, sizeof(size), "%10d",
+                                    (int) st_size);
+               }
+               else if (st_size < 1000 * 1000) {
+                       BLI_snprintf(size, sizeof(size), "%6d %03d",
+                                    (int) (st_size / 1000), (int) (st_size % 1000));
+               }
+               else if (st_size < 100 * 1000 * 1000) {
+                       BLI_snprintf(size, sizeof(size), "%2d %03d %03d",
+                                    (int) (st_size / (1000 * 1000)), (int) ((st_size / 1000) % 1000), (int) ( st_size % 1000));
+               }
+               else {
+                       /* XXX, whats going on here?. 2x calls - campbell */
+                       BLI_snprintf(size, sizeof(size), "> %4.1f M", (double) (st_size / (1024.0 * 1024.0)));
+                       BLI_snprintf(size, sizeof(size), "%10d", (int) st_size);
                }
 
-               sprintf(buf,"%s %s %s %7s %s %s %10s %s", file->mode1, file->mode2, file->mode3, file->owner, file->date, file->time, size,
-                       file->relname);
+               BLI_snprintf(buf, sizeof(buf), "%s %s %s %7s %s %s %10s %s",
+                            file->mode1, file->mode2, file->mode3, file->owner,
+                            file->date, file->time, size, file->relname);
 
-               file->string=MEM_mallocN(strlen(buf)+1, "filestring");
-               if (file->string){
-                       strcpy(file->string,buf);
-               }
+               file->string = BLI_strdup(buf);
        }
 }
 
index 1f45be6848dc79ae6bb8283d7bf13e1749ca0d25..82b934d52e60ad1b0051b4ca70428124d99f9c43 100644 (file)
@@ -6560,14 +6560,14 @@ static void customdata_version_242(Mesh *me)
                if (layer->type == CD_MTFACE) {
                        if (layer->name[0] == 0) {
                                if (mtfacen == 0) strcpy(layer->name, "UVMap");
-                               else sprintf(layer->name, "UVMap.%.3d", mtfacen);
+                               else BLI_snprintf(layer->name, sizeof(layer->name), "UVMap.%.3d", mtfacen);
                        }
                        mtfacen++;
                }
                else if (layer->type == CD_MCOL) {
                        if (layer->name[0] == 0) {
                                if (mcoln == 0) strcpy(layer->name, "Col");
-                               else sprintf(layer->name, "Col.%.3d", mcoln);
+                               else BLI_snprintf(layer->name, sizeof(layer->name), "Col.%.3d", mcoln);
                        }
                        mcoln++;
                }
@@ -9062,8 +9062,9 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
                                                        strcpy(kb->name, "Basis");
                                        }
                                        else {
-                                               if(kb->name[0]==0)
-                                                       sprintf(kb->name, "Key %d", index);
+                                               if (kb->name[0]==0) {
+                                                       BLI_snprintf(kb->name, sizeof(kb->name), "Key %d", index);
+                                               }
                                                kb->adrcode= index++;
                                        }
                                }
@@ -10056,7 +10057,7 @@ static void do_versions(FileData *fd, Library *lib, Main *main)
                                BLI_addtail(&ob->particlesystem, psys);
 
                                md= modifier_new(eModifierType_ParticleSystem);
-                               sprintf(md->name, "ParticleSystem %i", BLI_countlist(&ob->particlesystem));
+                               BLI_snprintf(md->name, sizeof(md->name), "ParticleSystem %i", BLI_countlist(&ob->particlesystem));
                                psmd= (ParticleSystemModifierData*) md;
                                psmd->psys=psys;
                                BLI_addtail(&ob->modifiers, md);
index 8c4e0065a1922095e66d71e62cef3e42bdfb5cea..169d6b944137912b0f129254e81f2bec6e24d51b 100644 (file)
@@ -134,8 +134,8 @@ int getname_anim_fcurve(char *name, ID *id, FCurve *fcu)
                                char c= RNA_property_array_item_char(prop, fcu->array_index);
                                
                                /* we need to write the index to a temp buffer (in py syntax) */
-                               if (c) sprintf(arrayindbuf, "%c ", c);
-                               else sprintf(arrayindbuf, "[%d]", fcu->array_index);
+                               if (c) BLI_snprintf(arrayindbuf, sizeof(arrayindbuf), "%c ", c);
+                               else BLI_snprintf(arrayindbuf, sizeof(arrayindbuf), "[%d]", fcu->array_index);
                                
                                arrayname= &arrayindbuf[0];
                        }
index a928976d6957d82c8fc66776f7dd991d9d44bfdd..9ec27b69835f1a15736eb7905909ba128bdc4985 100644 (file)
@@ -1453,7 +1453,7 @@ static void RIG_printCtrl(RigControl *ctrl, char *indent)
        printf("%sBone: %s\n", indent, ctrl->bone->name);
        printf("%sLink: %s\n", indent, ctrl->link ? ctrl->link->name : "!NONE!");
        
-       sprintf(text, "%soffset", indent);
+       BLI_snprintf(text, sizeof(text), "%soffset", indent);
        print_v3(text, ctrl->offset);
        
        printf("%sFlag: %i\n", indent, ctrl->flag);
index 502da1be8ac0b6210537542be18dd1b2b5b5c84f..e33b778a168cade18cf6da64f773ef603985350e 100644 (file)
@@ -45,6 +45,7 @@
 #include "BLI_edgehash.h"
 #include "BLI_memarena.h"
 #include "BLI_utildefines.h"
+#include "BLI_string.h"
 
 #include "BKE_DerivedMesh.h"
 #include "BKE_modifier.h"
@@ -1613,7 +1614,7 @@ static void meshdeform_matrix_solve(MeshDeformModifierData *mmd, MeshDeformBind
        NLContext *context;
        float vec[3], gridvec[3];
        int a, b, x, y, z, totvar;
-       char message[1024];
+       char message[256];
 
        /* setup variable indices */
        mdb->varidx= MEM_callocN(sizeof(int)*mdb->size3, "MeshDeformDSvaridx");
@@ -1715,7 +1716,7 @@ static void meshdeform_matrix_solve(MeshDeformModifierData *mmd, MeshDeformBind
                        break;
                }
 
-               sprintf(message, "Mesh deform solve %d / %d       |||", a+1, mdb->totcagevert);
+               BLI_snprintf(message, sizeof(message), "Mesh deform solve %d / %d       |||", a+1, mdb->totcagevert);
                progress_bar((float)(a+1)/(float)(mdb->totcagevert), message);
        }
 
index 6a9323107d713f3427fbb6cea4eb040c4348cefd..c28b688e377f646e06d1dd5dd56a9b746e80770d 100644 (file)
@@ -543,7 +543,7 @@ static void pose_slide_draw_status (tPoseSlideOp *pso)
                        break;
        }
        
-       sprintf(status_str, "%s: %d %%", mode_str, (int)(pso->percentage*100.0f));
+       BLI_snprintf(status_str, sizeof(status_str), "%s: %d %%", mode_str, (int)(pso->percentage*100.0f));
        ED_area_headerprint(pso->sa, status_str);
 }
 
index 5cdb9c763960410cfb8ec68b115ff3b3d3382f55..dcddde207f081bce067b7a74f04ef3c26af49f91 100644 (file)
@@ -977,7 +977,9 @@ static void poselib_preview_apply (bContext *C, wmOperator *op)
        /* do header print - if interactively previewing */
        if (pld->state == PL_PREVIEW_RUNNING) {
                if (pld->flag & PL_PREVIEW_SHOWORIGINAL) {
-                       sprintf(pld->headerstr, "PoseLib Previewing Pose: [Showing Original Pose] | Use Tab to start previewing poses again");
+                       BLI_strncpy(pld->headerstr,
+                                   "PoseLib Previewing Pose: [Showing Original Pose] | Use Tab to start previewing poses again",
+                                   sizeof(pld->headerstr));
                        ED_area_headerprint(pld->sa, pld->headerstr);
                }
                else if (pld->searchstr[0]) {
@@ -988,10 +990,10 @@ static void poselib_preview_apply (bContext *C, wmOperator *op)
                        /* get search-string */
                        index= pld->search_cursor;
                        
-                       if (index >= 0 && index <= 64) {
+                       if (index >= 0 && index <= sizeof(tempstr) - 1) {
                                memcpy(&tempstr[0], &pld->searchstr[0], index);
                                tempstr[index]= '|';
-                               memcpy(&tempstr[index+1], &pld->searchstr[index], 64-index);
+                               memcpy(&tempstr[index+1], &pld->searchstr[index], (sizeof(tempstr) - 1) - index);
                        }
                        else {
                                BLI_strncpy(tempstr, pld->searchstr, sizeof(tempstr));
@@ -1000,11 +1002,18 @@ static void poselib_preview_apply (bContext *C, wmOperator *op)
                        /* get marker name */
                        BLI_strncpy(markern, pld->marker ? pld->marker->name : "No Matches", sizeof(markern));
 
-                       sprintf(pld->headerstr, "PoseLib Previewing Pose: Filter - [%s] | Current Pose - \"%s\"  | Use ScrollWheel or PageUp/Down to change", tempstr, markern);
+                       BLI_snprintf(pld->headerstr, sizeof(pld->headerstr),
+                                    "PoseLib Previewing Pose: Filter - [%s] | "
+                                    "Current Pose - \"%s\"  | "
+                                    "Use ScrollWheel or PageUp/Down to change",
+                                    tempstr, markern);
                        ED_area_headerprint(pld->sa, pld->headerstr);
                }
                else {
-                       sprintf(pld->headerstr, "PoseLib Previewing Pose: \"%s\"  | Use ScrollWheel or PageUp/Down to change", pld->marker->name);
+                       BLI_snprintf(pld->headerstr, sizeof(pld->headerstr),
+                                    "PoseLib Previewing Pose: \"%s\"  | "
+                                    "Use ScrollWheel or PageUp/Down to change",
+                                    pld->marker->name);
                        ED_area_headerprint(pld->sa, pld->headerstr);
                }
        }
index 80278c95d05b33a24db596db4920b10313a963b5..fe9eb6dcd0145da499bc6b6c081a71f191766424 100644 (file)
@@ -2035,10 +2035,9 @@ void REEB_exportGraph(ReebGraph *rg, int count)
        
        if (count == -1)
        {
-               sprintf(filename, "test.txt");
+               strcpy(filename, "test.txt");
        }
-       else
-       {
+       else {
                sprintf(filename, "test%05i.txt", count);
        }
        f = fopen(filename, "w");
index 762564c1cc9c2d23ae643de8e4cbd4301d3d6c40..85ddc7ef14e6dd2acd9f7f4cba9b086bdabdf4ec 100644 (file)
@@ -1069,17 +1069,17 @@ static void curve_rename_fcurves(Object *obedit, ListBase *orig_curves)
                        while (a--) {
                                keyIndex= getCVKeyIndex(editnurb, bezt);
                                if(keyIndex) {
-                                       sprintf(rna_path, "splines[%d].bezier_points[%d]", nu_index, pt_index);
-                                       sprintf(orig_rna_path, "splines[%d].bezier_points[%d]", keyIndex->nu_index, keyIndex->pt_index);
+                                       BLI_snprintf(rna_path, sizeof(rna_path), "splines[%d].bezier_points[%d]", nu_index, pt_index);
+                                       BLI_snprintf(orig_rna_path, sizeof(orig_rna_path), "splines[%d].bezier_points[%d]", keyIndex->nu_index, keyIndex->pt_index);
 
                                        if(keyIndex->switched) {
                                                char handle_path[64], orig_handle_path[64];
-                                               sprintf(orig_handle_path, "%s.handle_left", orig_rna_path);
-                                               sprintf(handle_path, "%s.handle_right", rna_path);
+                                               BLI_snprintf(orig_handle_path, sizeof(orig_rna_path), "%s.handle_left", orig_rna_path);
+                                               BLI_snprintf(handle_path, sizeof(rna_path), "%s.handle_right", rna_path);
                                                fcurve_path_rename(ad, orig_handle_path, handle_path, orig_curves, &curves);
 
-                                               sprintf(orig_handle_path, "%s.handle_right", orig_rna_path);
-                                               sprintf(handle_path, "%s.handle_left", rna_path);
+                                               BLI_snprintf(orig_handle_path, sizeof(orig_rna_path), "%s.handle_right", orig_rna_path);
+                                               BLI_snprintf(handle_path, sizeof(rna_path), "%s.handle_left", rna_path);
                                                fcurve_path_rename(ad, orig_handle_path, handle_path, orig_curves, &curves);
                                        }
 
@@ -1100,8 +1100,8 @@ static void curve_rename_fcurves(Object *obedit, ListBase *orig_curves)
                        while (a--) {
                                keyIndex= getCVKeyIndex(editnurb, bp);
                                if(keyIndex) {
-                                       sprintf(rna_path, "splines[%d].points[%d]", nu_index, pt_index);
-                                       sprintf(orig_rna_path, "splines[%d].points[%d]", keyIndex->nu_index, keyIndex->pt_index);
+                                       BLI_snprintf(rna_path, sizeof(rna_path), "splines[%d].points[%d]", nu_index, pt_index);
+                                       BLI_snprintf(orig_rna_path, sizeof(orig_rna_path), "splines[%d].points[%d]", keyIndex->nu_index, keyIndex->pt_index);
                                        fcurve_path_rename(ad, orig_rna_path, rna_path, orig_curves, &curves);
 
                                        keyIndex->nu_index= nu_index;
@@ -1140,8 +1140,8 @@ static void curve_rename_fcurves(Object *obedit, ListBase *orig_curves)
                }
 
                if(keyIndex) {
-                       sprintf(rna_path, "splines[%d]", nu_index);
-                       sprintf(orig_rna_path, "splines[%d]", keyIndex->nu_index);
+                       BLI_snprintf(rna_path, sizeof(rna_path), "splines[%d]", nu_index);
+                       BLI_snprintf(orig_rna_path, sizeof(orig_rna_path), "splines[%d]", keyIndex->nu_index);
                        fcurve_path_rename(ad, orig_rna_path, rna_path, orig_curves, &curves);
                }
 
index 760faf01b6c8abc450d78eabe2aeaa8792c16386..53ef16a70a0c7710c7ae915881c5b61fa2625134 100644 (file)
@@ -143,9 +143,9 @@ static void gp_drawui_layer (uiLayout *layout, bGPdata *gpd, bGPDlayer *gpl, con
                
                /* name */
                if (gpl->flag & GP_LAYER_HIDE)
-                       sprintf(name, "%s (Hidden)", gpl->info);
+                       BLI_snprintf(name, sizeof(name), "%s (Hidden)", gpl->info);
                else
-                       sprintf(name, "%s (Locked)", gpl->info);
+                       BLI_snprintf(name, sizeof(name), "%s (Locked)", gpl->info);
                uiItemL(sub, name, ICON_NONE);
                        
                /* delete button (only if hidden but not locked!) */
index 0e9dbaf3022d3286df2706bed7079ec9d20012d1..16b543737d09e29490acadfbd3dcfb44f39e14e4 100644 (file)
@@ -180,7 +180,7 @@ void uiStyleFontDrawExt(uiFontStyle *fs, rcti *rect, const char *str,
        if (fs->kerning == 1)
                BLF_enable(fs->uifont_id, BLF_KERNING_DEFAULT);
 
-       BLF_draw(fs->uifont_id, str, 65535); /* XXX, use real length */
+       BLF_draw(fs->uifont_id, str, BLF_DRAW_STR_DUMMY_MAX);
        BLF_disable(fs->uifont_id, BLF_CLIPPING);
        if (fs->shadow)
                BLF_disable(fs->uifont_id, BLF_SHADOW);
@@ -243,7 +243,7 @@ void uiStyleFontDrawRotated(uiFontStyle *fs, rcti *rect, const char *str)
        if (fs->kerning == 1)
                BLF_enable(fs->uifont_id, BLF_KERNING_DEFAULT);
 
-       BLF_draw(fs->uifont_id, str, 65535); /* XXX, use real length */
+       BLF_draw(fs->uifont_id, str, BLF_DRAW_STR_DUMMY_MAX);
        BLF_disable(fs->uifont_id, BLF_ROTATION);
        BLF_disable(fs->uifont_id, BLF_CLIPPING);
        if (fs->shadow)
@@ -291,7 +291,7 @@ void UI_DrawString(float x, float y, const char *str)
 
        uiStyleFontSet(&style->widget);
        BLF_position(style->widget.uifont_id, x, y, 0.0f);
-       BLF_draw(style->widget.uifont_id, str, 65535); /* XXX, use real length */
+       BLF_draw(style->widget.uifont_id, str, BLF_DRAW_STR_DUMMY_MAX);
 
        if (style->widget.kerning == 1)
                BLF_disable(style->widget.uifont_id, BLF_KERNING_DEFAULT);
index ccca0c8f7cfafd0a1696bfbf7d34cc51fa0aaccd..379a253a5c9af2cda3464ce75f11571db61f2f6c 100644 (file)
@@ -2471,12 +2471,15 @@ static void operator_search_cb(const bContext *C, void *UNUSED(arg), const char
                                int len= strlen(ot->name);
                                
                                /* display name for menu, can hold hotkey */
-                               BLI_strncpy(name, ot->name, 256);
+                               BLI_strncpy(name, ot->name, sizeof(name));
                                
                                /* check for hotkey */
-                               if(len < 256-6) {
-                                       if(WM_key_event_operator_string(C, ot->idname, WM_OP_EXEC_DEFAULT, NULL, TRUE, &name[len+1], 256-len-1))
+                               if(len < sizeof(name)-6) {
+                                       if (WM_key_event_operator_string(C, ot->idname, WM_OP_EXEC_DEFAULT, NULL, TRUE,
+                                                                        &name[len+1], sizeof(name)-len-1))
+                                       {
                                                name[len]= '|';
+                                       }
                                }
                                
                                if(0==uiSearchItemAdd(items, name, ot, 0))
index 81ea3370331bfc7701029b64fa8df01c2ddccd8d..b8201d762df953a368f8f6ab89c9653d0ffcc46d 100644 (file)
@@ -1541,7 +1541,7 @@ static void scroll_printstr(Scene *scene, float x, float y, float val, int power
        }
        
        /* draw it */
-       BLF_draw_default_ascii(x, y, 0.0f, timecode_str, sizeof(timecode_str)-1);
+       BLF_draw_default_ascii(x, y, 0.0f, timecode_str, sizeof(timecode_str));
 }
 
 /* Draw scrollbars in the given 2d-region */
@@ -2093,11 +2093,11 @@ void UI_view2d_text_cache_draw(ARegion *ar)
                }
 
                if(v2s->rect.xmin >= v2s->rect.xmax)
-                       BLF_draw_default((float)v2s->mval[0]+xofs, (float)v2s->mval[1]+yofs, 0.0, str, 65535);
+                       BLF_draw_default((float)v2s->mval[0]+xofs, (float)v2s->mval[1]+yofs, 0.0, str, BLF_DRAW_STR_DUMMY_MAX);
                else {
                        BLF_clipping_default(v2s->rect.xmin-4, v2s->rect.ymin-4, v2s->rect.xmax+4, v2s->rect.ymax+4);
                        BLF_enable_default(BLF_CLIPPING);
-                       BLF_draw_default(v2s->rect.xmin+xofs, v2s->rect.ymin+yofs, 0.0f, str, 65535);
+                       BLF_draw_default(v2s->rect.xmin+xofs, v2s->rect.ymin+yofs, 0.0f, str, BLF_DRAW_STR_DUMMY_MAX);
                        BLF_disable_default(BLF_CLIPPING);
                }
        }
index 5294e29d3d5775cdb6301d213235e84e6c1d9cd5..0bb5dbef0ea32e36963946ebe6c66d7f02c97d25 100644 (file)
@@ -1042,7 +1042,7 @@ static int fluidsimBake(bContext *C, ReportList *reports, Object *fsDomain, shor
        fsset->surfaceSmoothing = domainSettings->surfaceSmoothing; 
        fsset->surfaceSubdivs = domainSettings->surfaceSubdivs; 
        fsset->farFieldSize = domainSettings->farFieldSize; 
-       BLI_strncpy(fsset->outputPath, targetFile, 240);
+       BLI_strncpy(fsset->outputPath, targetFile, sizeof(fsset->outputPath));
 
        // domain channels
        fsset->channelSizeFrameTime = 
index 08833b335eb531a3f4da8c28290fab23c2bc7551..e4088fe10c4f1f0a1b0e8f2731249f645e1d98d5 100644 (file)
@@ -478,7 +478,7 @@ void ED_region_do_draw(bContext *C, ARegion *ar)
                glClear(GL_COLOR_BUFFER_BIT);
                
                UI_ThemeColor(TH_TEXT);
-               BLF_draw_default(20, 8, 0.0f, ar->headerstr, 65535); /* XXX, use real length */
+               BLF_draw_default(20, 8, 0.0f, ar->headerstr, BLF_DRAW_STR_DUMMY_MAX);
        }
        else if(at->draw) {
                at->draw(C, ar);
@@ -1809,5 +1809,5 @@ void ED_region_info_draw(ARegion *ar, const char *text, int block, float alpha)
        /* text */
        UI_ThemeColor(TH_TEXT_HI);
        BLF_position(fontid, 12, rect.ymin + 5, 0.0f);
-       BLF_draw(fontid, text, 256);
+       BLF_draw(fontid, text, BLF_DRAW_STR_DUMMY_MAX);
 }
index 7517c0cd543189bb9fa52e523d0c3e3c93dc5974..c84a9d10ab4915f885481f5553bae8d87cff63e5 100644 (file)
@@ -134,7 +134,7 @@ void file_draw_buttons(const bContext *C, ARegion *ar)
        ARegion*                  artmp;
        
        /* Initialize UI block. */
-       sprintf(uiblockstr, "win %p", (void *)ar);
+       BLI_snprintf(uiblockstr, sizeof(uiblockstr), "win %p", (void *)ar);
        block = uiBeginBlock(C, ar, uiblockstr, UI_EMBOSS);
        uiBlockSetHandleFunc(block, do_file_buttons, NULL);
 
index 5b505004f49b0e9d2c972e03e7e83495231813f1..32fe8498eaf32af792d82c472782432852aeb6f2 100644 (file)
@@ -1199,10 +1199,10 @@ void filelist_from_main(struct FileList *filelist)
                                        if(idcode == ID_MA || idcode == ID_TE || idcode == ID_LA || idcode == ID_WO || idcode == ID_IM) {
                                                files->flags |= IMAGEFILE;
                                        }
-                                       if(id->lib && fake) sprintf(files->extra, "LF %d", id->us);
-                                       else if(id->lib) sprintf(files->extra, "L    %d", id->us);
-                                       else if(fake) sprintf(files->extra, "F    %d", id->us);
-                                       else sprintf(files->extra, "      %d", id->us);
+                                       if(id->lib && fake) BLI_snprintf(files->extra, sizeof(files->extra), "LF %d", id->us);
+                                       else if(id->lib) BLI_snprintf(files->extra, sizeof(files->extra), "L    %d", id->us);
+                                       else if(fake) BLI_snprintf(files->extra, sizeof(files->extra), "F    %d", id->us);
+                                       else BLI_snprintf(files->extra, sizeof(files->extra), "      %d", id->us);
                                        
                                        if(id->lib) {
                                                if(totlib==0) firstlib= files;
index c1dfa97a5088e2a8b02c72bb7d975af51c95058f..9e1ff82c20d32e4cc29eb11eaf3982e762cf76df 100644 (file)
@@ -647,7 +647,7 @@ static void graph_panel_drivers(const bContext *C, Panel *pa)
                        
                        uiItemL(row, "Driver Value:", ICON_NONE);
                        
-                       sprintf(valBuf, "%.3f", driver->curval);
+                       BLI_snprintf(valBuf, sizeof(valBuf), "%.3f", driver->curval);
                        uiItemL(row, valBuf, ICON_NONE);
                }
        
@@ -702,18 +702,18 @@ static void graph_panel_drivers(const bContext *C, Panel *pa)
                                        graph_panel_driverVar__transChan(box, ale->id, dvar);
                                        break;
                        }
-                       
-               /* value of variable */
-               if (driver->flag & DRIVER_FLAG_SHOWDEBUG) {
-                       char valBuf[32];
-                       
-                       box= uiLayoutBox(col);
-                       row= uiLayoutRow(box, 1);
+
+                       /* value of variable */
+                       if (driver->flag & DRIVER_FLAG_SHOWDEBUG) {
+                               char valBuf[32];
+
+                               box= uiLayoutBox(col);
+                               row= uiLayoutRow(box, 1);
                                uiItemL(row, "Value:", ICON_NONE);
                                
-                               sprintf(valBuf, "%.3f", dvar->curval);
+                               BLI_snprintf(valBuf, sizeof(valBuf), "%.3f", dvar->curval);
                                uiItemL(row, valBuf, ICON_NONE);
-               }
+                       }
        }
        
        /* cleanup */
index 3aebc39bd0a395462821710e4dee5e9ce97a4c06..43bea1c311d58051d65211bc11b17a6f40a9a679 100644 (file)
@@ -682,7 +682,7 @@ void uiTemplateImage(uiLayout *layout, bContext *C, PointerRNA *ptr, const char
                                        uiButSetFunc(but, image_freecache_cb, ima, NULL);
                                        
                                        if(iuser->frames)
-                                               sprintf(str, "(%d) Frames:", iuser->framenr);
+                                               BLI_snprintf(str, sizeof(str), "(%d) Frames:", iuser->framenr);
                                        else strcpy(str, "Frames:");
                                        uiBlockBeginAlign(block);
                                        uiDefButI(block, NUM, imagechanged, str,                10, 90,150, 20, &iuser->frames, 0.0, MAXFRAMEF, 0, 0, "Number of images of a movie to use");
@@ -763,7 +763,7 @@ void uiTemplateImage(uiLayout *layout, bContext *C, PointerRNA *ptr, const char
 
                                col= uiLayoutColumn(split, 0);
                                 
-                               sprintf(str, "(%d) Frames", iuser->framenr);
+                               BLI_snprintf(str, sizeof(str), "(%d) Frames", iuser->framenr);
                                uiItemR(col, userptr, "frame_duration", 0, str, ICON_NONE);
                                if(ima->anim) {
                                        block= uiLayoutGetBlock(col);
index dc712e286a172e7dac9f37c14d05551b4677f473..21a4f35bcb84e79b256abd87b58097b705ba71a2 100644 (file)
@@ -139,7 +139,7 @@ void draw_image_info(ARegion *ar, int color_manage, int channels, int x, int y,
        BLF_size(blf_mono_font, 11, 72);
 
        glColor3ub(255, 255, 255);
-       sprintf(str, "X:%-4d  Y:%-4d |", x, y);
+       BLI_snprintf(str, sizeof(str), "X:%-4d  Y:%-4d |", x, y);
        // UI_DrawString(6, 6, str); // works ok but fixed width is nicer.
        BLF_position(blf_mono_font, dx, 6, 0);
        BLF_draw_ascii(blf_mono_font, str, sizeof(str));
@@ -147,14 +147,14 @@ void draw_image_info(ARegion *ar, int color_manage, int channels, int x, int y,
 
        if(zp) {
                glColor3ub(255, 255, 255);
-               sprintf(str, " Z:%-.4f |", 0.5f+0.5f*(((float)*zp)/(float)0x7fffffff));
+               BLI_snprintf(str, sizeof(str), " Z:%-.4f |", 0.5f+0.5f*(((float)*zp)/(float)0x7fffffff));
                BLF_position(blf_mono_font, dx, 6, 0);
                BLF_draw_ascii(blf_mono_font, str, sizeof(str));
                dx += BLF_width(blf_mono_font, str);
        }
        if(zpf) {
                glColor3ub(255, 255, 255);
-               sprintf(str, " Z:%-.3f |", *zpf);
+               BLI_snprintf(str, sizeof(str), " Z:%-.3f |", *zpf);
                BLF_position(blf_mono_font, dx, 6, 0);
                BLF_draw_ascii(blf_mono_font, str, sizeof(str));
                dx += BLF_width(blf_mono_font, str);
@@ -163,33 +163,33 @@ void draw_image_info(ARegion *ar, int color_manage, int channels, int x, int y,
        if(channels >= 3) {
                glColor3ubv(red);
                if (fp)
-                       sprintf(str, "  R:%-.4f", fp[0]);
+                       BLI_snprintf(str, sizeof(str), "  R:%-.4f", fp[0]);
                else if (cp)
-                       sprintf(str, "  R:%-3d", cp[0]);
+                       BLI_snprintf(str, sizeof(str), "  R:%-3d", cp[0]);
                else
-                       sprintf(str, "  R:-");
+                       BLI_snprintf(str, sizeof(str), "  R:-");
                BLF_position(blf_mono_font, dx, 6, 0);
                BLF_draw_ascii(blf_mono_font, str, sizeof(str));
                dx += BLF_width(blf_mono_font, str);
                
                glColor3ubv(green);
                if (fp)
-                       sprintf(str, "  G:%-.4f", fp[1]);
+                       BLI_snprintf(str, sizeof(str), "  G:%-.4f", fp[1]);
                else if (cp)
-                       sprintf(str, "  G:%-3d", cp[1]);
+                       BLI_snprintf(str, sizeof(str), "  G:%-3d", cp[1]);
                else
-                       sprintf(str, "  G:-");
+                       BLI_snprintf(str, sizeof(str), "  G:-");
                BLF_position(blf_mono_font, dx, 6, 0);
                BLF_draw_ascii(blf_mono_font, str, sizeof(str));
                dx += BLF_width(blf_mono_font, str);
                
                glColor3ubv(blue);
                if (fp)
-                       sprintf(str, "  B:%-.4f", fp[2]);
+                       BLI_snprintf(str, sizeof(str), "  B:%-.4f", fp[2]);
                else if (cp)
-                       sprintf(str, "  B:%-3d", cp[2]);
+                       BLI_snprintf(str, sizeof(str), "  B:%-3d", cp[2]);
                else
-                       sprintf(str, "  B:-");
+                       BLI_snprintf(str, sizeof(str), "  B:-");
                BLF_position(blf_mono_font, dx, 6, 0);
                BLF_draw_ascii(blf_mono_font, str, sizeof(str));
                dx += BLF_width(blf_mono_font, str);
@@ -197,11 +197,11 @@ void draw_image_info(ARegion *ar, int color_manage, int channels, int x, int y,
                if(channels == 4) {
                        glColor3ub(255, 255, 255);
                        if (fp)
-                               sprintf(str, "  A:%-.4f", fp[3]);
+                               BLI_snprintf(str, sizeof(str), "  A:%-.4f", fp[3]);
                        else if (cp)
-                               sprintf(str, "  A:%-3d", cp[3]);
+                               BLI_snprintf(str, sizeof(str), "  A:%-3d", cp[3]);
                        else
-                               sprintf(str, "- ");
+                               BLI_snprintf(str, sizeof(str), "- ");
                        BLF_position(blf_mono_font, dx, 6, 0);
                        BLF_draw_ascii(blf_mono_font, str, sizeof(str));
                        dx += BLF_width(blf_mono_font, str);
@@ -269,12 +269,12 @@ void draw_image_info(ARegion *ar, int color_manage, int channels, int x, int y,
                        rgb_to_yuv((float)cp[0]/255.0f, (float)cp[0]/255.0f, (float)cp[0]/255.0f, &lum, &u, &v);
                }
                
-               sprintf(str, "V:%-.4f", val);
+               BLI_snprintf(str, sizeof(str), "V:%-.4f", val);
                BLF_position(blf_mono_font, dx, 6, 0);
                BLF_draw_ascii(blf_mono_font, str, sizeof(str));
                dx += BLF_width(blf_mono_font, str);
 
-               sprintf(str, "   L:%-.4f", lum);
+               BLI_snprintf(str, sizeof(str), "   L:%-.4f", lum);
                BLF_position(blf_mono_font, dx, 6, 0);
                BLF_draw_ascii(blf_mono_font, str, sizeof(str));
                dx += BLF_width(blf_mono_font, str);
@@ -289,22 +289,22 @@ void draw_image_info(ARegion *ar, int color_manage, int channels, int x, int y,
                        rgb_to_yuv((float)cp[0]/255.0f, (float)cp[1]/255.0f, (float)cp[2]/255.0f, &lum, &u, &v);
                }
 
-               sprintf(str, "H:%-.4f", hue);
+               BLI_snprintf(str, sizeof(str), "H:%-.4f", hue);
                BLF_position(blf_mono_font, dx, 6, 0);
                BLF_draw_ascii(blf_mono_font, str, sizeof(str));
                dx += BLF_width(blf_mono_font, str);
 
-               sprintf(str, "  S:%-.4f", sat);
+               BLI_snprintf(str, sizeof(str), "  S:%-.4f", sat);
                BLF_position(blf_mono_font, dx, 6, 0);
                BLF_draw_ascii(blf_mono_font, str, sizeof(str));
                dx += BLF_width(blf_mono_font, str);
 
-               sprintf(str, "  V:%-.4f", val);
+               BLI_snprintf(str, sizeof(str), "  V:%-.4f", val);
                BLF_position(blf_mono_font, dx, 6, 0);
                BLF_draw_ascii(blf_mono_font, str, sizeof(str));
                dx += BLF_width(blf_mono_font, str);
 
-               sprintf(str, "   L:%-.4f", lum);
+               BLI_snprintf(str, sizeof(str), "   L:%-.4f", lum);
                BLF_position(blf_mono_font, dx, 6, 0);
                BLF_draw_ascii(blf_mono_font, str, sizeof(str));
                dx += BLF_width(blf_mono_font, str);
index deff1c77912bb11a3d923a39ebc39df52edadd5d..2090b4eae0a1dc12a34f9d4c40ccde09c29ed7e1 100644 (file)
@@ -143,7 +143,7 @@ static int unpack_all_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event)
        Main *bmain= CTX_data_main(C);
        uiPopupMenu *pup;
        uiLayout *layout;
-       char title[128];
+       char title[64];
        int count = 0;
        
        count = countPackedFiles(bmain);
@@ -155,9 +155,9 @@ static int unpack_all_invoke(bContext *C, wmOperator *op, wmEvent *UNUSED(event)
        }
 
        if(count == 1)
-               sprintf(title, "Unpack 1 file");
+               strcpy(title, "Unpack 1 file");
        else
-               sprintf(title, "Unpack %d files", count);
+               BLI_snprintf(title, sizeof(title), "Unpack %d files", count);
        
        pup= uiPupMenuBegin(C, title, ICON_NONE);
        layout= uiPupMenuLayout(pup);
index 09a8ebc8770c2ae50ee040ef8352770672105dc9..2c1e7a0c546cb9528d36071fdf642314959a5b8e 100644 (file)
@@ -3580,7 +3580,7 @@ static void draw_controller_header(uiLayout *layout, PointerRNA *ptr, int xco, i
        bController *cont= (bController *)ptr->data;
 
        char state[3];
-       sprintf(state, "%d", RNA_int_get(ptr, "states"));
+       BLI_snprintf(state, sizeof(state), "%d", RNA_int_get(ptr, "states"));
        
        box= uiLayoutBox(layout);
        row= uiLayoutRow(box, 0);
@@ -4497,7 +4497,7 @@ static void logic_buttons_new(bContext *C, ARegion *ar)
        RNA_pointer_create(NULL, &RNA_SpaceLogicEditor, slogic, &logic_ptr);
        idar= get_selected_and_linked_obs(C, &count, slogic->scaflag);
        
-       sprintf(uiblockstr, "buttonswin %p", (void *)ar);
+       BLI_snprintf(uiblockstr, sizeof(uiblockstr), "buttonswin %p", (void *)ar);
        block= uiBeginBlock(C, ar, uiblockstr, UI_EMBOSS);
        uiBlockSetHandleFunc(block, do_logic_buts, NULL);
        
@@ -4815,7 +4815,7 @@ void logic_buttons(bContext *C, ARegion *ar)
        if(ob==NULL) return;
 //     uiSetButLock(object_is_libdata(ob), ERROR_LIBDATA_MESSAGE);
 
-       sprintf(numstr, "buttonswin %p", (void *)ar);
+       BLI_snprintf(numstr, sizeof(numstr), "buttonswin %p", (void *)ar);
        block= uiBeginBlock(C, ar, numstr, UI_EMBOSS);
        uiBlockSetHandleFunc(block, do_logic_buts, NULL);
 
index 9f13fd7bbb29099cf846832b480452a1ed150982..c7defdeb64b8210b5f2f5e78a1b51f2ba7233876 100644 (file)
@@ -715,7 +715,7 @@ static void draw_nla_channel_list_gl (bAnimContext *ac, ListBase *anim_data, Vie
                                        }
                                                
                                        sel = SEL_NLT(nlt);
-                                       strcpy(name, nlt->name);
+                                       BLI_strncpy(name, nlt->name, sizeof(name));
                                        
                                        // draw manually still
                                        doDraw= 1;
index 9b1bd1d7b3181a3b40edaaa491e45ab403cfbd52..0ccbf9127c6bacea87bf2d3c8fff4c869bc69704 100644 (file)
@@ -749,7 +749,7 @@ static void outliner_find_panel(Scene *UNUSED(scene), ARegion *ar, SpaceOops *so
        TreeElement *last_find;
        TreeStoreElem *tselem;
        int ytop, xdelta, prevFound=0;
-       char name[32];
+       char name[sizeof(soops->search_string)];
        
        /* get last found tree-element based on stored search_tse */
        last_find= outliner_find_tse(soops, &soops->search_tse);
@@ -803,7 +803,7 @@ static void outliner_find_panel(Scene *UNUSED(scene), ARegion *ar, SpaceOops *so
                        /* store selection */
                        soops->search_tse= *tselem;
                        
-                       BLI_strncpy(soops->search_string, name, 33);
+                       BLI_strncpy(soops->search_string, name, sizeof(soops->search_string));
                        soops->search_flags= flags;
                        
                        /* redraw */
index 637c8fcdbcf19752207481e89770f6384063ef6a..26bf25d281d5f10903d335f88996f67b137b70d5 100644 (file)
@@ -75,7 +75,7 @@ static void text_font_end(SpaceText *UNUSED(st))
 static int text_font_draw(SpaceText *UNUSED(st), int x, int y, char *str)
 {
        BLF_position(mono, x, y, 0);
-       BLF_draw(mono, str, 65535); /* XXX, use real length */
+       BLF_draw(mono, str, BLF_DRAW_STR_DUMMY_MAX);
 
        return BLF_width(mono, str);
 }
index 0066e9d799a4b0b60a471b57a4c4628fdbf3ff4a..1f578455d1000a7980beff11711b36aa8b87d947 100644 (file)
@@ -4539,7 +4539,7 @@ static void draw_new_particle_system(Scene *scene, View3D *v3d, RegionView3D *rv
 
                        for(a=0, pa=psys->particles; a<totpart; a++, pa++){
                                float vec_txt[3];
-                               sprintf(numstr, "%i", a);
+                               BLI_snprintf(numstr, sizeof(numstr), "%i", a);
                                /* use worldspace beause object matrix is already applied */
                                mul_v3_m4v3(vec_txt, ob->imat, cache[a]->co);
                                view3d_cached_text_draw_add(vec_txt, numstr, 10, V3D_CACHE_TEXT_WORLDSPACE|V3D_CACHE_TEXT_ASCII, tcol);
index 0f08c1984abef3998000c3d96004d72821052121..ad85ff6dea80d98c77d496757500883849ed19c7 100644 (file)
@@ -863,24 +863,24 @@ static void draw_selected_name(Scene *scene, Object *ob)
                                }
                        }
                        if(name && markern)
-                               sprintf(info, "(%d) %s %s <%s>", CFRA, ob->id.name+2, name, markern);
+                               BLI_snprintf(info, sizeof(info), "(%d) %s %s <%s>", CFRA, ob->id.name+2, name, markern);
                        else if(name)
-                               sprintf(info, "(%d) %s %s", CFRA, ob->id.name+2, name);
+                               BLI_snprintf(info, sizeof(info), "(%d) %s %s", CFRA, ob->id.name+2, name);
                        else
-                               sprintf(info, "(%d) %s", CFRA, ob->id.name+2);
+                               BLI_snprintf(info, sizeof(info), "(%d) %s", CFRA, ob->id.name+2);
                }
                else if(ELEM3(ob->type, OB_MESH, OB_LATTICE, OB_CURVE)) {
                        Key *key= NULL;
                        KeyBlock *kb = NULL;
-                       char shapes[75];
+                       char shapes[MAX_NAME + 10];
                        
                        /* try to display active shapekey too */
-                       shapes[0] = 0;
+                       shapes[0] = '\0';
                        key = ob_get_key(ob);
                        if(key){
                                kb = BLI_findlink(&key->block, ob->shapenr-1);
                                if(kb){
-                                       sprintf(shapes, ": %s ", kb->name);             
+                                       BLI_snprintf(shapes, sizeof(shapes), ": %s ", kb->name);
                                        if(ob->shapeflag == OB_SHAPE_LOCK){
                                                strcat(shapes, " (Pinned)");
                                        }
@@ -888,16 +888,16 @@ static void draw_selected_name(Scene *scene, Object *ob)
                        }
                        
                        if(markern)
-                               sprintf(info, "(%d) %s %s <%s>", CFRA, ob->id.name+2, shapes, markern);
+                               BLI_snprintf(info, sizeof(info), "(%d) %s %s <%s>", CFRA, ob->id.name+2, shapes, markern);
                        else
-                               sprintf(info, "(%d) %s %s", CFRA, ob->id.name+2, shapes);
+                               BLI_snprintf(info, sizeof(info), "(%d) %s %s", CFRA, ob->id.name+2, shapes);
                }
                else {
                        /* standard object */
                        if (markern)
-                               sprintf(info, "(%d) %s <%s>", CFRA, ob->id.name+2, markern);
+                               BLI_snprintf(info, sizeof(info), "(%d) %s <%s>", CFRA, ob->id.name+2, markern);
                        else
-                               sprintf(info, "(%d) %s", CFRA, ob->id.name+2);
+                               BLI_snprintf(info, sizeof(info), "(%d) %s", CFRA, ob->id.name+2);
                }
                
                /* color depends on whether there is a keyframe */
@@ -909,9 +909,9 @@ static void draw_selected_name(Scene *scene, Object *ob)
        else {
                /* no object */
                if (markern)
-                       sprintf(info, "(%d) <%s>", CFRA, markern);
+                       BLI_snprintf(info, sizeof(info), "(%d) <%s>", CFRA, markern);
                else
-                       sprintf(info, "(%d)", CFRA);
+                       BLI_snprintf(info, sizeof(info), "(%d)", CFRA);
                
                /* color is always white */
                UI_ThemeColor(TH_TEXT_HI);
@@ -920,7 +920,7 @@ static void draw_selected_name(Scene *scene, Object *ob)
        if (U.uiflag & USER_SHOW_ROTVIEWICON)
                offset = 14 + (U.rvisize * 2);
 
-       BLF_draw_default(offset,  10, 0.0f, info, sizeof(info)-1);
+       BLF_draw_default(offset,  10, 0.0f, info, sizeof(info));
 }
 
 static void view3d_camera_border(Scene *scene, ARegion *ar, View3D *v3d, RegionView3D *rv3d, rctf *viewborder_r, short no_shift, short no_zoom)
@@ -2623,7 +2623,7 @@ static void draw_viewport_fps(Scene *scene, ARegion *ar)
                BLI_snprintf(printable, sizeof(printable), "fps: %i", (int)(fps+0.5f));
        }
        
-       BLF_draw_default_ascii(22,  ar->winy-17, 0.0f, printable, sizeof(printable)-1);
+       BLF_draw_default_ascii(22,  ar->winy-17, 0.0f, printable, sizeof(printable));
 }
 
 static int view3d_main_area_draw_engine(const bContext *C, ARegion *ar)
@@ -2897,7 +2897,8 @@ static void view3d_main_area_draw_info(const bContext *C, ARegion *ar, const cha
                        BLI_snprintf(numstr, sizeof(numstr), "%s x %.4g", grid_unit, v3d->grid);
                }
 
-               BLF_draw_default_ascii(22,  ar->winy-(USER_SHOW_VIEWPORTNAME?40:20), 0.0f, numstr[0]?numstr : grid_unit, sizeof(numstr)); /* XXX, use real length */
+               BLF_draw_default_ascii(22,  ar->winy-(USER_SHOW_VIEWPORTNAME?40:20), 0.0f,
+                                      numstr[0] ? numstr : grid_unit, sizeof(numstr));
        }
 }
 
index b88e57e186196ee530fa82b962ffea9dce3c3b39..bd34477c13f8b57043ed6ac61ce6b8aac72cd3ba 100644 (file)
@@ -59,6 +59,7 @@
 
 #include "BLI_math.h"
 #include "BLI_utildefines.h"
+#include "BLI_string.h"
 
 //#include "blendef.h"
 //
@@ -552,7 +553,7 @@ static void applyObjectConstraintRot(TransInfo *t, TransData *td, float vec[3],
 
 void setConstraint(TransInfo *t, float space[3][3], int mode, const char text[])
 {
-       strncpy(t->con.text + 1, text, 48);
+       BLI_strncpy(t->con.text + 1, text, sizeof(t->con.text) - 1);
        copy_m3_m3(t->con.mtx, space);
        t->con.mode = mode;
        getConstraintMatrix(t);
@@ -579,7 +580,7 @@ void setLocalConstraint(TransInfo *t, int mode, const char text[])
                        setConstraint(t, t->data->axismtx, mode, text);
                }
                else {
-                       strncpy(t->con.text + 1, text, 48);
+                       BLI_strncpy(t->con.text + 1, text, sizeof(t->con.text) - 1);
                        copy_m3_m3(t->con.mtx, t->data->axismtx);
                        t->con.mode = mode;
                        getConstraintMatrix(t);
@@ -598,7 +599,7 @@ void setLocalConstraint(TransInfo *t, int mode, const char text[])
 /*
        Set the constraint according to the user defined orientation
 
-       ftext is a format string passed to sprintf. It will add the name of
+       ftext is a format string passed to BLI_snprintf. It will add the name of
        the orientation where %s is (logically).
 */
 void setUserConstraint(TransInfo *t, short orientation, int mode, const char ftext[])
@@ -609,28 +610,28 @@ void setUserConstraint(TransInfo *t, short orientation, int mode, const char fte
        case V3D_MANIP_GLOBAL:
                {
                        float mtx[3][3]= MAT3_UNITY;
-                       sprintf(text, ftext, "global");
+                       BLI_snprintf(text, sizeof(text), ftext, "global");
                        setConstraint(t, mtx, mode, text);
                }
                break;
        case V3D_MANIP_LOCAL:
-               sprintf(text, ftext, "local");
+               BLI_snprintf(text, sizeof(text), ftext, "local");
                setLocalConstraint(t, mode, text);
                break;
        case V3D_MANIP_NORMAL:
-               sprintf(text, ftext, "normal");
+               BLI_snprintf(text, sizeof(text), ftext, "normal");
                setConstraint(t, t->spacemtx, mode, text);
                break;
        case V3D_MANIP_VIEW:
-               sprintf(text, ftext, "view");
+               BLI_snprintf(text, sizeof(text), ftext, "view");
                setConstraint(t, t->spacemtx, mode, text);
                break;
        case V3D_MANIP_GIMBAL:
-               sprintf(text, ftext, "gimbal");
+               BLI_snprintf(text, sizeof(text), ftext, "gimbal");
                setConstraint(t, t->spacemtx, mode, text);
                break;
        default: /* V3D_MANIP_CUSTOM */
-               sprintf(text, ftext, t->spacename);
+               BLI_snprintf(text, sizeof(text), ftext, t->spacename);
                setConstraint(t, t->spacemtx, mode, text);
                break;
        }
@@ -874,11 +875,11 @@ static void setNearestAxis2d(TransInfo *t)
        /* no correction needed... just use whichever one is lower */
        if ( abs(t->mval[0]-t->con.imval[0]) < abs(t->mval[1]-t->con.imval[1]) ) {
                t->con.mode |= CON_AXIS1;
-               sprintf(t->con.text, " along Y axis");
+               BLI_snprintf(t->con.text, sizeof(t->con.text), " along Y axis");
        }
        else {
                t->con.mode |= CON_AXIS0;
-               sprintf(t->con.text, " along X axis");
+               BLI_snprintf(t->con.text, sizeof(t->con.text), " along X axis");
        }
 }
 
@@ -929,31 +930,31 @@ static void setNearestAxis3d(TransInfo *t)
        if (len[0] <= len[1] && len[0] <= len[2]) {
                if (t->modifiers & MOD_CONSTRAINT_PLANE) {
                        t->con.mode |= (CON_AXIS1|CON_AXIS2);
-                       sprintf(t->con.text, " locking %s X axis", t->spacename);
+                       BLI_snprintf(t->con.text, sizeof(t->con.text), " locking %s X axis", t->spacename);
                }
                else {
                        t->con.mode |= CON_AXIS0;
-                       sprintf(t->con.text, " along %s X axis", t->spacename);
+                       BLI_snprintf(t->con.text, sizeof(t->con.text), " along %s X axis", t->spacename);
                }
        }
        else if (len[1] <= len[0] && len[1] <= len[2]) {
                if (t->modifiers & MOD_CONSTRAINT_PLANE) {
                        t->con.mode |= (CON_AXIS0|CON_AXIS2);
-                       sprintf(t->con.text, " locking %s Y axis", t->spacename);
+                       BLI_snprintf(t->con.text, sizeof(t->con.text), " locking %s Y axis", t->spacename);
                }
                else {
                        t->con.mode |= CON_AXIS1;
-                       sprintf(t->con.text, " along %s Y axis", t->spacename);
+                       BLI_snprintf(t->con.text, sizeof(t->con.text), " along %s Y axis", t->spacename);
                }
        }
        else if (len[2] <= len[1] && len[2] <= len[0]) {
                if (t->modifiers & MOD_CONSTRAINT_PLANE) {
                        t->con.mode |= (CON_AXIS0|CON_AXIS1);
-                       sprintf(t->con.text, " locking %s Z axis", t->spacename);
+                       BLI_snprintf(t->con.text, sizeof(t->con.text), " locking %s Z axis", t->spacename);
                }
                else {
                        t->con.mode |= CON_AXIS2;
-                       sprintf(t->con.text, " along %s Z axis", t->spacename);
+                       BLI_snprintf(t->con.text, sizeof(t->con.text), " along %s Z axis", t->spacename);
                }
        }
 }
index 1a1022a5c7fa84e2218c97fb3324e2891957ed9b..73322a8292d16ade68171d731853ee6aef70a7e4 100644 (file)
@@ -179,18 +179,18 @@ void unpack_menu(bContext *C, const char *opname, const char *id_name, const cha
 
                BLI_strncpy(local_name, abs_name, sizeof(local_name));
                BLI_splitdirstring(local_name, fi);
-               sprintf(local_name, "//%s/%s", folder, fi);
+               BLI_snprintf(local_name, sizeof(local_name), "//%s/%s", folder, fi);
                if(strcmp(abs_name, local_name)!=0) {
                        switch(checkPackedFile(local_name, pf)) {
                                case PF_NOFILE:
-                                       sprintf(line, "Create %s", local_name);
+                                       BLI_snprintf(line, sizeof(line), "Create %s", local_name);
                                        props_ptr= uiItemFullO(layout, opname, line, ICON_NONE, NULL, WM_OP_EXEC_DEFAULT, UI_ITEM_O_RETURN_PROPS);
                                        RNA_enum_set(&props_ptr, "method", PF_WRITE_LOCAL);
                                        RNA_string_set(&props_ptr, "id", id_name);
 
                                        break;
                                case PF_EQUAL:
-                                       sprintf(line, "Use %s (identical)", local_name);
+                                       BLI_snprintf(line, sizeof(line), "Use %s (identical)", local_name);
                                        //uiItemEnumO(layout, opname, line, 0, "method", PF_USE_LOCAL);
                                        props_ptr= uiItemFullO(layout, opname, line, ICON_NONE, NULL, WM_OP_EXEC_DEFAULT, UI_ITEM_O_RETURN_PROPS);
                                        RNA_enum_set(&props_ptr, "method", PF_USE_LOCAL);
@@ -198,13 +198,13 @@ void unpack_menu(bContext *C, const char *opname, const char *id_name, const cha
 
                                        break;
                                case PF_DIFFERS:
-                                       sprintf(line, "Use %s (differs)", local_name);
+                                       BLI_snprintf(line, sizeof(line), "Use %s (differs)", local_name);
                                        //uiItemEnumO(layout, opname, line, 0, "method", PF_USE_LOCAL);
                                        props_ptr= uiItemFullO(layout, opname, line, ICON_NONE, NULL, WM_OP_EXEC_DEFAULT, UI_ITEM_O_RETURN_PROPS);
                                        RNA_enum_set(&props_ptr, "method", PF_USE_LOCAL);
                                        RNA_string_set(&props_ptr, "id", id_name);
 
-                                       sprintf(line, "Overwrite %s", local_name);
+                                       BLI_snprintf(line, sizeof(line), "Overwrite %s", local_name);
                                        //uiItemEnumO(layout, opname, line, 0, "method", PF_WRITE_LOCAL);
                                        props_ptr= uiItemFullO(layout, opname, line, ICON_NONE, NULL, WM_OP_EXEC_DEFAULT, UI_ITEM_O_RETURN_PROPS);
                                        RNA_enum_set(&props_ptr, "method", PF_WRITE_LOCAL);
@@ -216,27 +216,27 @@ void unpack_menu(bContext *C, const char *opname, const char *id_name, const cha
 
        switch(checkPackedFile(abs_name, pf)) {
                case PF_NOFILE:
-                       sprintf(line, "Create %s", abs_name);
+                       BLI_snprintf(line, sizeof(line), "Create %s", abs_name);
                        //uiItemEnumO(layout, opname, line, 0, "method", PF_WRITE_ORIGINAL);
                        props_ptr= uiItemFullO(layout, opname, line, ICON_NONE, NULL, WM_OP_EXEC_DEFAULT, UI_ITEM_O_RETURN_PROPS);
                        RNA_enum_set(&props_ptr, "method", PF_WRITE_ORIGINAL);
                        RNA_string_set(&props_ptr, "id", id_name);
                        break;
                case PF_EQUAL:
-                       sprintf(line, "Use %s (identical)", abs_name);
+                       BLI_snprintf(line, sizeof(line), "Use %s (identical)", abs_name);
                        //uiItemEnumO(layout, opname, line, 0, "method", PF_USE_ORIGINAL);
                        props_ptr= uiItemFullO(layout, opname, line, ICON_NONE, NULL, WM_OP_EXEC_DEFAULT, UI_ITEM_O_RETURN_PROPS);
                        RNA_enum_set(&props_ptr, "method", PF_USE_ORIGINAL);
                        RNA_string_set(&props_ptr, "id", id_name);
                        break;
                case PF_DIFFERS:
-                       sprintf(line, "Use %s (differs)", abs_name);
+                       BLI_snprintf(line, sizeof(line), "Use %s (differs)", abs_name);
                        //uiItemEnumO(layout, opname, line, 0, "method", PF_USE_ORIGINAL);
                        props_ptr= uiItemFullO(layout, opname, line, ICON_NONE, NULL, WM_OP_EXEC_DEFAULT, UI_ITEM_O_RETURN_PROPS);
                        RNA_enum_set(&props_ptr, "method", PF_USE_ORIGINAL);
                        RNA_string_set(&props_ptr, "id", id_name);
 
-                       sprintf(line, "Overwrite %s", abs_name);
+                       BLI_snprintf(line, sizeof(line), "Overwrite %s", abs_name);
                        //uiItemEnumO(layout, opname, line, 0, "method", PF_WRITE_ORIGINAL);
                        props_ptr= uiItemFullO(layout, opname, line, ICON_NONE, NULL, WM_OP_EXEC_DEFAULT, UI_ITEM_O_RETURN_PROPS);
                        RNA_enum_set(&props_ptr, "method", PF_WRITE_ORIGINAL);
index 6c8713aa03e6c2779ea5aa68763577319537fad5..52422d37f29e115b52b634ba8dcc73e0c68e0d8b 100644 (file)
 
 
 #include <math.h>                      /* fabs */
-#include <stdio.h>                     /* for sprintf          */
+#include <stdio.h>                     /* for size_t */
 
 #include "BLI_utildefines.h"
+#include "BLI_string.h"
 
 #include "WM_types.h"
 
@@ -84,34 +85,34 @@ void outputNumInput(NumInput *n, char *str)
                        inv[0] = 0;
 
                if( n->val[i] > 1e10f || n->val[i] < -1e10f )
-                       sprintf(&str[j*20], "%s%.4e%c", inv, n->val[i], cur);
+                       BLI_snprintf(&str[j*20], 20, "%s%.4e%c", inv, n->val[i], cur);
                else
                        switch (n->ctrl[i]) {
                        case 0:
-                               sprintf(&str[j*20], "%sNONE%c", inv, cur);
+                               BLI_snprintf(&str[j*20], 20, "%sNONE%c", inv, cur);
                                break;
                        case 1:
                        case -1:
-                               sprintf(&str[j*20], "%s%.0f%c", inv, n->val[i], cur);
+                               BLI_snprintf(&str[j*20], 20, "%s%.0f%c", inv, n->val[i], cur);
                                break;
                        case 10:
                        case -10:
-                               sprintf(&str[j*20], "%s%.f.%c", inv, n->val[i], cur);
+                               BLI_snprintf(&str[j*20], 20, "%s%.f.%c", inv, n->val[i], cur);
                                break;
                        case 100:
                        case -100:
-                               sprintf(&str[j*20], "%s%.1f%c", inv, n->val[i], cur);
+                               BLI_snprintf(&str[j*20], 20, "%s%.1f%c", inv, n->val[i], cur);
                                break;
                        case 1000:
                        case -1000:
-                               sprintf(&str[j*20], "%s%.2f%c", inv, n->val[i], cur);
+                               BLI_snprintf(&str[j*20], 20, "%s%.2f%c", inv, n->val[i], cur);
                                break;
                        case 10000:
                        case -10000:
-                               sprintf(&str[j*20], "%s%.3f%c", inv, n->val[i], cur);
+                               BLI_snprintf(&str[j*20], 20, "%s%.3f%c", inv, n->val[i], cur);
                                break;
                        default:
-                               sprintf(&str[j*20], "%s%.4e%c", inv, n->val[i], cur);
+                               BLI_snprintf(&str[j*20], 20, "%s%.4e%c", inv, n->val[i], cur);
                        }
        }
 }
index 830dc224c94921247d037c9f8db869de0f4379c3..840e094980c210b9ed2d05e430bab650fc3f4459 100644 (file)
@@ -46,6 +46,7 @@
 #include "BLI_editVert.h"
 #include "BLI_uvproject.h"
 #include "BLI_utildefines.h"
+#include "BLI_string.h"
 
 #include "BKE_context.h"
 #include "BKE_customdata.h"
@@ -334,7 +335,7 @@ static void minimize_stretch_iteration(bContext *C, wmOperator *op, int interact
                param_flush(ms->handle);
 
                if(sa) {
-                       sprintf(str, "Minimize Stretch. Blend %.2f", ms->blend);
+                       BLI_snprintf(str, sizeof(str), "Minimize Stretch. Blend %.2f", ms->blend);
                        ED_area_headerprint(sa, str);
                }
 
index 93ea067cfb74f3219bc1ea8090df3d24ff197341..ef2abb20cf3b1a199aae00c6dc3ee082977bb666 100644 (file)
@@ -173,7 +173,7 @@ static void gpu_material_set_attrib_id(GPUMaterial *material)
         * removed by the glsl compiler by dead code elimination */
 
        for(a=0, b=0; a<attribs->totlayer; a++) {
-               sprintf(name, "att%d", attribs->layer[a].attribid);
+               BLI_snprintf(name, sizeof(name), "att%d", attribs->layer[a].attribid);
                attribs->layer[a].glindex = GPU_shader_get_attribute(shader, name);
 
                if(attribs->layer[a].glindex >= 0) {
index e6d092856857488408fb33022c7db277ce622140..a09033795285aa2dd88833ebad666ab80794833d 100644 (file)
@@ -1289,7 +1289,7 @@ struct ImBuf * IMB_anim_absolute(struct anim * anim, int position,
 
        if (ibuf) {
                if (filter_y) IMB_filtery(ibuf);
-               sprintf(ibuf->name, "%s.%04d", anim->name, anim->curposition + 1);
+               BLI_snprintf(ibuf->name, sizeof(ibuf->name), "%s.%04d", anim->name, anim->curposition + 1);
                
        }
        return(ibuf);
index 400b6a1fa5ffd29762157288720c2469f8f80cd8..93456d39c9cf374f7d5a836a80e375e3161124b2 100644 (file)
@@ -605,7 +605,7 @@ void ntreeCompositExecTree(bNodeTree *ntree, RenderData *rd, int do_preview)
                                        ntree->progress(ntree->prh, (1.0f - curnode/(float)totnode));
                                if(ntree->stats_draw) {
                                        char str[128];
-                                       sprintf(str, "Compositing %d %s", curnode, node->name);
+                                       BLI_snprintf(str, sizeof(str), "Compositing %d %s", curnode, node->name);
                                        ntree->stats_draw(ntree->sdh, str);
                                }
                                curnode--;
index 2a28a7edfe8632ef0c1574f31583645b5fb41c69..638a94db20a27f87afb9f992c66403b420215b5b 100644 (file)
@@ -1257,8 +1257,9 @@ static uiBlock *wm_block_create_splash(bContext *C, ARegion *ar, void *UNUSED(ar
        version_str = &version_buf[0];
        revision_str = &revision_buf[0];
        
-       sprintf(version_str, "%d.%02d.%d", BLENDER_VERSION/100, BLENDER_VERSION%100, BLENDER_SUBVERSION);
-       sprintf(revision_str, "r%s", build_rev);
+       BLI_snprintf(version_str, sizeof(version_str),
+                    "%d.%02d.%d", BLENDER_VERSION/100, BLENDER_VERSION%100, BLENDER_SUBVERSION);
+       BLI_snprintf(revision_str, sizeof(revision_str), "r%s", build_rev);
        
        BLF_size(style->widgetlabel.uifont_id, style->widgetlabel.points, U.dpi);
        ver_width = (int)BLF_width(style->widgetlabel.uifont_id, version_str) + 5;