From: Jonathan Nieder <jrnieder@gmail.com>
To: Jeff King <peff@peff.net>
Cc: git@vger.kernel.org
Subject: Re: [PATCH 1/4] cat-file: handle NULL object_context.path
Date: Thu, 21 Sep 2017 17:58:57 -0700 [thread overview]
Message-ID: <20170922005857.GK27425@aiede.mtv.corp.google.com> (raw)
In-Reply-To: <20170921062140.cyfjv7rfuppqpblh@sigill.intra.peff.net>
Jeff King wrote:
> 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>
> ---
> builtin/cat-file.c | 4 ++--
> t/t8010-cat-file-filters.sh | 5 +++++
> 2 files changed, 7 insertions(+), 2 deletions(-)
Yikes. Commit dc944b65f1 even touched this function, so we reviewers
have no excuse for not having found it.
Technically this changes the behavior of cat-file --path='', but I
don't think that matters.
Do other GET_SHA1_RECORD_PATH callers need similar treatment?
* builtin/grep.c appears to do the right thing (it stores NULL in
list, so it passes NULL to grep_object, which calls grep_oid, which
calls grep_source_init, which stores NULL for the grep machinery
that is able to cope with a NULL).
* builtin/log.c is correctly updated as part of the patch.
Those are the only other callers. So we're safe. *phew*
Reviewed-by: Jonathan Nieder <jrnieder@gmail.com>
next prev parent reply other threads:[~2017-09-22 1:00 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-09-21 6:20 [PATCH 0/4] appeasing -Wimplicit-fallthrough Jeff King
2017-09-21 6:21 ` [PATCH 1/4] cat-file: handle NULL object_context.path Jeff King
2017-09-22 0:58 ` Jonathan Nieder [this message]
2017-09-21 6:22 ` [PATCH 2/4] test-line-buffer: simplify command parsing Jeff King
2017-09-22 3:47 ` Junio C Hamano
2017-09-21 6:23 ` [PATCH 3/4] curl_trace(): eliminate switch fallthrough Jeff King
2017-09-21 6:25 ` [PATCH 4/4] consistently use "fallthrough" comments in switches Jeff King
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
List information: http://vger.kernel.org/majordomo-info.html
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20170922005857.GK27425@aiede.mtv.corp.google.com \
--to=jrnieder@gmail.com \
--cc=git@vger.kernel.org \
--cc=peff@peff.net \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).