[PATCH v2] cpukit/libmisc/monitor: Fix src/dest overlap of strcpy in mon-editor.c
Joel Sherrill
joel at rtems.org
Fri May 28 19:08:12 UTC 2021
This looks OK.
On Thu, May 27, 2021 at 7:32 PM Harrison Edward Gerber <gerberhe11 at gmail.com>
wrote:
> From: Harrison Edward Gerber <gerberhe11 at gmail.com>
>
> See also CID 1399727
>
> Closes #4444
> ---
> cpukit/libmisc/monitor/mon-editor.c | 12 +++++++++++-
> 1 file changed, 11 insertions(+), 1 deletion(-)
>
> diff --git a/cpukit/libmisc/monitor/mon-editor.c
> b/cpukit/libmisc/monitor/mon-editor.c
> index dcea9fcc69..4287b399a5 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');
> --
> 2.25.1
>
> _______________________________________________
> devel mailing list
> devel at rtems.org
> http://lists.rtems.org/mailman/listinfo/devel
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.rtems.org/pipermail/devel/attachments/20210528/970884b8/attachment.html>
More information about the devel
mailing list