From: Toon Claes <toon@iotcl.com>
To: git@vger.kernel.org
Cc: Toon Claes <toon@iotcl.com>
Subject: [PATCH] bundle-uri.c: Fix double increment in depth
Date: Fri, 21 Jun 2024 11:22:58 +0200 [thread overview]
Message-ID: <20240621092258.1557258-1-toon@iotcl.com> (raw)
A bundle URI can serve a gitformat-bundle(5) or a bundle list. This
plain text file is in the Git config format containing other bundle
URIs. To avoid these bundle lists to nest too deep, we've set a limit
with `max_bundle_uri_depth`. Although, when walk through the tree of
bundles, the current depth is incremented in download_bundle_list() and
then calls download_bundle_to_file(), which also increments the depth.
Remove the increment in download_bundle_to_file().
Signed-off-by: Toon Claes <toon@iotcl.com>
---
bundle-uri.c | 2 +-
t/t5558-clone-bundle-uri.sh | 62 +++++++++++++++++++++++++++++++++++++
2 files changed, 63 insertions(+), 1 deletion(-)
diff --git a/bundle-uri.c b/bundle-uri.c
index 91b3319a5c..7b1a711919 100644
--- a/bundle-uri.c
+++ b/bundle-uri.c
@@ -436,7 +436,7 @@ static int download_bundle_to_file(struct remote_bundle_info *bundle, void *data
if (ctx->mode == BUNDLE_MODE_ANY && ctx->count)
return 0;
- res = fetch_bundle_uri_internal(ctx->r, bundle, ctx->depth + 1, ctx->list);
+ res = fetch_bundle_uri_internal(ctx->r, bundle, ctx->depth, ctx->list);
/*
* Only increment count if the download succeeded. If our mode is
diff --git a/t/t5558-clone-bundle-uri.sh b/t/t5558-clone-bundle-uri.sh
index 1ca5f745e7..f3a8494297 100755
--- a/t/t5558-clone-bundle-uri.sh
+++ b/t/t5558-clone-bundle-uri.sh
@@ -259,6 +259,68 @@ test_expect_success 'clone bundle list (file, any mode, all failures)' '
! grep "refs/bundles/" refs
'
+test_expect_success 'clone bundle list (file, above max depth)' '
+ cat >bundle-list-1 <<-EOF &&
+ [bundle]
+ version = 1
+ mode = any
+
+ [bundle "bundle-list-2"]
+ uri = file://$(pwd)/bundle-list-2
+ EOF
+
+ cat >bundle-list-2 <<-EOF &&
+ [bundle]
+ version = 1
+ mode = any
+
+ [bundle "bundle-list-3"]
+ uri = file://$(pwd)/bundle-list-3
+ EOF
+
+ cat >bundle-list-3 <<-EOF &&
+ [bundle]
+ version = 1
+ mode = any
+
+ [bundle "bundle-list-4"]
+ uri = file://$(pwd)/bundle-list-4
+ EOF
+
+ cat >bundle-list-4 <<-EOF &&
+ [bundle]
+ version = 1
+ mode = any
+
+ [bundle "bundle-0"]
+ uri = file://$(pwd)/clone-from/bundle-0.bundle
+ EOF
+
+ git clone --bundle-uri="file://$(pwd)/bundle-list-1" \
+ clone-from clone-too-deep 2>err &&
+ ! grep "fatal" err &&
+ grep "warning: exceeded bundle URI recursion limit" err &&
+
+ git -C clone-from for-each-ref --format="%(objectname)" >oids &&
+ git -C clone-too-deep cat-file --batch-check <oids &&
+
+ git -C clone-too-deep for-each-ref --format="%(refname)" >refs &&
+ ! grep "refs/bundles/" refs
+'
+
+test_expect_success 'clone bundle list (file, below max depth)' '
+ git clone --bundle-uri="file://$(pwd)/bundle-list-2" \
+ clone-from clone-max-depth 2>err &&
+ ! grep "fatal" err &&
+ ! grep "warning: exceeded bundle URI recursion limit" err &&
+
+ git -C clone-from for-each-ref --format="%(objectname)" >oids &&
+ git -C clone-max-depth cat-file --batch-check <oids &&
+
+ git -C clone-max-depth for-each-ref --format="%(refname)" >refs &&
+ ! grep "refs/bundles/" refs
+'
+
#########################################################################
# HTTP tests begin here
--
2.45.0
next reply other threads:[~2024-06-21 9:23 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-06-21 9:22 Toon Claes [this message]
2024-06-21 15:24 ` [PATCH] bundle-uri.c: Fix double increment in depth Christian Couder
2024-06-21 16:59 ` Junio C Hamano
2024-06-21 17:17 ` Eric Sunshine
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=20240621092258.1557258-1-toon@iotcl.com \
--to=toon@iotcl.com \
--cc=git@vger.kernel.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