]> git.ipfire.org Git - thirdparty/git.git/commitdiff
remote-curl: tighten "version 2" check for smart-http
authorJeff King <peff@peff.net>
Wed, 6 Feb 2019 19:18:58 +0000 (14:18 -0500)
committerJunio C Hamano <gitster@pobox.com>
Wed, 6 Feb 2019 20:20:22 +0000 (12:20 -0800)
In a v2 smart-http conversation, the server should reply to our initial
request with a pkt-line saying "version 2". We check that with
starts_with(), but really that should be the only thing in that packet.
A response of "version 20" should not match.

Let's tighten this check to use strcmp(). Note that we don't need to
worry about a trailing newline here, because the ptk-line code will have
chomped it for us already.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
remote-curl.c

index c78ba83744451f50ee1a7db65a38d3cc0e984b2a..bb7421023ba584d59592124aa6f3ff2028bc5356 100644 (file)
@@ -374,7 +374,7 @@ static void check_smart_http(struct discovery *d, const char *service,
                d->len = reader.src_len;
                d->proto_git = 1;
 
-       } else if (starts_with(reader.line, "version 2")) {
+       } else if (!strcmp(reader.line, "version 2")) {
                /*
                 * v2 smart http; do not consume version packet, which will
                 * be handled elsewhere.