[Bf-blender-cvs] [e9c8e03] master: Some minor fixes from coverity reports.

Bastien Montagne noreply at git.blender.org
Sun Jan 10 09:46:20 CET 2016


Commit: e9c8e0316fbce2edfc9c2b6d0ddce18a3ea2a22a
Author: Bastien Montagne
Date:   Sun Jan 10 09:45:57 2016 +0100
Branches: master
https://developer.blender.org/rBe9c8e0316fbce2edfc9c2b6d0ddce18a3ea2a22a

Some minor fixes from coverity reports.

===================================================================

M	source/blender/blenloader/intern/readfile.c
M	source/blender/editors/gpencil/gpencil_edit.c
M	source/blender/editors/space_file/file_ops.c
M	source/blender/editors/space_info/info_ops.c

===================================================================

diff --git a/source/blender/blenloader/intern/readfile.c b/source/blender/blenloader/intern/readfile.c
index fd144c0..a8c868a 100644
--- a/source/blender/blenloader/intern/readfile.c
+++ b/source/blender/blenloader/intern/readfile.c
@@ -10025,7 +10025,7 @@ static void read_libraries(FileData *basefd, ListBase *mainlist)
 							printf("	relative lib: %s\n", mainptr->curlib->name);
 							printf("  enter a new path:\n");
 							
-							if (scanf("%s", newlib_path) > 0) {
+							if (scanf("%1023s", newlib_path) > 0) {  /* Warning, keep length in sync with FILE_MAX! */
 								BLI_strncpy(mainptr->curlib->name, newlib_path, sizeof(mainptr->curlib->name));
 								BLI_strncpy(mainptr->curlib->filepath, newlib_path, sizeof(mainptr->curlib->filepath));
 								BLI_cleanup_path(G.main->name, mainptr->curlib->filepath);
diff --git a/source/blender/editors/gpencil/gpencil_edit.c b/source/blender/editors/gpencil/gpencil_edit.c
index 1b0a523..302d4da 100644
--- a/source/blender/editors/gpencil/gpencil_edit.c
+++ b/source/blender/editors/gpencil/gpencil_edit.c
@@ -1161,7 +1161,7 @@ static int gp_snap_cursor_to_sel(bContext *C, wmOperator *UNUSED(op))
 	}
 	CTX_DATA_END;
 	
-	if (v3d->around == V3D_AROUND_CENTER_MEAN) {
+	if (v3d->around == V3D_AROUND_CENTER_MEAN && count) {
 		mul_v3_fl(centroid, 1.0f / (float)count);
 		copy_v3_v3(cursor, centroid);
 	}
diff --git a/source/blender/editors/space_file/file_ops.c b/source/blender/editors/space_file/file_ops.c
index ccd1b7c..121bf75 100644
--- a/source/blender/editors/space_file/file_ops.c
+++ b/source/blender/editors/space_file/file_ops.c
@@ -1374,7 +1374,7 @@ int file_exec(bContext *C, wmOperator *exec_op)
 		}
 		else {
 			BLI_cleanup_dir(G.main->name, sfile->params->dir);
-			strcat(sfile->params->dir, file->relpath);
+			strncat(sfile->params->dir, file->relpath, sizeof(sfile->params->dir));
 			BLI_add_slash(sfile->params->dir);
 		}
 
diff --git a/source/blender/editors/space_info/info_ops.c b/source/blender/editors/space_info/info_ops.c
index 2bcd56a..771a646 100644
--- a/source/blender/editors/space_info/info_ops.c
+++ b/source/blender/editors/space_info/info_ops.c
@@ -249,7 +249,7 @@ static int unpack_all_invoke(bContext *C, wmOperator *op, const wmEvent *UNUSED(
 	}
 
 	if (count == 1)
-		strcpy(title, IFACE_("Unpack 1 File"));
+		BLI_strncpy(title, IFACE_("Unpack 1 File"), sizeof(title));
 	else
 		BLI_snprintf(title, sizeof(title), IFACE_("Unpack %d Files"), count);




More information about the Bf-blender-cvs mailing list