From 6293ded348a918e5644d286dcd8b05044097c27d Mon Sep 17 00:00:00 2001 From: =?utf8?q?Nguy=E1=BB=85n=20Th=C3=A1i=20Ng=E1=BB=8Dc=20Duy?= Date: Tue, 8 Jan 2013 18:32:36 +0700 Subject: [PATCH] upload-pack: only accept commits from "shallow" line MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit 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 Signed-off-by: Junio C Hamano --- upload-pack.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/upload-pack.c b/upload-pack.c index 2e90ccb74f..8c715354e7 100644 --- a/upload-pack.c +++ b/upload-pack.c @@ -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; -- 2.11.4.GIT