[Bf-blender-cvs] SVN commit: /data/svn/bf-blender [58246] trunk/blender/source/blender: replace strncpy with BLI_strncpy for cases we expect the string to be NULL terminated .

Campbell Barton ideasman42 at gmail.com
Mon Jul 15 00:08:57 CEST 2013


Revision: 58246
          http://projects.blender.org/scm/viewvc.php?view=rev&root=bf-blender&revision=58246
Author:   campbellbarton
Date:     2013-07-14 22:08:56 +0000 (Sun, 14 Jul 2013)
Log Message:
-----------
replace strncpy with BLI_strncpy for cases we expect the string to be NULL terminated.

Modified Paths:
--------------
    trunk/blender/source/blender/compositor/operations/COM_KeyingScreenOperation.h
    trunk/blender/source/blender/compositor/operations/COM_TrackPositionOperation.h
    trunk/blender/source/blender/editors/space_clip/clip_ops.c
    trunk/blender/source/blender/editors/space_sequencer/sequencer_add.c
    trunk/blender/source/blender/editors/transform/transform_orientations.c

Modified: trunk/blender/source/blender/compositor/operations/COM_KeyingScreenOperation.h
===================================================================
--- trunk/blender/source/blender/compositor/operations/COM_KeyingScreenOperation.h	2013-07-14 22:02:40 UTC (rev 58245)
+++ trunk/blender/source/blender/compositor/operations/COM_KeyingScreenOperation.h	2013-07-14 22:08:56 UTC (rev 58246)
@@ -32,6 +32,7 @@
 #include "DNA_movieclip_types.h"
 
 #include "BLI_listbase.h"
+#include "BLI_string.h"
 
 extern "C" {
 	#include "BLI_voronoi.h"
@@ -76,7 +77,7 @@
 	void deinitializeTileData(rcti *rect, void *data);
 
 	void setMovieClip(MovieClip *clip) {this->m_movieClip = clip;}
-	void setTrackingObject(const char *object) {strncpy(this->m_trackingObject, object, sizeof(this->m_trackingObject));}
+	void setTrackingObject(const char *object) { BLI_strncpy(this->m_trackingObject, object, sizeof(this->m_trackingObject)); }
 	void setFramenumber(int framenumber) {this->m_framenumber = framenumber;}
 
 	void executePixel(float output[4], int x, int y, void *data);

Modified: trunk/blender/source/blender/compositor/operations/COM_TrackPositionOperation.h
===================================================================
--- trunk/blender/source/blender/compositor/operations/COM_TrackPositionOperation.h	2013-07-14 22:02:40 UTC (rev 58245)
+++ trunk/blender/source/blender/compositor/operations/COM_TrackPositionOperation.h	2013-07-14 22:08:56 UTC (rev 58246)
@@ -33,6 +33,7 @@
 #include "DNA_tracking_types.h"
 
 #include "BLI_listbase.h"
+#include "BLI_string.h"
 
 /**
  * Class with implementation of green screen gradient rasterization
@@ -60,8 +61,8 @@
 	TrackPositionOperation();
 
 	void setMovieClip(MovieClip *clip) {this->m_movieClip = clip;}
-	void setTrackingObject(char *object) {strncpy(this->m_trackingObjectName, object, sizeof(this->m_trackingObjectName));}
-	void setTrackName(char *track) {strncpy(this->m_trackName, track, sizeof(this->m_trackName));}
+	void setTrackingObject(char *object) { BLI_strncpy(this->m_trackingObjectName, object, sizeof(this->m_trackingObjectName)); }
+	void setTrackName(char *track) { BLI_strncpy(this->m_trackName, track, sizeof(this->m_trackName)); }
 	void setFramenumber(int framenumber) {this->m_framenumber = framenumber;}
 	void setAxis(int value) {this->m_axis = value;}
 	void setPosition(int value) {this->m_position = value;}

Modified: trunk/blender/source/blender/editors/space_clip/clip_ops.c
===================================================================
--- trunk/blender/source/blender/editors/space_clip/clip_ops.c	2013-07-14 22:02:40 UTC (rev 58245)
+++ trunk/blender/source/blender/editors/space_clip/clip_ops.c	2013-07-14 22:08:56 UTC (rev 58246)
@@ -50,6 +50,7 @@
 #include "BLI_math.h"
 #include "BLI_rect.h"
 #include "BLI_threads.h"
+#include "BLI_string.h"
 
 #include "BLF_translation.h"
 
@@ -250,13 +251,13 @@
 		clip = ED_space_clip_get_clip(sc);
 
 	if (clip) {
-		strncpy(path, clip->name, sizeof(path));
+		BLI_strncpy(path, clip->name, sizeof(path));
 
 		BLI_path_abs(path, G.main->name);
 		BLI_parent_dir(path);
 	}
 	else {
-		strncpy(path, U.textudir, sizeof(path));
+		BLI_strncpy(path, U.textudir, sizeof(path));
 	}
 
 	if (RNA_struct_property_is_set(op->ptr, "files"))

Modified: trunk/blender/source/blender/editors/space_sequencer/sequencer_add.c
===================================================================
--- trunk/blender/source/blender/editors/space_sequencer/sequencer_add.c	2013-07-14 22:02:40 UTC (rev 58245)
+++ trunk/blender/source/blender/editors/space_sequencer/sequencer_add.c	2013-07-14 22:08:56 UTC (rev 58246)
@@ -761,7 +761,7 @@
 	BKE_sequencer_sort(scene);
 
 	/* last active name */
-	strncpy(ed->act_imagedir, strip->dir, FILE_MAXDIR - 1);
+	BLI_strncpy(ed->act_imagedir, strip->dir, sizeof(ed->act_imagedir));
 
 	if (RNA_boolean_get(op->ptr, "overlap") == FALSE) {
 		if (BKE_sequence_test_overlap(ed->seqbasep, seq))

Modified: trunk/blender/source/blender/editors/transform/transform_orientations.c
===================================================================
--- trunk/blender/source/blender/editors/transform/transform_orientations.c	2013-07-14 22:02:40 UTC (rev 58245)
+++ trunk/blender/source/blender/editors/transform/transform_orientations.c	2013-07-14 22:08:56 UTC (rev 58246)
@@ -115,7 +115,7 @@
 		View3D *v3d = CTX_wm_view3d(C);
 		if (rv3d->persp == RV3D_CAMOB && v3d->camera) {
 			/* If an object is used as camera, then this space is the same as object space! */
-			strncpy(name, v3d->camera->id.name + 2, MAX_NAME);
+			BLI_strncpy(name, v3d->camera->id.name + 2, MAX_NAME);
 		}
 		else {
 			strcpy(name, "Custom View");
@@ -141,7 +141,7 @@
 
 	/* use object name if no name is given */
 	if (name[0] == 0) {
-		strncpy(name, ob->id.name + 2, MAX_ID_NAME - 2);
+		BLI_strncpy(name, ob->id.name + 2, MAX_ID_NAME - 2);
 	}
 
 	return addMatrixSpace(C, mat, name, overwrite);
@@ -306,7 +306,7 @@
 	if (ts == NULL) {
 		ts = MEM_callocN(sizeof(TransformOrientation), "UserTransSpace from matrix");
 		BLI_addtail(transform_spaces, ts);
-		strncpy(ts->name, name, sizeof(ts->name));
+		BLI_strncpy(ts->name, name, sizeof(ts->name));
 	}
 
 	/* copy matrix into transform space */




More information about the Bf-blender-cvs mailing list