Skip to content

Commit 6293ded

Browse files
pcloudsgitster
authored andcommitted
upload-pack: only accept commits from "shallow" line
We only allow cuts at commits, not arbitrary objects. upload-pack will fail eventually in register_shallow if a non-commit is given with a generic error "Object %s is a %s, not a commit". Check it early and give a more accurate error. This should never show up in an ordinary session. It's for buggy clients, or when the user manually edits .git/shallow. Signed-off-by: Nguyễn Thái Ngọc Duy <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 7e20105 commit 6293ded

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

upload-pack.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -603,6 +603,8 @@ static void receive_needs(void)
603603
object = parse_object(sha1);
604604
if (!object)
605605
die("did not find object for %s", line);
606+
if (object->type != OBJ_COMMIT)
607+
die("invalid shallow object %s", sha1_to_hex(sha1));
606608
object->flags |= CLIENT_SHALLOW;
607609
add_object_array(object, NULL, &shallows);
608610
continue;

0 commit comments

Comments
 (0)