git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 5/9] upload-pack: accept only a single packfile-uri line

From
Jeff King <peff@peff.net>
Date
Feb 28, 2024, 22:38 UTC
Message-ID
<20240228223846.GE1158131@coredump.intra.peff.net>
In-Reply-To
<20240228223700.GA1157826@coredump.intra.peff.net>

When we see a packfile-uri line from the client, we use string_list_split() to split it on commas and store the result in a string_list. A single packfile-uri line is therefore limited to storing ~64kb, the size of a pkt-line.

But we'll happily accept multiple such lines, and each line appends to the string list, growing without bound.

In theory this could be useful, making:
  0017packfile-uris http
  0018packfile-uris https
equivalent to:
  001dpackfile-uris http,https

But the protocol documentation doesn't indicate that this should work (and indeed, refers to this in the singular as "the following argument can be included in the client's request"). And the client-side implementation in fetch-pack has always sent a single line (JGit appears to understand the line on the server side but has no client-side implementation, and libgit2 understands neither).

If we were worried about compatibility, we could instead just put a limit on the maximum number of values we'd accept. The current client implementation limits itself to only two values: "http" and "https", so something like "256" would be more than enough. But accepting only a single line seems more in line with the protocol documentation, and matches other parts of the protocol (e.g., we will not accept a second "filter" line).

We'll also make this more explicit in the protocol documentation; as above, I think this was always the intent, but there's no harm in making it clear.

Signed-off-by: Jeff King <peff@peff.net>
---
 Documentation/gitprotocol-v2.txt | 3 ++-
 upload-pack.c                    | 3 +++
 2 files changed, 5 insertions(+), 1 deletion(-)
diff --git a/Documentation/gitprotocol-v2.txt b/Documentation/gitprotocol-v2.txt
index 837ea6171e..414bc625d5 100644
--- a/Documentation/gitprotocol-v2.txt
+++ b/Documentation/gitprotocol-v2.txt
@@ -362,7 +362,8 @@ included in the client's request:
 If the 'packfile-uris' feature is advertised, the following argument
 can be included in the client's request as well as the potential
 addition of the 'packfile-uris' section in the server's response as
-explained below.
+explained below. Note that at most one `packfile-uris` line can be sent
+to the server.
 
     packfile-uris <comma-separated-list-of-protocols>
 	Indicates to the server that the client is willing to receive
diff --git a/upload-pack.c b/upload-pack.c
index 8b47576ec7..2a5c52666e 100644
--- a/upload-pack.c
+++ b/upload-pack.c
@@ -1646,6 +1646,9 @@ static void process_args(struct packet_reader *request,
 		}
 
 		if (skip_prefix(arg, "packfile-uris ", &p)) {
+			if (data->uri_protocols.nr)
+				send_err_and_die(data,
+						 "multiple packfile-uris lines forbidden");
 			string_list_split(&data->uri_protocols, p, ',', -1);
 			continue;
 		}
-- 
2.44.0.rc2.424.gbdbf4d014b
Previous: Jeff KingNext: Jeff King
Message 6 of 17 in “bound upload-pack memory allocations”
  1. 0/9 bound upload-pack memory allocationsJeff King, Feb 28, 2024
  2. 1/9 upload-pack: drop separate v2 "haves" arrayJeff King, Feb 28, 2024
  3. 2/9 upload-pack: switch deepen-not list to an oid_arrayJeff King, Feb 28, 2024
  4. 3/9 upload-pack: use oidset for deepen_not listJeff King, Feb 28, 2024
  5. 4/9 upload-pack: use a strmap for want-ref linesJeff King, Feb 28, 2024
  6. 5/9 upload-pack: accept only a single packfile-uri lineJeff King, Feb 28, 2024
  7. 6/9 upload-pack: disallow object-info capability by defaultJeff King, Feb 28, 2024
  8. Patrick SteinhardtMar 4, 2024
  9. Jeff KingMar 4, 2024
  10. Taylor BlauApr 29, 2024
  11. 7/9 upload-pack: always turn off save_commit_bufferJeff King, Feb 28, 2024
  12. 8/9 upload-pack: use PARSE_OBJECT_SKIP_HASH_CHECK in more placesJeff King, Feb 28, 2024
  13. 9/9 upload-pack: free tree buffers after parsingJeff King, Feb 28, 2024
  14. Patrick SteinhardtMar 4, 2024
  15. Jeff KingMar 4, 2024
  16. Patrick SteinhardtMar 4, 2024
  17. Junio C HamanoFeb 28, 2024

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.