@matheusbsbs / matheus-bagliano / commits / 1442171bc9
Fork 0

fix overlapping memcpy in normalize_absolute_path

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 <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Jeff King committed Oct 23, 2008 at 04:32 UTC 1442171bc913a9cddae5c6ad0d0a4be3a1ca86e8
1 file changed +1 -1
path.c
+1 -1
@@ -348,7 +348,7 @@ int normalize_absolute_path(char *buf, const char *path)
348 goto next;
349 }
350
351 - memcpy(dst, comp_start, comp_len);
351 + memmove(dst, comp_start, comp_len);
352 dst += comp_len;
353 next:
354 comp_start = comp_end;