[geany/geany-plugins] dc7804: debugger: Avoid possible overflows with strcpy()

Colomban Wendling git-noreply at xxxxx
Sun Nov 15 17:28:18 UTC 2015


Branch:      refs/heads/master
Author:      Colomban Wendling <ban at herbesfolles.org>
Committer:   Colomban Wendling <ban at herbesfolles.org>
Date:        Sat, 25 Oct 2014 14:32:58 UTC
Commit:      dc7804b0cc04d6155a80864ff94042fe66add293
             https://github.com/geany/geany-plugins/commit/dc7804b0cc04d6155a80864ff94042fe66add293

Log Message:
-----------
debugger: Avoid possible overflows with strcpy()


Modified Paths:
--------------
    debugger/src/breakpoint.c
    debugger/src/breakpoints.c
    debugger/src/dbm_gdb.c

Modified: debugger/src/breakpoint.c
4 lines changed, 2 insertions(+), 2 deletions(-)
===================================================================
@@ -50,10 +50,10 @@ breakpoint* break_new(void)
 breakpoint* break_new_full(const char* file, int line, const char* condition, int enabled, int hitscount)
 {
 	breakpoint* bp = break_new();
-	strcpy(bp->file, file);
+	strncpy(bp->file, file, G_N_ELEMENTS(bp->file) - 1);
 	bp->line = line;
 	if (condition)
-		strcpy(bp->condition, condition);
+		strncpy(bp->condition, condition, G_N_ELEMENTS(bp->condition) - 1);
 	bp->enabled = enabled;
 	bp->hitscount = hitscount;
 


Modified: debugger/src/breakpoints.c
4 lines changed, 2 insertions(+), 2 deletions(-)
===================================================================
@@ -227,7 +227,7 @@ static void breaks_set_condition_debug(breakpoint* bp)
 	{
 		/* revert to old condition (taken from tree) */
 		gchar* oldcondition = bptree_get_condition(bp);
-		strcpy(bp->condition, oldcondition);
+		strncpy(bp->condition, oldcondition, G_N_ELEMENTS(bp->condition) - 1);
 		g_free(oldcondition);
 		/* show error message */
 		dialogs_show_msgbox(GTK_MESSAGE_ERROR, "%s", debug_error_message());
@@ -596,7 +596,7 @@ void breaks_set_condition(const char* file, int line, const char* condition)
 		return;
 	
 	/* change condition */
-	strcpy(bp->condition, condition);
+	strncpy(bp->condition, condition, G_N_ELEMENTS(bp->condition) - 1);
 	
 	/* handle setting condition instantly if debugger is idle or stopped
 	and request debug module interruption overwise */


Modified: debugger/src/dbm_gdb.c
2 lines changed, 1 insertions(+), 1 deletions(-)
===================================================================
@@ -711,7 +711,7 @@ static result_class exec_sync_command(const gchar* command, gboolean wait4prompt
 			{
 				/* save error message */
 				gchar* msg = g_strcompress(strstr(coma, "msg=\"") + strlen("msg=\""));
-				strcpy(err_message, msg);
+				strncpy(err_message, msg, G_N_ELEMENTS(err_message) - 1);
 				g_free(msg);
 				
 				rc = RC_ERROR;



--------------
This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).


More information about the Plugins-Commits mailing list