summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrank K├╝hndel <frank.kuehndel@embedded-brains.de>2020-10-05 16:49:14 +0200
committerSebastian Huber <sebastian.huber@embedded-brains.de>2020-10-12 08:46:48 +0200
commitf3df25b65cd81f9fff778902fdd34dbb09ca4c33 (patch)
treec7741f82cb458a1c1413783883e4e9957d9e068d
parent4763ef8d9b3d80599b8ac9f1f4a4c613f087c0e0 (diff)
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]
-rw-r--r--cpukit/libmisc/monitor/mon-editor.c3
1 files changed, 2 insertions, 1 deletions
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++)