@@ -308,11 +308,25 @@ static int unbundle_from_file(struct repository *r, const char *file)
return result;
}
-int fetch_bundle_uri(struct repository *r, const char *uri)
+/**
+ * This limits the recursion on fetch_bundle_uri_internal() when following
+ * bundle lists.
+ */
+static int max_bundle_uri_depth = 4;
+
+static int fetch_bundle_uri_internal(struct repository *r,
+ const char *uri,
+ int depth)
{
int result = 0;
struct strbuf filename = STRBUF_INIT;
+ if (depth >= max_bundle_uri_depth) {
+ warning(_("exceeded bundle URI recursion limit (%d)"),
+ max_bundle_uri_depth);
+ return -1;
+ }
+
find_temp_filename(&filename);
if ((result = copy_uri_to_file(uri, filename.buf)))
goto cleanup;
@@ -335,6 +349,11 @@ cleanup:
return result;
}
+int fetch_bundle_uri(struct repository *r, const char *uri)
+{
+ return fetch_bundle_uri_internal(r, uri, 0);
+}
+
/**
* General API for {transport,connect}.c etc.
*/