Skip to content

Commit

Permalink
Fix minor DOS in rev-list.
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Junio C Hamano committed Oct 3, 2005
1 parent 91dd674 commit c807f77
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion rev-list.c
Expand Up @@ -194,7 +194,17 @@ static void show_commit_list(struct commit_list *list)
die("unknown pending object %s (%s)", sha1_to_hex(obj->sha1), name);
}
while (objects) {
printf("%s %s\n", sha1_to_hex(objects->item->sha1), objects->name);
/* An object with name "foo\n0000000000000000000000000000000000000000"
* can be used confuse downstream git-pack-objects very badly.
*/
const char *ep = strchr(objects->name, '\n');
if (ep) {
printf("%s %.*s\n", sha1_to_hex(objects->item->sha1),
(int) (ep - objects->name),
objects->name);
}
else
printf("%s %s\n", sha1_to_hex(objects->item->sha1), objects->name);
objects = objects->next;
}
}
Expand Down

0 comments on commit c807f77

Please sign in to comment.