summaryrefslogtreecommitdiff
path: root/index-pack.c
diff options
context:
space:
mode:
authorJim Meyering <jim@meyering.net>2006-12-11 18:06:34 (GMT)
committerJunio C Hamano <junkio@cox.net>2006-12-11 22:04:43 (GMT)
commit554a2636f7c5125a83bb07194632445467d46c83 (patch)
tree986dadaab34789ac35b71270d133af0dee9ea5ba /index-pack.c
parentd44c92d6ab4ded7a1960bb0b4a1da0c2fc102b89 (diff)
downloadgit-554a2636f7c5125a83bb07194632445467d46c83.zip
git-554a2636f7c5125a83bb07194632445467d46c83.tar.gz
git-554a2636f7c5125a83bb07194632445467d46c83.tar.bz2
Don't use memcpy when source and dest. buffers may overlap
git-index-pack can call memcpy with overlapping source and destination buffers. The patch below makes it use memmove instead. If you want to demonstrate a failure, add the following two lines + if (input_offset < input_len) + abort (); before the existing memcpy call (shown in the patch below), and then run this: (cd t; sh ./t5500-fetch-pack.sh) Signed-off-by: Jim Meyering <jim@meyering.net> Signed-off-by: Junio C Hamano <junkio@cox.net>
Diffstat (limited to 'index-pack.c')
-rw-r--r--index-pack.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/index-pack.c b/index-pack.c
index 8331d99..6d6c92b 100644
--- a/index-pack.c
+++ b/index-pack.c
@@ -96,7 +96,7 @@ static void flush(void)
if (output_fd >= 0)
write_or_die(output_fd, input_buffer, input_offset);
SHA1_Update(&input_ctx, input_buffer, input_offset);
- memcpy(input_buffer, input_buffer + input_offset, input_len);
+ memmove(input_buffer, input_buffer + input_offset, input_len);
input_offset = 0;
}
}