From: Stefan Hajnoczi <stefanha@redhat.com>
To: qemu-devel@nongnu.org
Cc: Anthony Liguori <aliguori@us.ibm.com>,
Nickolai Zeldovich <nickolai@csail.mit.edu>,
Stefan Hajnoczi <stefanha@redhat.com>
Subject: [Qemu-devel] [PATCH 1/6] readline: avoid memcpy() of overlapping regions
Date: Fri, 11 Jan 2013 10:18:01 +0100 [thread overview]
Message-ID: <1357895886-14283-2-git-send-email-stefanha@redhat.com> (raw)
In-Reply-To: <1357895886-14283-1-git-send-email-stefanha@redhat.com>
From: Nickolai Zeldovich <nickolai@csail.mit.edu>
memcpy() for overlapping regions is undefined behavior; use memmove()
instead in readline_hist_add().
[Keep tab characters since surrounding code still uses them -- Stefan]
Signed-off-by: Nickolai Zeldovich <nickolai@csail.mit.edu>
Reviewed-by: Richard Henderson <rth@twiddle.net>
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
---
readline.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/readline.c b/readline.c
index 5fc9643..a0c9638 100644
--- a/readline.c
+++ b/readline.c
@@ -248,8 +248,8 @@ static void readline_hist_add(ReadLineState *rs, const char *cmdline)
if (idx == READLINE_MAX_CMDS) {
/* Need to get one free slot */
free(rs->history[0]);
- memcpy(rs->history, &rs->history[1],
- (READLINE_MAX_CMDS - 1) * sizeof(char *));
+ memmove(rs->history, &rs->history[1],
+ (READLINE_MAX_CMDS - 1) * sizeof(char *));
rs->history[READLINE_MAX_CMDS - 1] = NULL;
idx = READLINE_MAX_CMDS - 1;
}
--
1.8.0.2
next prev parent reply other threads:[~2013-01-11 9:18 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-01-11 9:18 [Qemu-devel] [PULL 0/6] Trivial patches for 5 to 11 January 2013 Stefan Hajnoczi
2013-01-11 9:18 ` Stefan Hajnoczi [this message]
2013-01-11 9:18 ` [Qemu-devel] [PATCH 2/6] configure: Fix comment (copy+paste bug) Stefan Hajnoczi
2013-01-11 9:18 ` [Qemu-devel] [PATCH 3/6] qga/channel-posix.c: Explicitly include string.h Stefan Hajnoczi
2013-01-11 9:18 ` [Qemu-devel] [PATCH 4/6] savevm: Remove MinGW specific code which is no longer needed Stefan Hajnoczi
2013-01-11 9:18 ` [Qemu-devel] [PATCH 5/6] Replace remaining gmtime, localtime by gmtime_r, localtime_r Stefan Hajnoczi
2013-01-11 9:18 ` [Qemu-devel] [PATCH 6/6] hw/pc.c: Fix converting of ioport_register* to MemoryRegion Stefan Hajnoczi
2013-01-11 11:50 ` Andreas Färber
2013-01-11 14:53 ` Julien Grall
2013-01-11 15:17 ` Andreas Färber
2013-01-11 15:04 ` Julien Grall
2013-01-11 16:46 ` [Qemu-devel] [PULL 0/6] Trivial patches for 5 to 11 January 2013 Anthony Liguori
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1357895886-14283-2-git-send-email-stefanha@redhat.com \
--to=stefanha@redhat.com \
--cc=aliguori@us.ibm.com \
--cc=nickolai@csail.mit.edu \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).