[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 1/6] readline: avoid memcpy() of overlapping regions
From: |
Stefan Hajnoczi |
Subject: |
[Qemu-devel] [PATCH 1/6] readline: avoid memcpy() of overlapping regions |
Date: |
Fri, 11 Jan 2013 10:18:01 +0100 |
From: Nickolai Zeldovich <address@hidden>
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 <address@hidden>
Reviewed-by: Richard Henderson <address@hidden>
Signed-off-by: Stefan Hajnoczi <address@hidden>
---
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
- [Qemu-devel] [PULL 0/6] Trivial patches for 5 to 11 January 2013, Stefan Hajnoczi, 2013/01/11
- [Qemu-devel] [PATCH 2/6] configure: Fix comment (copy+paste bug), Stefan Hajnoczi, 2013/01/11
- [Qemu-devel] [PATCH 3/6] qga/channel-posix.c: Explicitly include string.h, Stefan Hajnoczi, 2013/01/11
- [Qemu-devel] [PATCH 1/6] readline: avoid memcpy() of overlapping regions,
Stefan Hajnoczi <=
- [Qemu-devel] [PATCH 5/6] Replace remaining gmtime, localtime by gmtime_r, localtime_r, Stefan Hajnoczi, 2013/01/11
- [Qemu-devel] [PATCH 4/6] savevm: Remove MinGW specific code which is no longer needed, Stefan Hajnoczi, 2013/01/11
- [Qemu-devel] [PATCH 6/6] hw/pc.c: Fix converting of ioport_register* to MemoryRegion, Stefan Hajnoczi, 2013/01/11
- Re: [Qemu-devel] [PATCH 6/6] hw/pc.c: Fix converting of ioport_register* to MemoryRegion, Julien Grall, 2013/01/11
- Re: [Qemu-devel] [PULL 0/6] Trivial patches for 5 to 11 January 2013, Anthony Liguori, 2013/01/11