зеркало из https://github.com/microsoft/git.git
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>
This commit is contained in:
Родитель
30d005c020
Коммит
cc0ea7c9e5
|
@ -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);
|
||||
|
||||
|
|
|
@ -51,6 +51,11 @@ test_expect_success '--path=<path> complains without --textconv/--filters' '
|
|||
grep "path.*needs.*filters" err
|
||||
'
|
||||
|
||||
test_expect_success '--textconv/--filters complain without path' '
|
||||
test_must_fail git cat-file --textconv HEAD &&
|
||||
test_must_fail git cat-file --filters HEAD
|
||||
'
|
||||
|
||||
test_expect_success 'cat-file --textconv --batch works' '
|
||||
sha1=$(git rev-parse -q --verify HEAD:world.txt) &&
|
||||
test_config diff.txt.textconv "tr A-Za-z N-ZA-Mn-za-m <" &&
|
||||
|
|
Загрузка…
Ссылка в новой задаче