Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJeff King <peff@peff.net>2017-09-21 09:21:40 +0300
committerJunio C Hamano <gitster@pobox.com>2017-09-22 06:49:28 +0300
commitcc0ea7c9e5c3d3bf9623415737b595c9d26b9b6d (patch)
tree037577f7d315c4f7eb67614f4dcf91e32f38f333 /builtin
parent30d005c02014680403b5d35ef274047ab91fa5bd (diff)
cat-file: handle NULL object_context.path
Commit dc944b65f1 (get_sha1_with_context: dynamically allocate oc->path, 2017-05-19) changed the rules that callers must follow for seeing if we parsed a path in the object name. The rules switched from "check if the oc.path buffer is empty" to "check if the oc.path pointer is NULL". But that commit forgot to update some sites in cat_one_file(), meaning we might dereference a NULL pointer. You can see this by making a path-aware request like --textconv without specifying --path, and giving an object name that doesn't have a path in it. Like: git cat-file --textconv HEAD which will reliably segfault. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'builtin')
-rw-r--r--builtin/cat-file.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/builtin/cat-file.c b/builtin/cat-file.c
index 421709517c..b91b167453 100644
--- a/builtin/cat-file.c
+++ b/builtin/cat-file.c
@@ -94,7 +94,7 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name,
return !has_object_file(&oid);
case 'w':
- if (!path[0])
+ if (!path)
die("git cat-file --filters %s: <object> must be "
"<sha1:path>", obj_name);
@@ -104,7 +104,7 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name,
break;
case 'c':
- if (!path[0])
+ if (!path)
die("git cat-file --textconv %s: <object> must be <sha1:path>",
obj_name);