From patchwork Tue May 19 10:53:54 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denton Liu X-Patchwork-Id: 11557431 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3B6C214C0 for ; Tue, 19 May 2020 10:54:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1A233207D3 for ; Tue, 19 May 2020 10:54:16 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="UCTbFZTN" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728733AbgESKyP (ORCPT ); Tue, 19 May 2020 06:54:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51304 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726494AbgESKyN (ORCPT ); Tue, 19 May 2020 06:54:13 -0400 Received: from mail-qk1-x741.google.com (mail-qk1-x741.google.com [IPv6:2607:f8b0:4864:20::741]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 772F1C061A0C for ; Tue, 19 May 2020 03:54:12 -0700 (PDT) Received: by mail-qk1-x741.google.com with SMTP id 190so14349318qki.1 for ; Tue, 19 May 2020 03:54:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=hxclQLbBSUal7Gbbwbp5s1iq2t0j8ZwEi3scAMADpQc=; b=UCTbFZTNr/KeWnaMtBYPzBcv5kAh2e4QTfREajiHyfDk4LSJE7zIWNWD0bRHf7q6bV rbzMO+5gh6iuu66Z0kL0Pw54uWPLOM13vluv+vZdcKRkGMmyMQaX2skKRxCeNOq44Jub IhxZxXh/2j9jSp8cr9kL3sUUHE0wlAjv4amL/GCw1VBLop74GO1c84PtZtkvFnCSk+gu FP4eQuh2Y0B3R4iv70yXbWn7VKNPwBpFQsqm91H5TnRKxY4aTs8uRE0w9Fx5jjk5+gu9 heBLV7S4l33VByBLJtRyhJX/1m0m3sUHHmahbMtFLbTEl+9LGciW4Ag2uj3l1YgW0EZ6 6dCg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=hxclQLbBSUal7Gbbwbp5s1iq2t0j8ZwEi3scAMADpQc=; b=l8fycAAgtx8idMSnCIf3+GyEuEIgODHU8D1OgLbb2PmeevA83te5X8Kh+kb4nV3ZNe 87+6xx9+05k4U0Y0TlJB1G8sXuhbm0JkU79SnqRuOYQfoaooKSA1vwc2Sr+NJNtoDP/k o9md6sqi0bIS6AWdsQwJyFJGjXL2rjYZizlo881Ur+YpHaeU404bA4R3DSfwWFEiAU9n w0XUVmlWPZbuL0xOzxgS1EykQMm+BcNowFda3LzmUAYRuW8DANj7nWwH7RFck2nnDJQ4 ESimfP0MzPHm0VkewU4P/CkKKjlQUKwxNwDc1lCTYpU75De0oPKtbZNywZxPQ8SVc1Ix PSzA== X-Gm-Message-State: AOAM5317SycxwUptSdE5di4KTZB2Zq4iyLxLxSkmrFnOc4UOpMJyjldo 1iE2BzutALSLNJZ9P0of2OKStRZC X-Google-Smtp-Source: ABdhPJxCFep8oBlfw4YVXWUiBox8V7caJW/y6ZBAO1REtE/OelIIN211IMq7HDlt6RJKaQfu2Fyhuw== X-Received: by 2002:a05:620a:1479:: with SMTP id j25mr21164725qkl.110.1589885651386; Tue, 19 May 2020 03:54:11 -0700 (PDT) Received: from archbookpro.localdomain (CPE18593399858a-CM185933998587.cpe.net.cable.rogers.com. [174.112.65.113]) by smtp.gmail.com with ESMTPSA id c63sm10177775qkf.131.2020.05.19.03.54.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 May 2020 03:54:10 -0700 (PDT) From: Denton Liu To: Git Mailing List Cc: Jeff King , Eric Sunshine , Junio C Hamano Subject: [PATCH v3 1/7] remote-curl: fix typo Date: Tue, 19 May 2020 06:53:54 -0400 Message-Id: X-Mailer: git-send-email 2.26.2.706.g87896c9627 In-Reply-To: References: MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Signed-off-by: Denton Liu --- remote-curl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/remote-curl.c b/remote-curl.c index 1c9aa3d0ab..6844708f38 100644 --- a/remote-curl.c +++ b/remote-curl.c @@ -643,7 +643,7 @@ static size_t rpc_out(void *ptr, size_t eltsize, return 0; } /* - * If avail is non-zerp, the line length for the flush still + * If avail is non-zero, the line length for the flush still * hasn't been fully sent. Proceed with sending the line * length. */ From patchwork Tue May 19 10:53:55 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denton Liu X-Patchwork-Id: 11557433 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 87F31739 for ; Tue, 19 May 2020 10:54:16 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 65D4E207D3 for ; Tue, 19 May 2020 10:54:16 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Hw8pHbIv" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728738AbgESKyP (ORCPT ); Tue, 19 May 2020 06:54:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51306 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728686AbgESKyN (ORCPT ); Tue, 19 May 2020 06:54:13 -0400 Received: from mail-qk1-x743.google.com (mail-qk1-x743.google.com [IPv6:2607:f8b0:4864:20::743]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A806AC05BD09 for ; Tue, 19 May 2020 03:54:13 -0700 (PDT) Received: by mail-qk1-x743.google.com with SMTP id y22so14315791qki.3 for ; Tue, 19 May 2020 03:54:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=RFan4SxK9IYM8JwqCj6zEhODFuYsjYeefwOc2HlU8gU=; b=Hw8pHbIvar+sKphWTUB0L8AWUvPE5ye8aKnf32nmfd4ETUDnHEn+t5BQERc1Jp0ACD k0xxmrhAQhlt65lyVKHNWNZKZq0juO7Mde2xc3JwQC7N2dtyEbglWnJNCbSwLfMmsMe+ SGetzbLoBSdGcsSQVo5Uwu+uhYjCIhRtuRTsK+aZ5gPkI/YvGOsIGhaDLmSOXR3ycnkp mj2NQIzG59bv+Dbjpbz2r/3CpdOezvwGOVam9117BSBmpcy5KbOtq98Y27kvez8egTW2 EygpFcoDhi9YVVXUkNLtTOMpF2bdf3VEH6IF/AnADO+ETHysb+wBEMwuwYLPpeH84Dhh XSpA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=RFan4SxK9IYM8JwqCj6zEhODFuYsjYeefwOc2HlU8gU=; b=Y+hS0SRqkYZRI4dYhqmcVzkOS0B5f2rWpTsMgZ042UupkopiYWsb0X47VBYYAGvGqx bYw3wAeC2oxVix9wXGs+PKSN/7lFrfKDSJHVm7AHohRR9LjLeIzX10ciHo9g7lDd5st+ SuP7Ictx/sqyiDBXleDz5KTwYKMFECs1aiBTyUPWc5X43SHTGkSxOK1dIDXBlycqj0ID AmBPDVC2IzTsdTrXDs+GI6GNpWr8WI4Aq2DeBPOiRKlF6T1u/ICuoN7dtfsPISt9+veo DOGRSx9kdTHWtZlTREM2OZErIFsv80aL+rslTBrUUlTk0oToXo4vi8CKbEwIHh/9QvMB 1dbw== X-Gm-Message-State: AOAM531fbBKOZvnrKxr2yBvYtTwT9o4PkkKGxbe2YmziocjCeki1TcNd /8WSYBb1d1qH6m+75ZjXtLgI41Dx X-Google-Smtp-Source: ABdhPJxWofqHXFBrsJTpOB9uEcAm7lSaHjSB95RTtNx/3wSwIbQC5rP2VLhJkSxe8/k80cJk/aNRvQ== X-Received: by 2002:a05:620a:1524:: with SMTP id n4mr20737960qkk.490.1589885652778; Tue, 19 May 2020 03:54:12 -0700 (PDT) Received: from archbookpro.localdomain (CPE18593399858a-CM185933998587.cpe.net.cable.rogers.com. [174.112.65.113]) by smtp.gmail.com with ESMTPSA id c63sm10177775qkf.131.2020.05.19.03.54.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 May 2020 03:54:12 -0700 (PDT) From: Denton Liu To: Git Mailing List Cc: Jeff King , Eric Sunshine , Junio C Hamano Subject: [PATCH v3 2/7] remote-curl: remove label indentation Date: Tue, 19 May 2020 06:53:55 -0400 Message-Id: X-Mailer: git-send-email 2.26.2.706.g87896c9627 In-Reply-To: References: MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org In the codebase, labels are aligned to the leftmost column. Remove the space-indentation from `free_specs:` to conform to this. Signed-off-by: Denton Liu --- remote-curl.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/remote-curl.c b/remote-curl.c index 6844708f38..da3e07184a 100644 --- a/remote-curl.c +++ b/remote-curl.c @@ -1276,7 +1276,7 @@ static void parse_push(struct strbuf *buf) if (ret) exit(128); /* error already reported */ - free_specs: +free_specs: argv_array_clear(&specs); } From patchwork Tue May 19 10:53:56 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denton Liu X-Patchwork-Id: 11557437 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id F3922912 for ; Tue, 19 May 2020 10:54:17 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DB65C20758 for ; Tue, 19 May 2020 10:54:17 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="Q0gI0XgY" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728740AbgESKyR (ORCPT ); Tue, 19 May 2020 06:54:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51314 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728728AbgESKyP (ORCPT ); Tue, 19 May 2020 06:54:15 -0400 Received: from mail-qk1-x741.google.com (mail-qk1-x741.google.com [IPv6:2607:f8b0:4864:20::741]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2FB70C05BD0A for ; Tue, 19 May 2020 03:54:15 -0700 (PDT) Received: by mail-qk1-x741.google.com with SMTP id i14so14257764qka.10 for ; Tue, 19 May 2020 03:54:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=YBnhe/GsDhR26I4VumrbqZP6HIDql2w1szyn7XtSRyc=; b=Q0gI0XgYGz+wfBexko8lTJyBd9XselxmlDqo1yuyq8ASC5LQlM1ZkwOUAeBpAsNUXa NPOp9NR1Cb2cmrVpvBlPwiwzkvPLQdgI/9OWl7MBBhXlw966XnSZpbcaBHcOHyagnc5M +nkSwwHJAZZGYf+2AbUwAmOZCstZ1OPGQQv6pxurr+NBMk45QT2nf6OP0uMEmL6KCV50 dwmSNrcaHqQW0pY9SJrR5sJRQ8pbc+gVp7wYUpu1dkjO+MQyB1izCVndyA+HgKILYKLK ELjfZ3sDxBn7a/sq4yxGXHawPhyKEmWu2+dw9qeJbADdNliMKjCRHiWSG3hNm5rOqouG EyDA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=YBnhe/GsDhR26I4VumrbqZP6HIDql2w1szyn7XtSRyc=; b=rh+4jvT5rTvr7XG08RgkXgf/mrig4c6Mlg//iOQMPAuOBabkQb3WTxkSDU4llmWWFW qkir8N1BRSklR/scAK+ab+3lqkrvedlYZJoAfSLx6WPNFIbU9BtP5QnIEVwFFB37SYsp j1tXY27T7lTRZpSJQdzdC9/1on+VPIc5zJruzCs6mARBXhxqnC29Bks6kIgVEMLB+cyV ELZ9vJVEKR/7DrHXuWzlBOtctWVjkE4s3wi3AbmTPOMD868fT5CcnciKIGQQKHyyUXf8 keewsh4Ngb+8pirQFx3Dfbi9y1gLSC2RgrOLcVExpL9Aq1nnVd9uUvTLSE3SvHxChMKV vsIw== X-Gm-Message-State: AOAM533opGPMwN/wmbboNB53aeEjFfyU6y+znrku8rFwPRzXf5UEz1Id FcoL1v2DVDjMEpsX/GnHNIQ+A51z X-Google-Smtp-Source: ABdhPJzDcyp0aMXnl90LB9Opni0NyY9wNnVD+gRNoZUhbblBf9v3DIPnOT3AsUKxAPpUxHALyabwoA== X-Received: by 2002:a37:6e42:: with SMTP id j63mr20014528qkc.495.1589885654142; Tue, 19 May 2020 03:54:14 -0700 (PDT) Received: from archbookpro.localdomain (CPE18593399858a-CM185933998587.cpe.net.cable.rogers.com. [174.112.65.113]) by smtp.gmail.com with ESMTPSA id c63sm10177775qkf.131.2020.05.19.03.54.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 May 2020 03:54:13 -0700 (PDT) From: Denton Liu To: Git Mailing List Cc: Jeff King , Eric Sunshine , Junio C Hamano Subject: [PATCH v3 3/7] transport: extract common fetch_pack() call Date: Tue, 19 May 2020 06:53:56 -0400 Message-Id: X-Mailer: git-send-email 2.26.2.706.g87896c9627 In-Reply-To: References: MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org In the switch statement, the difference between the `protocol_v2` and `protocol_v{1,0}` arms is a preparatory call to die_if_server_options() in the latter. The fetch_pack() call is identical in both arms. However, since this fetch_pack() call has so many parameters, it is not immediately obvious that the call is identical in both cases. Extract the common fetch_pack() call out of the switch statement so that code duplication is reduced and the logic is more clear for future readers. While we're at it, rewrite the switch statement as an if-else tower for increased clarity. Signed-off-by: Denton Liu --- transport.c | 25 ++++++++----------------- 1 file changed, 8 insertions(+), 17 deletions(-) diff --git a/transport.c b/transport.c index 15f5ba4e8f..431a93caef 100644 --- a/transport.c +++ b/transport.c @@ -369,24 +369,15 @@ static int fetch_refs_via_pack(struct transport *transport, refs_tmp = handshake(transport, 0, NULL, must_list_refs); } - switch (data->version) { - case protocol_v2: - refs = fetch_pack(&args, data->fd, - refs_tmp ? refs_tmp : transport->remote_refs, - to_fetch, nr_heads, &data->shallow, - &transport->pack_lockfile, data->version); - break; - case protocol_v1: - case protocol_v0: - die_if_server_options(transport); - refs = fetch_pack(&args, data->fd, - refs_tmp ? refs_tmp : transport->remote_refs, - to_fetch, nr_heads, &data->shallow, - &transport->pack_lockfile, data->version); - break; - case protocol_unknown_version: + if (data->version == protocol_unknown_version) BUG("unknown protocol version"); - } + else if (data->version <= protocol_v1) + die_if_server_options(transport); + + refs = fetch_pack(&args, data->fd, + refs_tmp ? refs_tmp : transport->remote_refs, + to_fetch, nr_heads, &data->shallow, + &transport->pack_lockfile, data->version); close(data->fd[0]); close(data->fd[1]); From patchwork Tue May 19 10:53:57 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denton Liu X-Patchwork-Id: 11557439 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 0D146912 for ; Tue, 19 May 2020 10:54:19 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id E87F0206D4 for ; Tue, 19 May 2020 10:54:18 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="cUHpyyUO" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728728AbgESKyS (ORCPT ); Tue, 19 May 2020 06:54:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51318 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728686AbgESKyQ (ORCPT ); Tue, 19 May 2020 06:54:16 -0400 Received: from mail-qt1-x843.google.com (mail-qt1-x843.google.com [IPv6:2607:f8b0:4864:20::843]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 554EAC061A0C for ; Tue, 19 May 2020 03:54:16 -0700 (PDT) Received: by mail-qt1-x843.google.com with SMTP id d7so10659369qtn.11 for ; Tue, 19 May 2020 03:54:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=kf97xiEpEC7PleCi4uJLbelhql6zZMVB0zEdFr9uAHA=; b=cUHpyyUOAY0/I25g530+eRw8q0T9GZeTOXhXLsRMjveNVbU1rFscQWjVcZOetE7qX5 ONrbFX77CPSnDGgdWFzHZ3TxaWeFkK2PgO2OXFupGP8HrPt8624bnlSYo8G00T5UoVDZ jK+/yP10m4I1hXV1a6uesQ24CTfn6tV1pROuPtVIqqOgqvlTC/1FRrnz9y8rdER+oHQo NsV7lNh52/nrx12FdBI6qQAivrLEPwHucAlLtI3Vs8euBotW/JHuYagtTtBBdYoYv3OZ gHd9AQQuUH57Rb6LfoshqQkXCmxJX29yNhV3qadu5ebuVDQb7XTrIvz6tJZULkkJXk2X YtDA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=kf97xiEpEC7PleCi4uJLbelhql6zZMVB0zEdFr9uAHA=; b=OFNphywV7CnaLLkpLKI4b2RyiW0waO8kKnqjY1cKQEJrF435vLFNHNCZ6+mLpAqQtJ Z7myHcUvEiphuFOOHodkdV1aBwsQF3Gw6UyY/1mMkk15sx9v3aYTAguuhOpbQiknW2Oa kU8b30Pvthn2nBJUM1IhLif9Z9viAtqlOorVRCuOfD2MWtiEdQ2tIJRaR+n7/cpb57JW j0o3e9sHEvHvPiMKPoGykGC5MhgTcc8H8EEY9oD3JmwjD2MldxJScvpL1CzXhsBRnqRc HbRwZH2NKMOClBYtk5H+cXtlGnQ8b+PfeBCya63HHEkku4BBUdvwAhFdK+Z67luI7N7y 8UNQ== X-Gm-Message-State: AOAM530gsIMoodp4uZaKOIKHAaO3wlqHXMCaxMnpjhg4F3aVwE2v0fU5 ZVUa6sEIO7zsTS5Q/y1+Ql+M1oQw X-Google-Smtp-Source: ABdhPJxyt4ATIOzvt2H6R1J9+p/OFki/kFYyqmSf1F2oV3CneMLTGHtuvyUD6A8Z0YFC7jVg8Izgog== X-Received: by 2002:aed:3f8f:: with SMTP id s15mr5942059qth.82.1589885655405; Tue, 19 May 2020 03:54:15 -0700 (PDT) Received: from archbookpro.localdomain (CPE18593399858a-CM185933998587.cpe.net.cable.rogers.com. [174.112.65.113]) by smtp.gmail.com with ESMTPSA id c63sm10177775qkf.131.2020.05.19.03.54.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 May 2020 03:54:14 -0700 (PDT) From: Denton Liu To: Git Mailing List Cc: Jeff King , Eric Sunshine , Junio C Hamano Subject: [PATCH v3 4/7] pkt-line: extern packet_length() Date: Tue, 19 May 2020 06:53:57 -0400 Message-Id: <36885943b239807eda49e231d8a45e1991f7288e.1589885479.git.liu.denton@gmail.com> X-Mailer: git-send-email 2.26.2.706.g87896c9627 In-Reply-To: References: MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org In a future commit, we will be manually processing packets and we will need to access the length header. In order to simplify this, extern packet_length() so that the logic can be reused. Change the function parameter from `const char *linelen` to `const char lenbuf_hex[4]`. Even though these two types behave identically as function parameters, use the array notation to semantically indicate exactly what this function is expecting as an argument. Also, rename it from linelen to lenbuf_hex as the former sounds like it should be an integral type which is misleading. Signed-off-by: Denton Liu --- pkt-line.c | 6 +++--- pkt-line.h | 9 +++++++++ 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/pkt-line.c b/pkt-line.c index a0e87b1e81..3beab1dc6b 100644 --- a/pkt-line.c +++ b/pkt-line.c @@ -306,10 +306,10 @@ static int get_packet_data(int fd, char **src_buf, size_t *src_size, return ret; } -static int packet_length(const char *linelen) +int packet_length(const char lenbuf_hex[4]) { - int val = hex2chr(linelen); - return (val < 0) ? val : (val << 8) | hex2chr(linelen + 2); + int val = hex2chr(lenbuf_hex); + return (val < 0) ? val : (val << 8) | hex2chr(lenbuf_hex + 2); } enum packet_read_status packet_read_with_status(int fd, char **src_buffer, diff --git a/pkt-line.h b/pkt-line.h index fef3a0d792..0d92c5e17f 100644 --- a/pkt-line.h +++ b/pkt-line.h @@ -74,6 +74,15 @@ int write_packetized_from_buf(const char *src_in, size_t len, int fd_out); int packet_read(int fd, char **src_buffer, size_t *src_len, char *buffer, unsigned size, int options); +/* + * Convert a four hex digit packet line length header into its numeric + * representation. + * + * If linelen contains non-hex characters, return -1. Otherwise, return the + * numeric value of the length header. + */ +int packet_length(const char lenbuf_hex[4]); + /* * Read a packetized line into a buffer like the 'packet_read()' function but * returns an 'enum packet_read_status' which indicates the status of the read. From patchwork Tue May 19 10:53:58 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denton Liu X-Patchwork-Id: 11557443 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3D719739 for ; Tue, 19 May 2020 10:54:22 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 1EF79207D3 for ; Tue, 19 May 2020 10:54:22 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="BKsdKa9G" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728741AbgESKyV (ORCPT ); Tue, 19 May 2020 06:54:21 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51322 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728183AbgESKyT (ORCPT ); Tue, 19 May 2020 06:54:19 -0400 Received: from mail-qk1-x734.google.com (mail-qk1-x734.google.com [IPv6:2607:f8b0:4864:20::734]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A0DA4C061A0C for ; Tue, 19 May 2020 03:54:17 -0700 (PDT) Received: by mail-qk1-x734.google.com with SMTP id b6so14274495qkh.11 for ; Tue, 19 May 2020 03:54:17 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=xDyfk99dSlNJzQcalya55W2esYP2M3wyh3LpAOsHX0w=; b=BKsdKa9G1XR01u1fu6gATj+Ae8K6954jb55M4binX/XqIa0t/ZYCajsrmJlEsQsSwO w7bLCE0BAJZtRlESyZcaWOMNu6lslpB48/hVFosC3b+WpRuWLThgUDtS0jsJ50EjgxTa GQFmdYv90qOue4usM82VpztApczsRrOecoRTGe7VhZ6vuB8K4Xfl76Gn1i5NANoSTbdE z6h/BbRIgCyk8vKpy0z1nEOhD9gDAgiqEPbTn0vlxido3Xi0nN1OXw+3ci8CjB9MHred qHMycyxW4VR6kebQ9uBF1YSfwVFVwP1bcKchjT0S4D/QkKerDPJ6zXe2GDOGK0kwbiWH srrg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=xDyfk99dSlNJzQcalya55W2esYP2M3wyh3LpAOsHX0w=; b=DIunNhGTVheoULoz7vEFoABaIdHuu/iNjE8V6ShIPKmBR5R3q6e/o0KGUXDnTJmzus RGLYxaOEmarXmH/Rb4GfKpNdTVdPSGws6zQS903ihYV6GoVfO+DvLJAJoN2km2uYBUxT N/+8bcQvVVGkEJ0NFzjbNMjLYwUjyvyByqDoNXqUanw4zjRweceUS+P3QQsrCU+6RU5z ROIHPV/Jc6qQQPtspoxnQkSxD81ux5G5275gxdTXvbTYU/3QgADJ5goXr8GTfnHMLj7n D20NwaS9Kjl+rF6+uKdLIeRyA9DJvWqXvXz+zyuCZf+PPcmlExRjKSGYlLdzCvNgcKCg wkjA== X-Gm-Message-State: AOAM533ANh6X192apjoJdFdWkQ3iLUIiJsqwAjznGuS+3lLs2gWKpqpK WXr0R8Oq3f0fQDmLQfmxM2LWLiL7 X-Google-Smtp-Source: ABdhPJyXWV7ha+uovhSfl9CO3ytv2ySNovArqPdpTQ9D+b6VP/wXjLyMh8P8iAuxJxEPSbh+1LLL7w== X-Received: by 2002:a37:7603:: with SMTP id r3mr16560846qkc.243.1589885656550; Tue, 19 May 2020 03:54:16 -0700 (PDT) Received: from archbookpro.localdomain (CPE18593399858a-CM185933998587.cpe.net.cable.rogers.com. [174.112.65.113]) by smtp.gmail.com with ESMTPSA id c63sm10177775qkf.131.2020.05.19.03.54.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 May 2020 03:54:15 -0700 (PDT) From: Denton Liu To: Git Mailing List Cc: Jeff King , Eric Sunshine , Junio C Hamano Subject: [PATCH v3 5/7] remote-curl: error on incomplete packet Date: Tue, 19 May 2020 06:53:58 -0400 Message-Id: <91d330620a18e286ec112747ea2f3a9d39066018.1589885479.git.liu.denton@gmail.com> X-Mailer: git-send-email 2.26.2.706.g87896c9627 In-Reply-To: References: MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Currently, remote-curl acts as a proxy and blindly forwards packets between an HTTP server and fetch-pack. In the case of a stateless RPC connection where the connection is terminated with a partially written packet, remote-curl will blindly send the partially written packet before waiting on more input from fetch-pack. Meanwhile, fetch-pack will read the partial packet and continue reading, expecting more input. This results in a deadlock between the two processes. For a stateless connection, inspect packets before sending them and error out if a packet line packet is incomplete. Helped-by: Jeff King Signed-off-by: Denton Liu --- remote-curl.c | 59 ++++++++++++++++++- t/lib-httpd.sh | 2 + t/lib-httpd/apache.conf | 8 +++ .../incomplete-body-upload-pack-v2-http.sh | 3 + .../incomplete-length-upload-pack-v2-http.sh | 3 + t/t5702-protocol-v2.sh | 34 +++++++++++ 6 files changed, 106 insertions(+), 3 deletions(-) create mode 100644 t/lib-httpd/incomplete-body-upload-pack-v2-http.sh create mode 100644 t/lib-httpd/incomplete-length-upload-pack-v2-http.sh diff --git a/remote-curl.c b/remote-curl.c index da3e07184a..e020140092 100644 --- a/remote-curl.c +++ b/remote-curl.c @@ -679,9 +679,53 @@ static curlioerr rpc_ioctl(CURL *handle, int cmd, void *clientp) } #endif +struct check_pktline_state { + char len_buf[4]; + int len_filled; + int remaining; +}; + +static void check_pktline(struct check_pktline_state *state, const char *ptr, size_t size) +{ + while (size) { + if (!state->remaining) { + int digits_remaining = 4 - state->len_filled; + if (digits_remaining > size) + digits_remaining = size; + memcpy(&state->len_buf[state->len_filled], ptr, digits_remaining); + state->len_filled += digits_remaining; + ptr += digits_remaining; + size -= digits_remaining; + + if (state->len_filled == 4) { + state->remaining = packet_length(state->len_buf); + if (state->remaining < 0) { + die(_("remote-curl: bad line length character: %.4s"), state->len_buf); + } else if (state->remaining < 4) { + state->remaining = 0; + } else { + state->remaining -= 4; + } + state->len_filled = 0; + } + } + + if (state->remaining) { + int remaining = state->remaining; + if (remaining > size) + remaining = size; + ptr += remaining; + size -= remaining; + state->remaining -= remaining; + } + } +} + struct rpc_in_data { struct rpc_state *rpc; struct active_request_slot *slot; + int check_pktline; + struct check_pktline_state pktline_state; }; /* @@ -702,6 +746,8 @@ static size_t rpc_in(char *ptr, size_t eltsize, return size; if (size) data->rpc->any_written = 1; + if (data->check_pktline) + check_pktline(&data->pktline_state, ptr, size); write_or_die(data->rpc->in, ptr, size); return size; } @@ -778,7 +824,7 @@ static curl_off_t xcurl_off_t(size_t len) * If flush_received is true, do not attempt to read any more; just use what's * in rpc->buf. */ -static int post_rpc(struct rpc_state *rpc, int flush_received) +static int post_rpc(struct rpc_state *rpc, int stateless_connect, int flush_received) { struct active_request_slot *slot; struct curl_slist *headers = http_copy_default_headers(); @@ -920,6 +966,8 @@ static int post_rpc(struct rpc_state *rpc, int flush_received) curl_easy_setopt(slot->curl, CURLOPT_WRITEFUNCTION, rpc_in); rpc_in_data.rpc = rpc; rpc_in_data.slot = slot; + rpc_in_data.check_pktline = stateless_connect; + memset(&rpc_in_data.pktline_state, 0, sizeof(rpc_in_data.pktline_state)); curl_easy_setopt(slot->curl, CURLOPT_FILE, &rpc_in_data); curl_easy_setopt(slot->curl, CURLOPT_FAILONERROR, 0); @@ -936,6 +984,11 @@ static int post_rpc(struct rpc_state *rpc, int flush_received) if (!rpc->any_written) err = -1; + if (rpc_in_data.pktline_state.len_filled) + err = error(_("%d bytes of length header were received"), rpc_in_data.pktline_state.len_filled); + if (rpc_in_data.pktline_state.remaining) + err = error(_("%d bytes of body are still expected"), rpc_in_data.pktline_state.remaining); + curl_slist_free_all(headers); free(gzip_body); return err; @@ -985,7 +1038,7 @@ static int rpc_service(struct rpc_state *rpc, struct discovery *heads, break; rpc->pos = 0; rpc->len = n; - err |= post_rpc(rpc, 0); + err |= post_rpc(rpc, 0, 0); } close(client.in); @@ -1342,7 +1395,7 @@ static int stateless_connect(const char *service_name) BUG("The entire rpc->buf should be larger than LARGE_PACKET_MAX"); if (status == PACKET_READ_EOF) break; - if (post_rpc(&rpc, status == PACKET_READ_FLUSH)) + if (post_rpc(&rpc, 1, status == PACKET_READ_FLUSH)) /* We would have an err here */ break; /* Reset the buffer for next request */ diff --git a/t/lib-httpd.sh b/t/lib-httpd.sh index 1449ee95e9..d2edfa4c50 100644 --- a/t/lib-httpd.sh +++ b/t/lib-httpd.sh @@ -129,6 +129,8 @@ install_script () { prepare_httpd() { mkdir -p "$HTTPD_DOCUMENT_ROOT_PATH" cp "$TEST_PATH"/passwd "$HTTPD_ROOT_PATH" + install_script incomplete-length-upload-pack-v2-http.sh + install_script incomplete-body-upload-pack-v2-http.sh install_script broken-smart-http.sh install_script error-smart-http.sh install_script error.sh diff --git a/t/lib-httpd/apache.conf b/t/lib-httpd/apache.conf index 994e5290d6..afa91e38b0 100644 --- a/t/lib-httpd/apache.conf +++ b/t/lib-httpd/apache.conf @@ -117,6 +117,8 @@ Alias /auth/dumb/ www/auth/dumb/ SetEnv GIT_EXEC_PATH ${GIT_EXEC_PATH} SetEnv GIT_HTTP_EXPORT_ALL +ScriptAlias /smart/incomplete_length/git-upload-pack incomplete-length-upload-pack-v2-http.sh/ +ScriptAlias /smart/incomplete_body/git-upload-pack incomplete-body-upload-pack-v2-http.sh/ ScriptAliasMatch /error_git_upload_pack/(.*)/git-upload-pack error.sh/ ScriptAliasMatch /smart_*[^/]*/(.*) ${GIT_EXEC_PATH}/git-http-backend/$1 ScriptAlias /broken_smart/ broken-smart-http.sh/ @@ -126,6 +128,12 @@ ScriptAliasMatch /one_time_perl/(.*) apply-one-time-perl.sh/$1 Options FollowSymlinks + + Options ExecCGI + + + Options ExecCGI + Options ExecCGI diff --git a/t/lib-httpd/incomplete-body-upload-pack-v2-http.sh b/t/lib-httpd/incomplete-body-upload-pack-v2-http.sh new file mode 100644 index 0000000000..2f5ed9fcf6 --- /dev/null +++ b/t/lib-httpd/incomplete-body-upload-pack-v2-http.sh @@ -0,0 +1,3 @@ +printf "Content-Type: text/%s\n" "application/x-git-upload-pack-result" +echo +printf "%s%s\n" "0079" "45" diff --git a/t/lib-httpd/incomplete-length-upload-pack-v2-http.sh b/t/lib-httpd/incomplete-length-upload-pack-v2-http.sh new file mode 100644 index 0000000000..86c6e648c9 --- /dev/null +++ b/t/lib-httpd/incomplete-length-upload-pack-v2-http.sh @@ -0,0 +1,3 @@ +printf "Content-Type: text/%s\n" "application/x-git-upload-pack-result" +echo +printf "%s\n" "00" diff --git a/t/t5702-protocol-v2.sh b/t/t5702-protocol-v2.sh index 5039e66dc4..4eb81ba2d4 100755 --- a/t/t5702-protocol-v2.sh +++ b/t/t5702-protocol-v2.sh @@ -586,6 +586,40 @@ test_expect_success 'clone with http:// using protocol v2' ' ! grep "Send header: Transfer-Encoding: chunked" log ' +test_expect_success 'clone repository with http:// using protocol v2 with incomplete pktline length' ' + test_when_finished "rm -f log" && + + git init "$HTTPD_DOCUMENT_ROOT_PATH/incomplete_length" && + test_commit -C "$HTTPD_DOCUMENT_ROOT_PATH/incomplete_length" file && + + test_must_fail env GIT_TRACE_PACKET="$(pwd)/log" GIT_TRACE_CURL="$(pwd)/log" git -c protocol.version=2 \ + clone "$HTTPD_URL/smart/incomplete_length" incomplete_length_child 2>err && + + # Client requested to use protocol v2 + grep "Git-Protocol: version=2" log && + # Server responded using protocol v2 + grep "git< version 2" log && + # Client reported appropriate failure + test_i18ngrep "bytes of length header were received" err +' + +test_expect_success 'clone repository with http:// using protocol v2 with incomplete pktline body' ' + test_when_finished "rm -f log" && + + git init "$HTTPD_DOCUMENT_ROOT_PATH/incomplete_body" && + test_commit -C "$HTTPD_DOCUMENT_ROOT_PATH/incomplete_body" file && + + test_must_fail env GIT_TRACE_PACKET="$(pwd)/log" GIT_TRACE_CURL="$(pwd)/log" git -c protocol.version=2 \ + clone "$HTTPD_URL/smart/incomplete_body" incomplete_body_child 2>err && + + # Client requested to use protocol v2 + grep "Git-Protocol: version=2" log && + # Server responded using protocol v2 + grep "git< version 2" log && + # Client reported appropriate failure + test_i18ngrep "bytes of body are still expected" err +' + test_expect_success 'clone big repository with http:// using protocol v2' ' test_when_finished "rm -f log" && From patchwork Tue May 19 10:53:59 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denton Liu X-Patchwork-Id: 11557441 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 26644739 for ; Tue, 19 May 2020 10:54:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0BBA8206D4 for ; Tue, 19 May 2020 10:54:21 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="pMXq44qf" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728579AbgESKyU (ORCPT ); Tue, 19 May 2020 06:54:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51328 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728662AbgESKyS (ORCPT ); Tue, 19 May 2020 06:54:18 -0400 Received: from mail-qt1-x843.google.com (mail-qt1-x843.google.com [IPv6:2607:f8b0:4864:20::843]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 90275C05BD09 for ; Tue, 19 May 2020 03:54:18 -0700 (PDT) Received: by mail-qt1-x843.google.com with SMTP id n22so8238162qtv.12 for ; Tue, 19 May 2020 03:54:18 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=R4tgJGEiZjfkukk7zy3D2mJp0VLdTghlqnhnyxpePkc=; b=pMXq44qfH21mGkoAvourLwzBEfNHJFLWLmxaLntAix64mzWoV5UBpp5N5GXAVxU5ne ++36nRLZDz0lFAPDrR1zqBxJ1QBpVTomTi8dlZoN2J+u+jAWEJPVw/j2f761d5yLrbes nK9BjIWDVLUNlzfUtkwA0R4YRWtQGx7lsQsnIKoHyJtpZ3sPzLY34FPoqvwYRa6Sz2e9 XA0JYEHohGUoKuno5SCCRNL11lzPCkkxE53dtsKqQyq60S+JP5umeYxw66OWOENPTlXu u41pXK+whTfPCR7qQaqXTZj4CrUFag+UY11BzyF0ahRB4fysdg+4OZrsKkEIaiDoTZre rVSg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=R4tgJGEiZjfkukk7zy3D2mJp0VLdTghlqnhnyxpePkc=; b=o2E3YVLzgYatAkqFqG5I6Di2u+y4t9rSFdSKQnqCpyyBFYLCeS3n0ChZ4hzGvYCN9E GmzGoqtqHDjf5YmMh6QcmDOU8954k+smW5YzNa6tSsoYzROc06+nMOJIEVWg0YE9ei+9 sIc52bsI/u4f6BGgPmDPMv9N/q7fa+5hJLs2I54Bd7msKFSUrDPfd7OxknzK6oAinQkE AHuxwby1PyuCU27+UhFUALtrKK7BeQIxhK2xEID141wIyfLfiTVV4l6jCm8dZfu44XBZ 1c05XqyjcRWWku0lAdHxq0HhLfJRtIme8i0SrDCmRgmoTyFDAxCScC69Zb6+7658o95T /YTg== X-Gm-Message-State: AOAM531oBxCUrij+YfMCg7ce826M+BTI5MXK6xepnzOgoU43pWAAieRk i659ftIBVjU7cPXKIlnfbJRQ+f6C X-Google-Smtp-Source: ABdhPJzBCWg54gLgrAp5Kduk9C9mVAf0rFF5d/Zd2rFNJt0h6KRh3XeFwScXwq/ZPuH4y0+fXHYBbg== X-Received: by 2002:ac8:7181:: with SMTP id w1mr20914182qto.125.1589885657611; Tue, 19 May 2020 03:54:17 -0700 (PDT) Received: from archbookpro.localdomain (CPE18593399858a-CM185933998587.cpe.net.cable.rogers.com. [174.112.65.113]) by smtp.gmail.com with ESMTPSA id c63sm10177775qkf.131.2020.05.19.03.54.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 May 2020 03:54:17 -0700 (PDT) From: Denton Liu To: Git Mailing List Cc: Jeff King , Eric Sunshine , Junio C Hamano Subject: [PATCH v3 6/7] pkt-line: define PACKET_READ_RESPONSE_END Date: Tue, 19 May 2020 06:53:59 -0400 Message-Id: X-Mailer: git-send-email 2.26.2.706.g87896c9627 In-Reply-To: References: MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org In a future commit, we will use PACKET_READ_RESPONSE_END to separate messages proxied by remote-curl. To prepare for this, add the PACKET_READ_RESPONSE_END enum value. In switch statements that need a case added, die() or BUG() when a PACKET_READ_RESPONSE_END is unexpected. Otherwise, mirror how PACKET_READ_DELIM is implemented (especially in cases where packets are being forwarded). Signed-off-by: Denton Liu --- connect.c | 2 ++ pkt-line.c | 11 +++++++++++ pkt-line.h | 2 ++ remote-curl.c | 2 ++ serve.c | 2 ++ t/helper/test-pkt-line.c | 4 ++++ 6 files changed, 23 insertions(+) diff --git a/connect.c b/connect.c index 23013c6344..11c6ec70a0 100644 --- a/connect.c +++ b/connect.c @@ -127,6 +127,7 @@ enum protocol_version discover_version(struct packet_reader *reader) die_initial_contact(0); case PACKET_READ_FLUSH: case PACKET_READ_DELIM: + case PACKET_READ_RESPONSE_END: version = protocol_v0; break; case PACKET_READ_NORMAL: @@ -310,6 +311,7 @@ struct ref **get_remote_heads(struct packet_reader *reader, state = EXPECTING_DONE; break; case PACKET_READ_DELIM: + case PACKET_READ_RESPONSE_END: die(_("invalid packet")); } diff --git a/pkt-line.c b/pkt-line.c index 3beab1dc6b..8f9bc68ee2 100644 --- a/pkt-line.c +++ b/pkt-line.c @@ -99,6 +99,13 @@ void packet_delim(int fd) die_errno(_("unable to write delim packet")); } +void packet_response_end(int fd) +{ + packet_trace("0002", 4, 1); + if (write_in_full(fd, "0002", 4) < 0) + die_errno(_("unable to write stateless separator packet")); +} + int packet_flush_gently(int fd) { packet_trace("0000", 4, 1); @@ -337,6 +344,10 @@ enum packet_read_status packet_read_with_status(int fd, char **src_buffer, packet_trace("0001", 4, 0); *pktlen = 0; return PACKET_READ_DELIM; + } else if (len == 2) { + packet_trace("0002", 4, 0); + *pktlen = 0; + return PACKET_READ_RESPONSE_END; } else if (len < 4) { die(_("protocol error: bad line length %d"), len); } diff --git a/pkt-line.h b/pkt-line.h index 0d92c5e17f..6cb92d7a5d 100644 --- a/pkt-line.h +++ b/pkt-line.h @@ -22,6 +22,7 @@ */ void packet_flush(int fd); void packet_delim(int fd); +void packet_response_end(int fd); void packet_write_fmt(int fd, const char *fmt, ...) __attribute__((format (printf, 2, 3))); void packet_buf_flush(struct strbuf *buf); void packet_buf_delim(struct strbuf *buf); @@ -94,6 +95,7 @@ enum packet_read_status { PACKET_READ_NORMAL, PACKET_READ_FLUSH, PACKET_READ_DELIM, + PACKET_READ_RESPONSE_END, }; enum packet_read_status packet_read_with_status(int fd, char **src_buffer, size_t *src_len, char *buffer, diff --git a/remote-curl.c b/remote-curl.c index e020140092..d02cb547e9 100644 --- a/remote-curl.c +++ b/remote-curl.c @@ -601,6 +601,8 @@ static int rpc_read_from_out(struct rpc_state *rpc, int options, case PACKET_READ_FLUSH: memcpy(buf - 4, "0000", 4); break; + case PACKET_READ_RESPONSE_END: + die(_("remote server sent stateless separator")); } } diff --git a/serve.c b/serve.c index 317256c1a4..c046926ba1 100644 --- a/serve.c +++ b/serve.c @@ -217,6 +217,8 @@ static int process_request(void) state = PROCESS_REQUEST_DONE; break; + case PACKET_READ_RESPONSE_END: + BUG("unexpected stateless separator packet"); } } diff --git a/t/helper/test-pkt-line.c b/t/helper/test-pkt-line.c index 12ca698e17..69152958e5 100644 --- a/t/helper/test-pkt-line.c +++ b/t/helper/test-pkt-line.c @@ -46,6 +46,9 @@ static void unpack(void) case PACKET_READ_DELIM: printf("0001\n"); break; + case PACKET_READ_RESPONSE_END: + printf("0002\n"); + break; } } } @@ -75,6 +78,7 @@ static void unpack_sideband(void) case PACKET_READ_FLUSH: return; case PACKET_READ_DELIM: + case PACKET_READ_RESPONSE_END: break; } } From patchwork Tue May 19 10:54:00 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denton Liu X-Patchwork-Id: 11557445 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 42552912 for ; Tue, 19 May 2020 10:54:23 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 24EE7207D3 for ; Tue, 19 May 2020 10:54:23 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="n1TzDpH2" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728745AbgESKyW (ORCPT ); Tue, 19 May 2020 06:54:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51334 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728625AbgESKyV (ORCPT ); Tue, 19 May 2020 06:54:21 -0400 Received: from mail-qt1-x835.google.com (mail-qt1-x835.google.com [IPv6:2607:f8b0:4864:20::835]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2F797C05BD09 for ; Tue, 19 May 2020 03:54:20 -0700 (PDT) Received: by mail-qt1-x835.google.com with SMTP id p12so10660741qtn.13 for ; Tue, 19 May 2020 03:54:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=99UkvxAYs9mF93dxO73Sz5GT3PvnfX6LAik4PfDQmcc=; b=n1TzDpH2IcM0XmWdAvPdq+uOhXD/hJR8EEPCJ7A9PbdP1BbIhRMu88XlBMKTK1CPZl X4vl9mZd+lGmxDqtIdo9bBwjrIVDqvS4o/qzrOnM8DGC8QN+w8RakPdFxdzJarEFGx1R imluvHMxDxy0lJZUI9tOxTagwSrFcEZBgWc2k915CkZRldUC+aK3bk5fEBWJaDMNA3rP SPG8OvagIP8BeXyLPMZVVdta4iCLWGCrUR9Q/wprwBQG2u2tkjpESlCAwZ/aNbuJ7pLt ZEsgKg4UmE7IfrCdekamhS1nfmjM4rmiRc2LJ5wznN5RUkUXVzLQPSx4bjbXTMO9xNvi Q3lg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=99UkvxAYs9mF93dxO73Sz5GT3PvnfX6LAik4PfDQmcc=; b=stuIDaLXgsIA1bCQGuSaD73KMFqe8c2R92WNpVo1xMyNvTvq6yuvPzH9FmTMF+mqAP NsM6EAn+KA/Kv2mm4I2QBur05kRYFQ8hDUh7R1c4n9HQpX4F1wTyFLiMwdbjjJBhu9AT AX2aA8GitPivmPUuXBy6PVl/YC79KfsuhtGX+KP0xCVt1Vhz6cmImjajQGf7NZY6fwqS hRWZfbR4O/SpYvQQ3RYGOtuyK3U/JpX4TQtsHplRgq0BuytWzpMinh6Oub2S5pllGIOG tdJ6zBQyBEgOj8HA3Xpf0YAsyh0dVDSjaLXYFLpvUjcQQvpR/Zn6Q0C7a99SPJ6QKtHa 6P7Q== X-Gm-Message-State: AOAM5301Qcw0J3elwOis/lEXUIw4yC9z/dtMjRIqsJVv/spmAaGo/DHw 0jdzOdlCJxItWZ1EUMzADQKSx0PC X-Google-Smtp-Source: ABdhPJwxiD5R4PviiblHSXag0lPNHLM9+sEaIoJ7KyAWeuP7/PA1bPueDRAa4cLi5xMPrn/ubZId+w== X-Received: by 2002:aed:2ce4:: with SMTP id g91mr21896395qtd.22.1589885658970; Tue, 19 May 2020 03:54:18 -0700 (PDT) Received: from archbookpro.localdomain (CPE18593399858a-CM185933998587.cpe.net.cable.rogers.com. [174.112.65.113]) by smtp.gmail.com with ESMTPSA id c63sm10177775qkf.131.2020.05.19.03.54.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 May 2020 03:54:18 -0700 (PDT) From: Denton Liu To: Git Mailing List Cc: Jeff King , Eric Sunshine , Junio C Hamano , Force Charlie Subject: [PATCH v3 7/7] stateless-connect: send response end packet Date: Tue, 19 May 2020 06:54:00 -0400 Message-Id: X-Mailer: git-send-email 2.26.2.706.g87896c9627 In-Reply-To: References: MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Currently, remote-curl acts as a proxy and blindly forwards packets between an HTTP server and fetch-pack. In the case of a stateless RPC connection where the connection is terminated before the transaction is complete, remote-curl will blindly forward the packets before waiting on more input from fetch-pack. Meanwhile, fetch-pack will read the transaction and continue reading, expecting more input to continue the transaction. This results in a deadlock between the two processes. This can be seen in the following command which does not terminate: $ git -c protocol.version=2 clone https://github.com/git/git.git --shallow-since=20151012 Cloning into 'git'... whereas the v1 version does terminate as expected: $ git -c protocol.version=1 clone https://github.com/git/git.git --shallow-since=20151012 Cloning into 'git'... fatal: the remote end hung up unexpectedly Instead of blindly forwarding packets, make remote-curl insert a response end packet after proxying the responses from the remote server when using stateless_connect(). On the RPC client side, ensure that each response ends as described. A separate control packet is chosen because we need to be able to differentiate between what the remote server sends and remote-curl's control packets. By ensuring in the remote-curl code that a server cannot send response end packets, we prevent a malicious server from being able to perform a denial of service attack in which they spoof a response end packet and cause the described deadlock to happen. Reported-by: Force Charlie Helped-by: Jeff King Signed-off-by: Denton Liu --- Documentation/gitremote-helpers.txt | 4 +++- Documentation/technical/protocol-v2.txt | 2 ++ builtin/fetch-pack.c | 2 +- connect.c | 16 +++++++++++++++- connect.h | 4 ++++ fetch-pack.c | 13 +++++++++++++ remote-curl.c | 5 +++++ remote.h | 3 ++- t/t5702-protocol-v2.sh | 13 +++++++++++++ transport.c | 3 ++- 10 files changed, 60 insertions(+), 5 deletions(-) diff --git a/Documentation/gitremote-helpers.txt b/Documentation/gitremote-helpers.txt index f48a031dc3..93baeeb029 100644 --- a/Documentation/gitremote-helpers.txt +++ b/Documentation/gitremote-helpers.txt @@ -405,7 +405,9 @@ Supported if the helper has the "connect" capability. trying to fall back). After line feed terminating the positive (empty) response, the output of the service starts. Messages (both request and response) must consist of zero or more - PKT-LINEs, terminating in a flush packet. The client must not + PKT-LINEs, terminating in a flush packet. Response messages will + then have a response end packet after the flush packet to + indicate the end of a response. The client must not expect the server to store any state in between request-response pairs. After the connection ends, the remote helper exits. + diff --git a/Documentation/technical/protocol-v2.txt b/Documentation/technical/protocol-v2.txt index 7e3766cafb..3996d70891 100644 --- a/Documentation/technical/protocol-v2.txt +++ b/Documentation/technical/protocol-v2.txt @@ -33,6 +33,8 @@ In protocol v2 these special packets will have the following semantics: * '0000' Flush Packet (flush-pkt) - indicates the end of a message * '0001' Delimiter Packet (delim-pkt) - separates sections of a message + * '0002' Message Packet (response-end-pkt) - indicates the end of a response + for stateless connections Initial Client Request ---------------------- diff --git a/builtin/fetch-pack.c b/builtin/fetch-pack.c index 4771100072..94b0c89b82 100644 --- a/builtin/fetch-pack.c +++ b/builtin/fetch-pack.c @@ -224,7 +224,7 @@ int cmd_fetch_pack(int argc, const char **argv, const char *prefix) version = discover_version(&reader); switch (version) { case protocol_v2: - get_remote_refs(fd[1], &reader, &ref, 0, NULL, NULL); + get_remote_refs(fd[1], &reader, &ref, 0, NULL, NULL, args.stateless_rpc); break; case protocol_v1: case protocol_v0: diff --git a/connect.c b/connect.c index 11c6ec70a0..0df45a1108 100644 --- a/connect.c +++ b/connect.c @@ -406,10 +406,21 @@ static int process_ref_v2(const char *line, struct ref ***list) return ret; } +void check_stateless_delimiter(int stateless_rpc, + struct packet_reader *reader, + const char *error) +{ + if (!stateless_rpc) + return; /* not in stateless mode, no delimiter expected */ + if (packet_reader_read(reader) != PACKET_READ_RESPONSE_END) + die("%s", error); +} + struct ref **get_remote_refs(int fd_out, struct packet_reader *reader, struct ref **list, int for_push, const struct argv_array *ref_prefixes, - const struct string_list *server_options) + const struct string_list *server_options, + int stateless_rpc) { int i; *list = NULL; @@ -446,6 +457,9 @@ struct ref **get_remote_refs(int fd_out, struct packet_reader *reader, if (reader->status != PACKET_READ_FLUSH) die(_("expected flush after ref listing")); + check_stateless_delimiter(stateless_rpc, reader, + _("expected response end packet after ref listing")); + return list; } diff --git a/connect.h b/connect.h index 5f2382e018..235bc66254 100644 --- a/connect.h +++ b/connect.h @@ -22,4 +22,8 @@ int server_supports_v2(const char *c, int die_on_error); int server_supports_feature(const char *c, const char *feature, int die_on_error); +void check_stateless_delimiter(int stateless_rpc, + struct packet_reader *reader, + const char *error); + #endif diff --git a/fetch-pack.c b/fetch-pack.c index f73a2ce6cb..f096442d4d 100644 --- a/fetch-pack.c +++ b/fetch-pack.c @@ -1450,6 +1450,13 @@ enum fetch_state { FETCH_DONE, }; +static void do_check_stateless_delimiter(const struct fetch_pack_args *args, + struct packet_reader *reader) +{ + check_stateless_delimiter(args->stateless_rpc, reader, + _("git fetch-pack: expected response end packet")); +} + static struct ref *do_fetch_pack_v2(struct fetch_pack_args *args, int fd[2], const struct ref *orig_ref, @@ -1534,6 +1541,10 @@ static struct ref *do_fetch_pack_v2(struct fetch_pack_args *args, /* Process ACKs/NAKs */ switch (process_acks(negotiator, &reader, &common)) { case READY: + /* + * Don't check for response delimiter; get_pack() will + * read the rest of this response. + */ state = FETCH_GET_PACK; break; case COMMON_FOUND: @@ -1541,6 +1552,7 @@ static struct ref *do_fetch_pack_v2(struct fetch_pack_args *args, seen_ack = 1; /* fallthrough */ case NO_COMMON_FOUND: + do_check_stateless_delimiter(args, &reader); state = FETCH_SEND_REQUEST; break; } @@ -1560,6 +1572,7 @@ static struct ref *do_fetch_pack_v2(struct fetch_pack_args *args, process_section_header(&reader, "packfile", 0); if (get_pack(args, fd, pack_lockfile, sought, nr_sought)) die(_("git fetch-pack: fetch failed.")); + do_check_stateless_delimiter(args, &reader); state = FETCH_DONE; break; diff --git a/remote-curl.c b/remote-curl.c index d02cb547e9..75532a8bae 100644 --- a/remote-curl.c +++ b/remote-curl.c @@ -703,6 +703,8 @@ static void check_pktline(struct check_pktline_state *state, const char *ptr, si state->remaining = packet_length(state->len_buf); if (state->remaining < 0) { die(_("remote-curl: bad line length character: %.4s"), state->len_buf); + } else if (state->remaining == 2) { + die(_("remote-curl: unexpected response end packet")); } else if (state->remaining < 4) { state->remaining = 0; } else { @@ -991,6 +993,9 @@ static int post_rpc(struct rpc_state *rpc, int stateless_connect, int flush_rece if (rpc_in_data.pktline_state.remaining) err = error(_("%d bytes of body are still expected"), rpc_in_data.pktline_state.remaining); + if (stateless_connect) + packet_response_end(rpc->in); + curl_slist_free_all(headers); free(gzip_body); return err; diff --git a/remote.h b/remote.h index 11d8719b58..5cc26c1b3b 100644 --- a/remote.h +++ b/remote.h @@ -179,7 +179,8 @@ struct ref **get_remote_heads(struct packet_reader *reader, struct ref **get_remote_refs(int fd_out, struct packet_reader *reader, struct ref **list, int for_push, const struct argv_array *ref_prefixes, - const struct string_list *server_options); + const struct string_list *server_options, + int stateless_rpc); int resolve_remote_symref(struct ref *ref, struct ref *list); diff --git a/t/t5702-protocol-v2.sh b/t/t5702-protocol-v2.sh index 4eb81ba2d4..8da65e60de 100755 --- a/t/t5702-protocol-v2.sh +++ b/t/t5702-protocol-v2.sh @@ -620,6 +620,19 @@ test_expect_success 'clone repository with http:// using protocol v2 with incomp test_i18ngrep "bytes of body are still expected" err ' +test_expect_success 'clone with http:// using protocol v2 and invalid parameters' ' + test_when_finished "rm -f log" && + + test_must_fail env GIT_TRACE_PACKET="$(pwd)/log" GIT_TRACE_CURL="$(pwd)/log" \ + git -c protocol.version=2 \ + clone --shallow-since=20151012 "$HTTPD_URL/smart/http_parent" http_child_invalid && + + # Client requested to use protocol v2 + grep "Git-Protocol: version=2" log && + # Server responded using protocol v2 + grep "git< version 2" log +' + test_expect_success 'clone big repository with http:// using protocol v2' ' test_when_finished "rm -f log" && diff --git a/transport.c b/transport.c index 431a93caef..7d50c502ad 100644 --- a/transport.c +++ b/transport.c @@ -297,7 +297,8 @@ static struct ref *handshake(struct transport *transport, int for_push, if (must_list_refs) get_remote_refs(data->fd[1], &reader, &refs, for_push, ref_prefixes, - transport->server_options); + transport->server_options, + transport->stateless_rpc); break; case protocol_v1: case protocol_v0: From patchwork Tue May 19 20:51:57 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denton Liu X-Patchwork-Id: 11558789 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id A19F990 for ; Tue, 19 May 2020 20:52:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 7E0C92075F for ; Tue, 19 May 2020 20:52:12 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="RTAlABjz" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726318AbgESUwL (ORCPT ); Tue, 19 May 2020 16:52:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60472 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725998AbgESUwL (ORCPT ); Tue, 19 May 2020 16:52:11 -0400 Received: from mail-qk1-x741.google.com (mail-qk1-x741.google.com [IPv6:2607:f8b0:4864:20::741]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EFB84C08C5C0 for ; Tue, 19 May 2020 13:52:10 -0700 (PDT) Received: by mail-qk1-x741.google.com with SMTP id b6so1209846qkh.11 for ; Tue, 19 May 2020 13:52:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=8D5jAaFU7Z237U4f3jH24xnqJKCSTDe2XfokLYbwxCA=; b=RTAlABjzm44WTNIKTgknnD+3rcwOyl5HE9x+sgP1ECiUb9HbJCFr6adNfiUFvcLgL1 /TuBScHvSo2gab3h78gpphYrdd7CDcM+4Ub+1eHNH3N8c2RjK7glywcAFtu/ALQAkNyT 2BvYjXgrwoUzRwmNWlogYZESJlGNmUwzo4Bu5aAmH4oOiN/X3qT5j0Tkq+FdSilY8gcC NAfdSUBBAZlfH6IBv7JKOBYzBG5/p56uz1MK3G4ILYiBXaMJNqIpqGFYrCfU2B7b0wyK 1M0NoH7+EdtiqaYMqBd3kyjRGVcek4ykr8MGsjP/Nd7E7/JAMjAucKUFm0411LiuzLaZ BtmQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=8D5jAaFU7Z237U4f3jH24xnqJKCSTDe2XfokLYbwxCA=; b=afbOdwGO4gM3y9RmK9Donleddm3TiGqB5YFJDApG1PHt1sCXluvx5hsjjnQN+5mm4F CVeb3f9NP0iSm1pyB0m5b9vmdba9uByMQjKihiXTmIDSiW3b7R9UK2scw5uNXTWCRnVQ u//iJz6N2dw4hcdVYYcDwbggDwYN7bG+iMQxazg4/xP6Fq9hwb1xYCEQESiYPyrjnebb jtCRQ78vNSxVOnif4K2TgSdchL7aZtEUeJ3ODp6gyAGc0EcQo5UXn2ghZyqehf2BIHMt mZne2v6dEyVEOe7RYNuzZq3XeRVVoYOZMgs1vVbzm/5dOSR2EZ1fEf5lGrd3+mCpBeeV SBJQ== X-Gm-Message-State: AOAM532bTsqGOxntLsCBiFLwduSZ4L4P7h6Eg1rxf6u1eFdAE0TpvwFl 7NRJyGqK7VgA8oh+INk+Ux2OdZ2+ X-Google-Smtp-Source: ABdhPJwkzVT838suikdE869At4txkFk7Xh2KX0UbvwstOlHRYTF8ua3dY1ISWDYz/EWWCDrQpvUEpg== X-Received: by 2002:a37:a642:: with SMTP id p63mr1427052qke.113.1589921529875; Tue, 19 May 2020 13:52:09 -0700 (PDT) Received: from archbookpro.localdomain (CPE18593399858a-CM185933998587.cpe.net.cable.rogers.com. [174.112.65.113]) by smtp.gmail.com with ESMTPSA id f33sm812722qta.44.2020.05.19.13.52.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 May 2020 13:52:09 -0700 (PDT) From: Denton Liu To: Git Mailing List Cc: Jeff King , Eric Sunshine , Junio C Hamano Subject: [PATCH v3 8/7] fixup! pkt-line: extern packet_length() Date: Tue, 19 May 2020 16:51:57 -0400 Message-Id: <04fbb741689d5f25b176c8d9709bfc6d19b2dbb5.1589921435.git.liu.denton@gmail.com> X-Mailer: git-send-email 2.27.0.rc0.114.g141fe7d276 In-Reply-To: References: MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Signed-off-by: Denton Liu --- pkt-line.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkt-line.h b/pkt-line.h index 6cb92d7a5d..5b373fe4cd 100644 --- a/pkt-line.h +++ b/pkt-line.h @@ -79,7 +79,7 @@ int packet_read(int fd, char **src_buffer, size_t *src_len, char * Convert a four hex digit packet line length header into its numeric * representation. * - * If linelen contains non-hex characters, return -1. Otherwise, return the + * If lenbuf_hex contains non-hex characters, return -1. Otherwise, return the * numeric value of the length header. */ int packet_length(const char lenbuf_hex[4]); From patchwork Fri May 22 13:33:47 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Denton Liu X-Patchwork-Id: 11565661 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id DD0FB739 for ; Fri, 22 May 2020 13:34:03 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C658D20723 for ; Fri, 22 May 2020 13:34:03 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="nfVigJSQ" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729822AbgEVNeC (ORCPT ); Fri, 22 May 2020 09:34:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45092 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729406AbgEVNeC (ORCPT ); Fri, 22 May 2020 09:34:02 -0400 Received: from mail-qk1-x741.google.com (mail-qk1-x741.google.com [IPv6:2607:f8b0:4864:20::741]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CCDE6C061A0E for ; Fri, 22 May 2020 06:34:01 -0700 (PDT) Received: by mail-qk1-x741.google.com with SMTP id s1so10647033qkf.9 for ; Fri, 22 May 2020 06:34:01 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=H58wDxSvvk/NVXHikzrRsxlA3p99a4yu7QYLXpYI8fo=; b=nfVigJSQCle/UtjFfI8GZfxxzB2LJzab6Rvjai1KqJ/7RBnD0QtkVg0+vzJTP1QNq4 U7KVUHCJ1p0m3MaHrywA3BZ84ekBY5979WZWAY+SBQGiGGIhVsTYxsoYLNGX10BPGqDs eKDSL8HUvWOf8Ee7CnYYbTeB4oNYOQ9URuS0Pb6ATRLJeO4g63tgn9i1Vc1g8mfc0aw0 7Pb1bMS4IAvB2peQ0whI9WwVthbuYBmd71C5xMSWMlKuO+BP3cmiuKoh4Wqr8GGtNV7B hEpkwHeQlInX4+m0NubG1m6M6KmjkJNnoTGzfIYo0BCoUECeOgCTtTEItA1w9wXlTXNy b6pw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=H58wDxSvvk/NVXHikzrRsxlA3p99a4yu7QYLXpYI8fo=; b=Mdk0ktUQxcA6ykiu2sr55xZ0n01gMWAqksXVrrYTRHQ1oOI5qINWg7L29tcBRokmP8 cJz4Sm847S54ONpX9AVhInV6u0jhFw6pSMifpesgUaYH30HxqHELR2XgWNaeHalbWN2L vnZx0V5+B/Cb5QFKYD3mkdKwu+1+nyp7K6OY9yLzyk9dyQJfpK4fD/jMjJz9Jl0+8/gQ g1sdxJo1A/iq7zxRV8vsYaiZntl/g8IgFg+A+aKkoaLYTksHbnlf/FdoN3K83fXGvB6r SlzwBxdmmjK1Pma/Rnmk/y9eActkQ7BijiLLF02cnRrUkalmB2HCV7ogOWbylOgzaBzx rHYw== X-Gm-Message-State: AOAM533yYdubMM8OzkJ5/exJGIAxaVkgEV4sR88x9rR57XdONdr6IAUE eZRlfW4OaI8G5QM7FhpTLVaOkq9T X-Google-Smtp-Source: ABdhPJyZ8Xn7lhZatXO43Ka5dhMZ93VtaMlG1hf0ugQ9L4RpvBgdwHdYx81qCK67PWvjojM4cSQR+w== X-Received: by 2002:a37:6384:: with SMTP id x126mr15236329qkb.355.1590154440888; Fri, 22 May 2020 06:34:00 -0700 (PDT) Received: from archbookpro.localdomain (CPE18593399858a-CM185933998587.cpe.net.cable.rogers.com. [174.112.65.113]) by smtp.gmail.com with ESMTPSA id g3sm7314462qtu.90.2020.05.22.06.33.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 May 2020 06:33:59 -0700 (PDT) From: Denton Liu To: Git Mailing List Cc: Jeff King , Eric Sunshine , Junio C Hamano Subject: [PATCH v3 9/9] fixup! remote-curl: error on incomplete packet Date: Fri, 22 May 2020 09:33:47 -0400 Message-Id: <4364b38bd027c219d41282bad3f8476daec936f9.1590154401.git.liu.denton@gmail.com> X-Mailer: git-send-email 2.27.0.rc1.69.g3229fa6e15 In-Reply-To: References: MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org In the CGI scripts which emulate a connection being prematurely terminated, it doesn't make sense for there to be a trailing newline after the simulated connection cut. Remove these newlines. Signed-off-by: Denton Liu --- t/lib-httpd/incomplete-body-upload-pack-v2-http.sh | 2 +- t/lib-httpd/incomplete-length-upload-pack-v2-http.sh | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/t/lib-httpd/incomplete-body-upload-pack-v2-http.sh b/t/lib-httpd/incomplete-body-upload-pack-v2-http.sh index 2f5ed9fcf6..90e73ef8d5 100644 --- a/t/lib-httpd/incomplete-body-upload-pack-v2-http.sh +++ b/t/lib-httpd/incomplete-body-upload-pack-v2-http.sh @@ -1,3 +1,3 @@ printf "Content-Type: text/%s\n" "application/x-git-upload-pack-result" echo -printf "%s%s\n" "0079" "45" +printf "%s%s" "0079" "45" diff --git a/t/lib-httpd/incomplete-length-upload-pack-v2-http.sh b/t/lib-httpd/incomplete-length-upload-pack-v2-http.sh index 86c6e648c9..dce552e348 100644 --- a/t/lib-httpd/incomplete-length-upload-pack-v2-http.sh +++ b/t/lib-httpd/incomplete-length-upload-pack-v2-http.sh @@ -1,3 +1,3 @@ printf "Content-Type: text/%s\n" "application/x-git-upload-pack-result" echo -printf "%s\n" "00" +printf "%s" "00"