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

[PATCH] upload-pack: don't send null character in abort message to the client

From
SZEDER Gábor <szeder.dev@gmail.com>
Date
Feb 25, 2024, 18:34 UTC
Message-ID
<20240225183452.1939334-1-szeder.dev@gmail.com>

Since 583b7ea31b (upload-pack/fetch-pack: support side-band communication, 2006-06-21) the abort message sent by upload-pack in case of possible repository corruption ends with a null character. This can be seen in several test cases in 't5530-upload-pack-error.sh' where 'grep <pattern> output.err' often reports "Binary file output.err matches" because of that null character.

The reason for this is that the abort message is defined as a string literal, and we pass its size to the send function as sizeof(abort_msg), which also counts the terminating null character.

Use strlen() instead to avoid sending that terminating null character.
Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com>
---
 upload-pack.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/upload-pack.c b/upload-pack.c
index 2537affa90..6e0d441ef5 100644
--- a/upload-pack.c
+++ b/upload-pack.c
@@ -463,7 +463,7 @@ static void create_pack_file(struct upload_pack_data *pack_data,
 
  fail:
 	free(output_state);
-	send_client_data(3, abort_msg, sizeof(abort_msg),
+	send_client_data(3, abort_msg, strlen(abort_msg),
 			 pack_data->use_sideband);
 	die("git upload-pack: %s", abort_msg);
 }
-- 
2.44.0.rc1.366.g26e5fbbdb0
Next: Junio C Hamano
Message 1 of 2 in “upload-pack: don't send null character in abort message to the client”
  1. upload-pack: don't send null character in abort message to the clientSZEDER Gábor, Feb 25, 2024
  2. Junio C HamanoFeb 26, 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.