qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH] readline: avoid memcpy() of overlapping regions
@ 2013-01-07 20:38 Nickolai Zeldovich
  2013-01-07 21:36 ` Richard Henderson
  2013-01-08  9:03 ` Stefan Hajnoczi
  0 siblings, 2 replies; 10+ messages in thread
From: Nickolai Zeldovich @ 2013-01-07 20:38 UTC (permalink / raw)
  To: qemu-devel; +Cc: Nickolai Zeldovich

memcpy() for overlapping regions is undefined behavior; use memmove()
instead in readline_hist_add().

Signed-off-by: Nickolai Zeldovich <nickolai@csail.mit.edu>
---
 readline.c |    4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/readline.c b/readline.c
index 5fc9643..aeccc7b 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.7.10.4

^ permalink raw reply related	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2013-01-19  9:05 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-01-07 20:38 [Qemu-devel] [PATCH] readline: avoid memcpy() of overlapping regions Nickolai Zeldovich
2013-01-07 21:36 ` Richard Henderson
2013-01-08  9:03 ` Stefan Hajnoczi
2013-01-09 20:43   ` Blue Swirl
2013-01-10 12:43     ` Stefan Hajnoczi
2013-01-12 10:46       ` Blue Swirl
2013-01-14  9:09         ` Stefan Hajnoczi
2013-01-17 20:13           ` Blue Swirl
2013-01-18 11:04             ` Stefan Hajnoczi
2013-01-19  9:04               ` Blue Swirl

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).