Andrew's git
/
gitweb.git
/ diff
summary
|
log
|
commit
| diff |
tree
commit
grep
author
committer
pickaxe
?
re
Don't use memcpy when source and dest. buffers may overlap
author
Jim Meyering
<jim@meyering.net>
Mon, 11 Dec 2006 18:06:34 +0000
(19:06 +0100)
committer
Junio C Hamano
<junkio@cox.net>
Mon, 11 Dec 2006 22:04:43 +0000
(14:04 -0800)
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>
index-pack.c
patch
|
blob
|
history
raw
|
patch
| inline |
side by side
(parent:
d44c92d
)
diff --git
a/index-pack.c
b/index-pack.c
index 8331d99a62a457cb341a834792aedf5de9c5625f..6d6c92bf14803923f4c98678ae682aef4d41d3ab 100644
(file)
--- 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);
- mem
cpy
(input_buffer, input_buffer + input_offset, input_len);
+ mem
move
(input_buffer, input_buffer + input_offset, input_len);
input_offset = 0;
}
}