Commit 05c81edd authored by Thorsten Blum's avatar Thorsten Blum Committed by Daniel Thompson (RISCstar)
Browse files

kernel: debug: gdbstub: Replace deprecated strcpy() with strscpy()

strcpy() is deprecated; use strscpy() instead.

Link: https://github.com/KSPP/linux/issues/88


Reviewed-by: default avatarDouglas Anderson <dianders@chromium.org>
Signed-off-by: default avatarThorsten Blum <thorsten.blum@linux.dev>
Signed-off-by: default avatarDaniel Thompson (RISCstar) <danielt@kernel.org>
parent 76eeb9b8
Loading
Loading
Loading
Loading
+15 −14
Original line number Diff line number Diff line
@@ -30,6 +30,7 @@
#include <linux/kgdb.h>
#include <linux/kdb.h>
#include <linux/serial_core.h>
#include <linux/string.h>
#include <linux/reboot.h>
#include <linux/uaccess.h>
#include <asm/cacheflush.h>
@@ -547,7 +548,7 @@ static void gdb_cmd_setregs(struct kgdb_state *ks)
		error_packet(remcom_out_buffer, -EINVAL);
	} else {
		gdb_regs_to_pt_regs(gdb_regs, ks->linux_regs);
		strcpy(remcom_out_buffer, "OK");
		strscpy(remcom_out_buffer, "OK");
	}
}

@@ -577,7 +578,7 @@ static void gdb_cmd_memwrite(struct kgdb_state *ks)
	if (err)
		error_packet(remcom_out_buffer, err);
	else
		strcpy(remcom_out_buffer, "OK");
		strscpy(remcom_out_buffer, "OK");
}

#if DBG_MAX_REG_NUM > 0
@@ -630,7 +631,7 @@ static void gdb_cmd_reg_set(struct kgdb_state *ks)
	i = i / 2;
	kgdb_hex2mem(ptr, (char *)gdb_regs, i);
	dbg_set_reg(regnum, gdb_regs, ks->linux_regs);
	strcpy(remcom_out_buffer, "OK");
	strscpy(remcom_out_buffer, "OK");
}
#endif /* DBG_MAX_REG_NUM > 0 */

@@ -642,7 +643,7 @@ static void gdb_cmd_binwrite(struct kgdb_state *ks)
	if (err)
		error_packet(remcom_out_buffer, err);
	else
		strcpy(remcom_out_buffer, "OK");
		strscpy(remcom_out_buffer, "OK");
}

/* Handle the 'D' or 'k', detach or kill packets */
@@ -656,7 +657,7 @@ static void gdb_cmd_detachkill(struct kgdb_state *ks)
		if (error < 0) {
			error_packet(remcom_out_buffer, error);
		} else {
			strcpy(remcom_out_buffer, "OK");
			strscpy(remcom_out_buffer, "OK");
			kgdb_connected = 0;
		}
		put_packet(remcom_out_buffer);
@@ -676,7 +677,7 @@ static int gdb_cmd_reboot(struct kgdb_state *ks)
	/* For now, only honor R0 */
	if (strcmp(remcom_in_buffer, "R0") == 0) {
		printk(KERN_CRIT "Executing emergency reboot\n");
		strcpy(remcom_out_buffer, "OK");
		strscpy(remcom_out_buffer, "OK");
		put_packet(remcom_out_buffer);

		/*
@@ -739,7 +740,7 @@ static void gdb_cmd_query(struct kgdb_state *ks)

	case 'C':
		/* Current thread id */
		strcpy(remcom_out_buffer, "QC");
		strscpy(remcom_out_buffer, "QC");
		ks->threadid = shadow_pid(current->pid);
		int_to_threadref(thref, ks->threadid);
		pack_threadid(remcom_out_buffer + 2, thref);
@@ -773,7 +774,7 @@ static void gdb_cmd_query(struct kgdb_state *ks)
			int len = strlen(remcom_in_buffer + 6);

			if ((len % 2) != 0) {
				strcpy(remcom_out_buffer, "E01");
				strscpy(remcom_out_buffer, "E01");
				break;
			}
			kgdb_hex2mem(remcom_in_buffer + 6,
@@ -785,14 +786,14 @@ static void gdb_cmd_query(struct kgdb_state *ks)
			kdb_parse(remcom_out_buffer);
			kdb_common_deinit_state();

			strcpy(remcom_out_buffer, "OK");
			strscpy(remcom_out_buffer, "OK");
		}
		break;
#endif
#ifdef CONFIG_HAVE_ARCH_KGDB_QXFER_PKT
	case 'S':
		if (!strncmp(remcom_in_buffer, "qSupported:", 11))
			strcpy(remcom_out_buffer, kgdb_arch_gdb_stub_feature);
			strscpy(remcom_out_buffer, kgdb_arch_gdb_stub_feature);
		break;
	case 'X':
		if (!strncmp(remcom_in_buffer, "qXfer:", 6))
@@ -822,7 +823,7 @@ static void gdb_cmd_task(struct kgdb_state *ks)
		}
		kgdb_usethread = thread;
		ks->kgdb_usethreadid = ks->threadid;
		strcpy(remcom_out_buffer, "OK");
		strscpy(remcom_out_buffer, "OK");
		break;
	case 'c':
		ptr = &remcom_in_buffer[2];
@@ -837,7 +838,7 @@ static void gdb_cmd_task(struct kgdb_state *ks)
			}
			kgdb_contthread = thread;
		}
		strcpy(remcom_out_buffer, "OK");
		strscpy(remcom_out_buffer, "OK");
		break;
	}
}
@@ -851,7 +852,7 @@ static void gdb_cmd_thread(struct kgdb_state *ks)
	kgdb_hex2long(&ptr, &ks->threadid);
	thread = getthread(ks->linux_regs, ks->threadid);
	if (thread)
		strcpy(remcom_out_buffer, "OK");
		strscpy(remcom_out_buffer, "OK");
	else
		error_packet(remcom_out_buffer, -EINVAL);
}
@@ -913,7 +914,7 @@ static void gdb_cmd_break(struct kgdb_state *ks)
			(int) length, *bpt_type - '0');

	if (error == 0)
		strcpy(remcom_out_buffer, "OK");
		strscpy(remcom_out_buffer, "OK");
	else
		error_packet(remcom_out_buffer, error);
}