From: Aschref Ben Thabet <aschref.ben-tha...@embedded-brains.de>

Replace strcpy with the safer memcpy().
The strcpy() function is designed to work exclusively with strings.
strcpy() copies each byte of the source string to the destination string
and stops when the terminating null character (\0) has been moved.
On the other hand, the memcpy() function is designed to work with any
type of data, because not all data ends with a null character, you must
provide the memcpy() function with the number of bytes you want to copy
from the source to the destination.
---
 cpukit/libmisc/monitor/mon-editor.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/cpukit/libmisc/monitor/mon-editor.c 
b/cpukit/libmisc/monitor/mon-editor.c
index a3b408a14f..e6ead104ca 100644
--- a/cpukit/libmisc/monitor/mon-editor.c
+++ b/cpukit/libmisc/monitor/mon-editor.c
@@ -339,8 +339,8 @@ rtems_monitor_line_editor (
             {
               int end;
               int bs;
-              strcpy (&buffer[pos], &buffer[pos + 1]);
-              fprintf(stdout,"\r%s $ %s", monitor_prompt, buffer);
+              memcpy(&buffer[pos], &buffer[pos + 1], strlen(&buffer[pos + 1]));
+              fprintf(stdout, "\r%s $ %s", monitor_prompt, buffer);
               end = (int) strlen (buffer);
               for (bs = 0; bs < (end - pos); bs++)
                 putchar ('\b');
-- 
2.26.2

_______________________________________________
devel mailing list
devel@rtems.org
http://lists.rtems.org/mailman/listinfo/devel

Reply via email to