OSDN Git Service

upload-pack: only accept commits from "shallow" line
authorNguyễn Thái Ngọc Duy <pclouds@gmail.com>
Tue, 8 Jan 2013 11:32:36 +0000 (18:32 +0700)
committerJunio C Hamano <gitster@pobox.com>
Tue, 8 Jan 2013 17:28:00 +0000 (09:28 -0800)
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 <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
upload-pack.c

index 2e90ccb..8c71535 100644 (file)
@@ -603,6 +603,8 @@ static void receive_needs(void)
                        object = parse_object(sha1);
                        if (!object)
                                die("did not find object for %s", line);
+                       if (object->type != OBJ_COMMIT)
+                               die("invalid shallow object %s", sha1_to_hex(sha1));
                        object->flags |= CLIENT_SHALLOW;
                        add_object_array(object, NULL, &shallows);
                        continue;