From patchwork Wed Feb 23 16:03:12 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matt Cooper X-Patchwork-Id: 12757157 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id D48E9C433EF for ; Wed, 23 Feb 2022 16:03:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242569AbiBWQDt (ORCPT ); Wed, 23 Feb 2022 11:03:49 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56966 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240555AbiBWQDq (ORCPT ); Wed, 23 Feb 2022 11:03:46 -0500 Received: from mail-wr1-x431.google.com (mail-wr1-x431.google.com [IPv6:2a00:1450:4864:20::431]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 409547E08B for ; Wed, 23 Feb 2022 08:03:18 -0800 (PST) Received: by mail-wr1-x431.google.com with SMTP id s13so11874281wrb.6 for ; Wed, 23 Feb 2022 08:03:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:in-reply-to:references:from:date:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=s/CZEzPjYxFygFdH4NuFkOv/sJbCmDhnqsdbwhsLjzY=; b=iZoi8VuptxRXGEIoiA7cM36ASb8aXiCJ5s739AFdedgIUJocb+gL69nKfpZ8vkxPvJ 9jrsIUcoEQRyR/bcxadKqHpnYs3lzxGjrxumicsEdbmTt5z73RH5Ip0C04pV/B0sLQ8r hu10xFJokoVUk7ZVcTKYd94zoTe8YQTO0Xr5lqCy+3ZtrmBMvLloBxbi5Cp4mVy+us+Y tCd3940+zAjuMFOVI61ty1sfRLLSGsLjY/19x+nP+Zievbufsx9jIfrz3j6t9UOWffeQ n88gJcRX0Z+I+e3gjUsJ8kbxwo3MOKqKIB5bFoS5anVudP5bBE2ruRzR1+/eG+7GbchN YWUA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=s/CZEzPjYxFygFdH4NuFkOv/sJbCmDhnqsdbwhsLjzY=; b=BGWjLV+NoUhNJpmnNmo41zZn4TTW/py2o8FIfFs9hqi2gA1fGVR1dZ4rTolekEmE6w CLw5ySUQuiKWgzBxslEbKFId9JanfGgeQ+DscuM+ysMG4CS4bdkFx09rYpjuI55s2xwv r/f+DPAxloyWc/R2c8K9N2XWtT/gQTlz86/Hg8/NDlDoLGAJIRSA+ZIF13WWPnXCA+Js /7rAZECD9653BSqYAJDx0rEyZdsaAXC4l1jh35ZbFgbp2Q0ncxHZUCtlhqSlzsXyb33J y6JNvmWxzqYzLBb0w1qe8LGSv0IzgJu8aaLmZVVQUXzapN3aSPxQFFrh6yRYAWNIiOiF g4xA== X-Gm-Message-State: AOAM533SKq7Nra1pJMwhhSN2M1bIBc0TYCn3aycT2H9w6V/g5YYBrv3+ IlbECDdq/A5OLpmqbJZfKNQd2TOS/JI= X-Google-Smtp-Source: ABdhPJzKubz4YnaUmHXKuX7qt2JzwrHGT85vhP5s8FjOHXHAN5CaLO/cfEy9CS8uvrs0Z1J7PtOkBg== X-Received: by 2002:a5d:6411:0:b0:1e5:6bed:3df6 with SMTP id z17-20020a5d6411000000b001e56bed3df6mr219110wru.477.1645632196526; Wed, 23 Feb 2022 08:03:16 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id a10sm119045wrt.59.2022.02.23.08.03.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Feb 2022 08:03:15 -0800 (PST) Message-Id: In-Reply-To: References: Date: Wed, 23 Feb 2022 16:03:12 +0000 Subject: [PATCH 1/2] index-pack: clarify the breached limit Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: gitster@pobox.com, me@ttaylorr.com, derrickstolee@github.com, Matt Cooper , Matt Cooper Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Matt Cooper From: Matt Cooper As a small courtesy to users, report what limit was breached. This is especially useful when a push exceeds a server-defined limit, since the user is unlikely to have configured the limit (their host did). Signed-off-by: Matt Cooper --- builtin/index-pack.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/builtin/index-pack.c b/builtin/index-pack.c index 3c2e6aee3cc..c45273de3b1 100644 --- a/builtin/index-pack.c +++ b/builtin/index-pack.c @@ -323,8 +323,12 @@ static void use(int bytes) if (signed_add_overflows(consumed_bytes, bytes)) die(_("pack too large for current definition of off_t")); consumed_bytes += bytes; - if (max_input_size && consumed_bytes > max_input_size) - die(_("pack exceeds maximum allowed size")); + if (max_input_size && consumed_bytes > max_input_size) { + struct strbuf size_limit = STRBUF_INIT; + strbuf_humanise_bytes(&size_limit, max_input_size); + die(_("pack exceeds maximum allowed size (%s)"), + size_limit.buf); + } } static const char *open_pack_file(const char *pack_name) From patchwork Wed Feb 23 16:03:13 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Matt Cooper X-Patchwork-Id: 12757158 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 20DD6C433F5 for ; Wed, 23 Feb 2022 16:03:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242576AbiBWQDv (ORCPT ); Wed, 23 Feb 2022 11:03:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56978 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242414AbiBWQDq (ORCPT ); Wed, 23 Feb 2022 11:03:46 -0500 Received: from mail-wr1-x436.google.com (mail-wr1-x436.google.com [IPv6:2a00:1450:4864:20::436]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 002767DE33 for ; Wed, 23 Feb 2022 08:03:18 -0800 (PST) Received: by mail-wr1-x436.google.com with SMTP id d28so12647251wra.4 for ; Wed, 23 Feb 2022 08:03:18 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=message-id:in-reply-to:references:from:date:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=HKgoO0YXdrpxQaCTqKz3yiJBDgSCowAE1BP45GDxf4M=; b=bU27bWmK5Ykgk5vNYXRtoafYy+9pNMIFfSUOJ13l9VIdetdS7tcO2EZTgMPjmS2cyo EvD/+njGJdfvxwBB0mqYfefdv2vKk9/He18ZGMc7GqyJy60o7IwsrATQkKLPN3QWJREW oOdBIr/5mZbKhOe2bJuaAl17eHkNdqz+IyBcnQSrNRAH2b0rv2QBDoN+AuI2/XThrDC9 eBbylrPfl65Tp//O97bMxpojrAw3I26pswFbyBGrwLfAmmhStw6drqytBmEmLNhBSfgd 86pieLCRGR2IZU+VcY/wCIuDr16zGN+OEs1RndzkGoHdcBECbzit6KpK7R9buJdaPJdV /LCw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=HKgoO0YXdrpxQaCTqKz3yiJBDgSCowAE1BP45GDxf4M=; b=Mxe+anarxYsaeargJy+l/F3XmP0imbb+Yl1G1b1SKWMVs0dDhclnQeGmbmQRZaVXkb Mmr6azp7XVgqNa4qgySmcv1Rn5wFKDHKmMd5fTUg8KhE6Uj6bRfH8X81DgxlvQGA/IjE HA8ZgufgOm9OB6jKxOiWVKml7web6O3qwFEvHG6PpUepW+tysNZY5ZTR/8JB05NfDziS jyhY2vP5IjSMmpZ5XblVaQFJ38LlPJF5qyf8MfeueCH7cUgYf1wcNmvp9KOdzj+QbU+t X+g6kG7APxjwAueC491CwzNawAqJ9oupSGUJJ9dzzYUqlWVlZroIWx9bHpSf87+znYvP bUvA== X-Gm-Message-State: AOAM5333wzd651kHC/4hmVRZEmqmzNq/ZD/mNylupMUs1Cfx21+4pvEb UfaZA8KfCAVarJi/6EPb5HcZS9vhbzk= X-Google-Smtp-Source: ABdhPJwf9bJ2a1kwsVQ2Le39ZIpPOHLsjR4Y/aUDRruJ5J2DedplxxS4KDDmQIvNE00EcAk5hBfyng== X-Received: by 2002:a05:6000:15c4:b0:1ea:78a4:9cce with SMTP id y4-20020a05600015c400b001ea78a49ccemr219115wry.375.1645632197461; Wed, 23 Feb 2022 08:03:17 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id m62-20020a1c2641000000b00380d0cff5f3sm171952wmm.8.2022.02.23.08.03.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 23 Feb 2022 08:03:17 -0800 (PST) Message-Id: <43990408a10d65058d872f13ea9619e85de7081d.1645632193.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Wed, 23 Feb 2022 16:03:13 +0000 Subject: [PATCH 2/2] t5302: confirm that large packs mention limit Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: gitster@pobox.com, me@ttaylorr.com, derrickstolee@github.com, Matt Cooper , Matt Cooper Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Matt Cooper From: Matt Cooper When a pack can't be processed because it's too large, we report the exact nature of the breach. This test ensures that the error message has a human-readable size included. Signed-off-by: Matt Cooper Helped-by: Taylor Blau Helped-by: Derrick Stolee --- t/t5302-pack-index.sh | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/t/t5302-pack-index.sh b/t/t5302-pack-index.sh index 8ee67df38f6..b0095ab41d3 100755 --- a/t/t5302-pack-index.sh +++ b/t/t5302-pack-index.sh @@ -284,4 +284,12 @@ test_expect_success 'index-pack -v --stdin produces progress for both phases' ' test_i18ngrep "Resolving deltas" err ' +test_expect_success 'too-large packs report the breach' ' + pack=$(git pack-objects --all pack err && + grep "maximum allowed size (20 bytes)" err +' + test_done