From: Junio C Hamano <gitster@pobox.com>
To: Jeff King <peff@peff.net>
Cc: Shawn Pearce <spearce@spearce.org>, git@vger.kernel.org
Subject: Re: [PATCH] Verify Content-Type from smart HTTP servers
Date: Sun, 03 Feb 2013 23:17:33 -0800 [thread overview]
Message-ID: <7va9rk5z02.fsf@alter.siamese.dyndns.org> (raw)
In-Reply-To: <20130201185827.GA22919@sigill.intra.peff.net> (Jeff King's message of "Fri, 1 Feb 2013 13:58:27 -0500")
Jeff King <peff@peff.net> writes:
> I was specifically thinking of this (on top of your patch):
>
> diff --git a/remote-curl.c b/remote-curl.c
> index e6f3b63..63680a8 100644
> --- a/remote-curl.c
> +++ b/remote-curl.c
> @@ -134,14 +134,12 @@ static struct discovery* discover_refs(const char *service)
> last->buf_alloc = strbuf_detach(&buffer, &last->len);
> last->buf = last->buf_alloc;
>
> - if (maybe_smart && 5 <= last->len && last->buf[4] == '#') {
> + strbuf_addf(&exp, "application/x-%s-advertisement", service);
> + if (maybe_smart && !strbuf_cmp(&exp, &type)) {
> /*
> * smart HTTP response; validate that the service
> * pkt-line matches our request.
> */
> - strbuf_addf(&exp, "application/x-%s-advertisement", service);
> - if (strbuf_cmp(&exp, &type))
> - die("invalid content-type %s", type.buf);
> if (packet_get_line(&buffer, &last->buf, &last->len) <= 0)
> die("%s has invalid packet header", refs_url);
> if (buffer.len && buffer.buf[buffer.len - 1] == '\n')
>
> To just follow the dumb path if we don't get the content-type we expect.
> We may want to keep the '#' format check in addition (packet_get_line
> will check it and die, anyway, but we may want to drop back to
> considering it dumb, just to protect against a badly configured dumb
> server which uses our mime type, but I do not think it likely).
Yeah, but it doesn't cost anything to check, so let's do so.
Does this look good to both of you (relative to Shawn's patch)?
remote-curl.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/remote-curl.c b/remote-curl.c
index e6f3b63..933c69a 100644
--- a/remote-curl.c
+++ b/remote-curl.c
@@ -134,14 +134,14 @@ static struct discovery* discover_refs(const char *service)
last->buf_alloc = strbuf_detach(&buffer, &last->len);
last->buf = last->buf_alloc;
- if (maybe_smart && 5 <= last->len && last->buf[4] == '#') {
+ strbuf_addf(&exp, "application/x-%s-advertisement", service);
+ if (maybe_smart &&
+ (5 <= last->len && last->buf[4] == '#') &&
+ !strbuf_cmp(&exp, &type)) {
/*
* smart HTTP response; validate that the service
* pkt-line matches our request.
*/
- strbuf_addf(&exp, "application/x-%s-advertisement", service);
- if (strbuf_cmp(&exp, &type))
- die("invalid content-type %s", type.buf);
if (packet_get_line(&buffer, &last->buf, &last->len) <= 0)
die("%s has invalid packet header", refs_url);
if (buffer.len && buffer.buf[buffer.len - 1] == '\n')
next prev parent reply other threads:[~2013-02-04 7:18 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2013-01-31 22:09 [PATCH] Verify Content-Type from smart HTTP servers Junio C Hamano
2013-02-01 8:52 ` Jeff King
2013-02-01 18:09 ` Junio C Hamano
2013-02-01 18:58 ` Jeff King
2013-02-04 7:17 ` Junio C Hamano [this message]
2013-02-04 8:38 ` Jeff King
2013-02-04 23:49 ` Shawn Pearce
2013-02-05 0:21 ` Junio C Hamano
2013-02-06 10:24 ` Michael Schubert
2013-02-06 10:39 ` Jeff King
2013-02-06 15:56 ` Junio C Hamano
2013-02-06 22:47 ` Jeff King
[not found] <1359666943-13316-1-git-send-email-spearce@spearce.org>
[not found] ` <7vd2wlf1zf.fsf@alter.siamese.dyndns.org>
2013-01-31 22:36 ` Shawn Pearce
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=7va9rk5z02.fsf@alter.siamese.dyndns.org \
--to=gitster@pobox.com \
--cc=git@vger.kernel.org \
--cc=peff@peff.net \
--cc=spearce@spearce.org \
/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).