Skip to content

Commit

Permalink
fix overlapping memcpy in normalize_absolute_path
Browse files Browse the repository at this point in the history
The comments for normalize_absolute_path explicitly claim
that the source and destination buffers may be the same
(though they may not otherwise overlap). Thus the call to
memcpy may involve copying overlapping data, and memmove
should be used instead.

This fixes a valgrind error in t1504.

Signed-off-by: Jeff King <[email protected]>
Signed-off-by: Junio C Hamano <[email protected]>
  • Loading branch information
peff authored and gitster committed Nov 2, 2008
1 parent 421b488 commit 1442171
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion path.c
Original file line number Diff line number Diff line change
Expand Up @@ -348,7 +348,7 @@ int normalize_absolute_path(char *buf, const char *path)
goto next;
}

memcpy(dst, comp_start, comp_len);
memmove(dst, comp_start, comp_len);
dst += comp_len;
next:
comp_start = comp_end;
Expand Down

0 comments on commit 1442171

Please sign in to comment.