From f3df25b65cd81f9fff778902fdd34dbb09ca4c33 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Frank=20K=C3=BChndel?= Date: Mon, 5 Oct 2020 16:49:14 +0200 Subject: cpukit/libmisc/monitor: Fix an illegal string copy This is actually an illegal use of strcpy() because one is not allowed to use this function with overlapping source and destination buffers; whereas memmove() is explicitly designed to handle such cases. The compiler warning was: ../../../cpukit/libmisc/monitor/mon-editor.c:342:15: warning: 'strcpy' accessing 1 byte at offsets [0, 75] and [0, 75] overlaps 1 byte at offset [0, 74] [-Wrestrict] --- cpukit/libmisc/monitor/mon-editor.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cpukit/libmisc/monitor/mon-editor.c b/cpukit/libmisc/monitor/mon-editor.c index a3b408a14f..dcea9fcc69 100644 --- a/cpukit/libmisc/monitor/mon-editor.c +++ b/cpukit/libmisc/monitor/mon-editor.c @@ -339,7 +339,8 @@ rtems_monitor_line_editor ( { int end; int bs; - strcpy (&buffer[pos], &buffer[pos + 1]); + memmove (&buffer[pos], &buffer[pos + 1], + strlen (&buffer[pos + 1]) + 1); fprintf(stdout,"\r%s $ %s", monitor_prompt, buffer); end = (int) strlen (buffer); for (bs = 0; bs < (end - pos); bs++) -- cgit v1.2.3