Skip to content

Commit

Permalink
Fix cloning (memory corruption)
Browse files Browse the repository at this point in the history
upload-pack would set create_full_pack=1 if nr_has==0, but would ask later
if nr_needs<MAX_NEEDS. If that proves true, it would ignore create_full_pack,
and arguments would be written into unreserved memory.

Signed-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Signed-off-by: Junio C Hamano <junkio@cox.net>
  • Loading branch information
Johannes Schindelin authored and Junio C Hamano committed Oct 26, 2005
1 parent 565ebbf commit b5c367f
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions upload-pack.c
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ static void create_pack_file(void)
close(fd[1]);
*p++ = "git-rev-list";
*p++ = "--objects";
if (MAX_NEEDS <= nr_needs)
if (create_full_pack || MAX_NEEDS <= nr_needs)
*p++ = "--all";
else {
for (i = 0; i < nr_needs; i++) {
Expand All @@ -69,12 +69,13 @@ static void create_pack_file(void)
buf += 41;
}
}
for (i = 0; i < nr_has; i++) {
*p++ = buf;
*buf++ = '^';
memcpy(buf, sha1_to_hex(has_sha1[i]), 41);
buf += 41;
}
if (!create_full_pack)
for (i = 0; i < nr_has; i++) {
*p++ = buf;
*buf++ = '^';
memcpy(buf, sha1_to_hex(has_sha1[i]), 41);
buf += 41;
}
*p++ = NULL;
execvp("git-rev-list", argv);
die("git-upload-pack: unable to exec git-rev-list");
Expand Down

0 comments on commit b5c367f

Please sign in to comment.