summaryrefslogtreecommitdiff
path: root/builtin/hash-object.c
diff options
context:
space:
mode:
authorNguyễn Thái Ngọc Duy <pclouds@gmail.com>2011-02-05 10:52:21 (GMT)
committerJunio C Hamano <gitster@pobox.com>2011-02-07 23:05:25 (GMT)
commitc879daa23729547fb28aa7e8783c5e4e619a9e7c (patch)
tree0c73b7150204bf11f9ca90683b36e3229fb22279 /builtin/hash-object.c
parentcf7b1cad0e8b024538de975dff5893262cec72d7 (diff)
downloadgit-c879daa23729547fb28aa7e8783c5e4e619a9e7c.zip
git-c879daa23729547fb28aa7e8783c5e4e619a9e7c.tar.gz
git-c879daa23729547fb28aa7e8783c5e4e619a9e7c.tar.bz2
Make hash-object more robust against malformed objects
Commits, trees and tags have structure. Don't let users feed git with malformed ones. Sooner or later git will die() when encountering them. Note that this patch does not check semantics. A tree that points to non-existent objects is perfectly OK (and should be so, users may choose to add commit first, then its associated tree for example). Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin/hash-object.c')
-rw-r--r--builtin/hash-object.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/builtin/hash-object.c b/builtin/hash-object.c
index 080af1a..c90acdd 100644
--- a/builtin/hash-object.c
+++ b/builtin/hash-object.c
@@ -15,7 +15,7 @@ static void hash_fd(int fd, const char *type, int write_object, const char *path
struct stat st;
unsigned char sha1[20];
if (fstat(fd, &st) < 0 ||
- index_fd(sha1, fd, &st, write_object, type_from_string(type), path))
+ index_fd(sha1, fd, &st, write_object, type_from_string(type), path, 1))
die(write_object
? "Unable to add %s to database"
: "Unable to hash %s", path);