summaryrefslogtreecommitdiffstats
path: root/cpukit/libmisc/monitor/mon-editor.c
diff options
context:
space:
mode:
authorHarrison Edward Gerber <gerberhe11@gmail.com>2021-05-27 17:31:53 -0700
committerVijay Kumar Banerjee <vijay@rtems.org>2021-05-28 16:00:32 -0600
commit6a56fd9340e46766dc5b069f259e4c133c06f39a (patch)
treed98567c815c5c194df70f3338a5b290f3ebb75f6 /cpukit/libmisc/monitor/mon-editor.c
parentChange filesystem utime_h handler to utimens_h (diff)
downloadrtems-6a56fd9340e46766dc5b069f259e4c133c06f39a.tar.bz2
cpukit/libmisc/monitor: Fix src/dest overlap of strcpy in mon-editor.c
See also CID 1399727 Closes #4444
Diffstat (limited to '')
-rw-r--r--cpukit/libmisc/monitor/mon-editor.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/cpukit/libmisc/monitor/mon-editor.c b/cpukit/libmisc/monitor/mon-editor.c
index dcea9fcc69..6957fee9c8 100644
--- a/cpukit/libmisc/monitor/mon-editor.c
+++ b/cpukit/libmisc/monitor/mon-editor.c
@@ -360,7 +360,17 @@ rtems_monitor_line_editor (
{
int bs;
pos--;
- strcpy (buffer + pos, buffer + pos + 1);
+
+ /*
+ * Memory operation used here instead of string
+ * method due the src and dest of buffer overlapping.
+ */
+ memmove(
+ buffer + pos,
+ buffer + pos + 1,
+ RTEMS_COMMAND_BUFFER_SIZE - pos - 1
+ );
+ buffer[RTEMS_COMMAND_BUFFER_SIZE - 1] = '\0';
fprintf(stdout,"\b%s \b", buffer + pos);
for (bs = 0; bs < ((int) strlen (buffer) - pos); bs++)
putchar ('\b');