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

Fix minor DOS in rev-list.

A carefully crafted pathname can be used to disrupt downstream git-pack-objects that uses 'git-rev-list --objects' output. Prevent this. Signed-off-by: Junio C Hamano <junkio@cox.net>

Junio C Hamano committed Oct 2, 2005 at 17:29 UTC c807f771947de65dceb22960d1a093d702f42105
1 file changed +11 -1
rev-list.c
+11 -1
@@ -194,7 +194,17 @@ static void show_commit_list(struct commit_list *list)
194 die("unknown pending object %s (%s)", sha1_to_hex(obj->sha1), name);
195 }
196 while (objects) {
197 - printf("%s %s\n", sha1_to_hex(objects->item->sha1), objects->name);
197 + /* An object with name "foo\n0000000000000000000000000000000000000000"
198 + * can be used confuse downstream git-pack-objects very badly.
199 + */
200 + const char *ep = strchr(objects->name, '\n');
201 + if (ep) {
202 + printf("%s %.*s\n", sha1_to_hex(objects->item->sha1),
203 + (int) (ep - objects->name),
204 + objects->name);
205 + }
206 + else
207 + printf("%s %s\n", sha1_to_hex(objects->item->sha1), objects->name);
208 objects = objects->next;
209 }
210 }