From: Junio C Hamano <gitster@pobox.com>
To: Jeff King <peff@peff.net>
Cc: Johannes Schindelin <johannes.schindelin@gmx.de>,
Wolfgang Denk <wd@denx.de>,
git@vger.kernel.org
Subject: Re: git error in tag ...: unterminated header
Date: Fri, 26 Jun 2015 10:37:19 -0700 [thread overview]
Message-ID: <xmqqh9puv0a8.fsf@gitster.dls.corp.google.com> (raw)
In-Reply-To: <20150626155248.GB30273@peff.net> (Jeff King's message of "Fri, 26 Jun 2015 11:52:48 -0400")
Jeff King <peff@peff.net> writes:
> On Fri, Jun 26, 2015 at 10:06:20AM +0200, Johannes Schindelin wrote:
>
>> I understood what you were saying, but it still appears too fragile to
>> me to mix functions that assume NUL-terminated strings with an ad-hoc
>> counted string check.
>
> Yeah, I agree. It is not that you cannot make it safe, but that it is
> simply a fragile maintenance burden in the future. I thought we dealt
> with this already with a1e920a (index-pack: terminate object buffers
> with NUL, 2014-12-08), though.
Hmph, that is an interesting point.
It would mean that the require_eoh() can be reduced a bit further.
* It is still a good idea to make sure we do not have NUL in the
header part,
* It can still stop scanning when it finds a blank line (i.e. we do
not care what is in the message part of commit and tag),
* It does not have to insist that a commit or a tag has a blank
line to reject a header-only object.
That would mean the name of the helper needs to change, though.
Perhaps like this?
fsck.c | 13 +++++++++----
1 file changed, 9 insertions(+), 4 deletions(-)
diff --git a/fsck.c b/fsck.c
index 10bcb65..c23e84e 100644
--- a/fsck.c
+++ b/fsck.c
@@ -241,8 +241,8 @@ static int fsck_tree(struct tree *item, int strict, fsck_error error_func)
return retval;
}
-static int require_end_of_header(const void *data, unsigned long size,
- struct object *obj, fsck_error error_func)
+static int verify_headers(const void *data, unsigned long size,
+ struct object *obj, fsck_error error_func)
{
const char *buffer = (const char *)data;
unsigned long i;
@@ -257,8 +257,13 @@ static int require_end_of_header(const void *data, unsigned long size,
return 0;
}
}
-
- return error_func(obj, FSCK_ERROR, "unterminated header");
+ /*
+ * did not find a blank line -- is the last header line
+ * correctly terminated with LF?
+ */
+ if (size && buffer[size - 1] != '\n')
+ return error_func(obj, FSCK_ERROR, "unterminated header");
+ return 0;
}
static int fsck_ident(const char **ident, struct object *obj, fsck_error error_func)
next prev parent reply other threads:[~2015-06-26 17:37 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-06-25 15:51 git error in tag ...: unterminated header Wolfgang Denk
2015-06-25 17:32 ` Junio C Hamano
2015-06-25 20:13 ` Wolfgang Denk
2015-06-25 20:24 ` Junio C Hamano
2015-06-25 21:07 ` Johannes Schindelin
2015-06-25 21:21 ` Junio C Hamano
2015-06-25 22:29 ` Junio C Hamano
2015-06-26 8:06 ` Johannes Schindelin
2015-06-26 15:52 ` Jeff King
2015-06-26 17:37 ` Junio C Hamano [this message]
2015-06-27 8:57 ` Johannes Schindelin
2015-06-27 18:36 ` Junio C Hamano
2015-06-28 18:18 ` [PATCH] fsck: it is OK for a tag and a commit to lack the body Junio C Hamano
2015-06-28 18:21 ` Eric Sunshine
2015-06-29 5:12 ` Johannes Schindelin
2015-06-29 5:42 ` Junio C Hamano
2015-06-29 14:51 ` Johannes Schindelin
2015-06-25 20:48 ` git error in tag ...: unterminated header Junio C Hamano
2015-06-25 17:38 ` Junio C Hamano
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=xmqqh9puv0a8.fsf@gitster.dls.corp.google.com \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
--cc=johannes.schindelin@gmx.de \
--cc=peff@peff.net \
--cc=wd@denx.de \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.