From: Stefan Beller <sbeller@google.com>
To: gitster@pobox.com
Cc: git@vger.kernel.org, Stefan Beller <sbeller@google.com>
Subject: [PATCH] commit parsing: replace unchecked parse_commit by parse_commit_or_die
Date: Thu, 20 Oct 2016 11:06:29 -0700 [thread overview]
Message-ID: <20161020180629.11955-1-sbeller@google.com> (raw)
In-Reply-To: <xmqqoa2ehp5u.fsf@gitster.mtv.corp.google.com>
The reason parse_commit() would fail at these points would be because
the repository is corrupt.
This was noticed by coverity.
Signed-off-by: Stefan Beller <sbeller@google.com>
---
developed on pu as that's where coverity spotted it.
I have no overview if these areas are being worked on. (It may clash
with at least jc/merge-base-fp-only)
Thanks,
Stefan
builtin/blame.c | 2 +-
builtin/describe.c | 4 ++--
builtin/name-rev.c | 2 +-
builtin/show-branch.c | 4 ++--
commit.c | 2 +-
fetch-pack.c | 2 +-
6 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/builtin/blame.c b/builtin/blame.c
index 992a79c..3b8564c 100644
--- a/builtin/blame.c
+++ b/builtin/blame.c
@@ -1801,7 +1801,7 @@ static void assign_blame(struct scoreboard *sb, int opt)
* so hold onto it in the meantime.
*/
origin_incref(suspect);
- parse_commit(commit);
+ parse_commit_or_die(commit);
if (reverse ||
(!(commit->object.flags & UNINTERESTING) &&
!(revs->max_age != -1 && commit->date < revs->max_age)))
diff --git a/builtin/describe.c b/builtin/describe.c
index 01490a1..8299b16 100644
--- a/builtin/describe.c
+++ b/builtin/describe.c
@@ -199,7 +199,7 @@ static unsigned long finish_depth_computation(
best->depth++;
while (parents) {
struct commit *p = parents->item;
- parse_commit(p);
+ parse_commit_or_die(p);
if (!(p->object.flags & SEEN))
commit_list_insert_by_date(p, list);
p->object.flags |= c->object.flags;
@@ -322,7 +322,7 @@ static void describe(const char *arg, int last_one)
}
while (parents) {
struct commit *p = parents->item;
- parse_commit(p);
+ parse_commit_or_die(p);
if (!(p->object.flags & SEEN))
commit_list_insert_by_date(p, &list);
p->object.flags |= c->object.flags;
diff --git a/builtin/name-rev.c b/builtin/name-rev.c
index cd89d48..92c3316 100644
--- a/builtin/name-rev.c
+++ b/builtin/name-rev.c
@@ -29,7 +29,7 @@ static void name_rev(struct commit *commit,
struct commit_list *parents;
int parent_number = 1;
- parse_commit(commit);
+ parse_commit_or_die(commit);
if (commit->date < cutoff)
return;
diff --git a/builtin/show-branch.c b/builtin/show-branch.c
index 974f340..fd911b5 100644
--- a/builtin/show-branch.c
+++ b/builtin/show-branch.c
@@ -218,7 +218,7 @@ static void join_revs(struct commit_list **list_p,
parents = parents->next;
if ((this_flag & flags) == flags)
continue;
- parse_commit(p);
+ parse_commit_or_die(p);
if (mark_seen(p, seen_p) && !still_interesting)
extra--;
p->object.flags |= flags;
@@ -835,7 +835,7 @@ int cmd_show_branch(int ac, const char **av, const char *prefix)
if (!commit)
die(_("cannot find commit %s (%s)"),
ref_name[num_rev], oid_to_hex(&revkey));
- parse_commit(commit);
+ parse_commit_or_die(commit);
mark_seen(commit, &seen);
/* rev#0 uses bit REV_SHIFT, rev#1 uses bit REV_SHIFT+1,
diff --git a/commit.c b/commit.c
index b9c0c81..5b23eaf 100644
--- a/commit.c
+++ b/commit.c
@@ -910,7 +910,7 @@ static void mark_redundant(struct commit **array, int cnt)
ALLOC_ARRAY(filled_index, cnt - 1);
for (i = 0; i < cnt; i++)
- parse_commit(array[i]);
+ parse_commit_or_die(array[i]);
for (i = 0; i < cnt; i++) {
struct commit_list *common;
diff --git a/fetch-pack.c b/fetch-pack.c
index cb45c34..8b4ab47 100644
--- a/fetch-pack.c
+++ b/fetch-pack.c
@@ -159,7 +159,7 @@ static const unsigned char *get_rev(void)
return NULL;
commit = prio_queue_get(&rev_list);
- parse_commit(commit);
+ parse_commit_or_die(commit);
parents = commit->parents;
commit->object.flags |= POPPED;
--
2.10.1.448.g862ec83.dirty
next prev parent reply other threads:[~2016-10-20 18:06 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <580893d5a4736_4ed37b53181837@ss1435.mail>
2016-10-20 17:05 ` Fwd: New Defects reported by Coverity Scan for git Stefan Beller
2016-10-20 17:50 ` Junio C Hamano
2016-10-20 17:58 ` Stefan Beller
2016-10-20 18:05 ` Junio C Hamano
2016-10-20 18:06 ` Stefan Beller [this message]
2016-10-20 18:13 ` Stefan Beller
2016-10-20 21:42 ` Jeff King
2016-10-20 22:07 ` Junio C Hamano
2016-10-20 21:40 ` 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
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20161020180629.11955-1-sbeller@google.com \
--to=sbeller@google.com \
--cc=git@vger.kernel.org \
--cc=gitster@pobox.com \
/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.
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 NNTP newsgroup(s).