@matheusbsbs / matheus-bagliano / commits / b5c367f75c
Fork 0

Fix cloning (memory corruption)

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>

Johannes Schindelin committed Oct 26, 2005 at 16:18 UTC b5c367f75c2990650119749a1add5216871ca47a
1 file changed +8 -7
upload-pack.c
+8 -7
@@ -60,7 +60,7 @@ static void create_pack_file(void)
60 close(fd[1]);
61 *p++ = "git-rev-list";
62 *p++ = "--objects";
63 - if (MAX_NEEDS <= nr_needs)
63 + if (create_full_pack || MAX_NEEDS <= nr_needs)
64 *p++ = "--all";
65 else {
66 for (i = 0; i < nr_needs; i++) {
@@ -69,12 +69,13 @@ static void create_pack_file(void)
69 buf += 41;
70 }
71 }
72 - for (i = 0; i < nr_has; i++) {
73 - *p++ = buf;
74 - *buf++ = '^';
75 - memcpy(buf, sha1_to_hex(has_sha1[i]), 41);
76 - buf += 41;
77 - }
72 + if (!create_full_pack)
73 + for (i = 0; i < nr_has; i++) {
74 + *p++ = buf;
75 + *buf++ = '^';
76 + memcpy(buf, sha1_to_hex(has_sha1[i]), 41);
77 + buf += 41;
78 + }
79 *p++ = NULL;
80 execvp("git-rev-list", argv);
81 die("git-upload-pack: unable to exec git-rev-list");