forked from Imagelibrary/rtems
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]
This commit is contained in:
committed by
Sebastian Huber
parent
4763ef8d9b
commit
f3df25b65c
@@ -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++)
|
||||
|
||||
Reference in New Issue
Block a user