diff options
author | Nickolai Zeldovich <nickolai@csail.mit.edu> | 2013-01-07 15:38:39 -0500 |
---|---|---|
committer | Stefan Hajnoczi <stefanha@redhat.com> | 2013-01-08 10:00:26 +0100 |
commit | 7682e8580722f951559f372ba3d2b6170fdbe734 (patch) | |
tree | 204b296a188a9ab4caedb029191b3e5904f52eff /readline.c | |
parent | 8e4a424b305e29dc0e454f52df3b35577f342975 (diff) | |
download | qemu-7682e8580722f951559f372ba3d2b6170fdbe734.tar.gz qemu-7682e8580722f951559f372ba3d2b6170fdbe734.tar.bz2 qemu-7682e8580722f951559f372ba3d2b6170fdbe734.zip |
readline: avoid memcpy() of overlapping regions
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>
Diffstat (limited to 'readline.c')
-rw-r--r-- | readline.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/readline.c b/readline.c index 5fc9643c2b..a0c9638e4d 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; } |