Skip to content

Commit 3f4c7a0

Browse files
szedergitster
authored andcommitted
upload-pack: don't send null character in abort message to the client
Since 583b7ea (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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 3c2a3fd commit 3f4c7a0

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

upload-pack.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -463,7 +463,7 @@ static void create_pack_file(struct upload_pack_data *pack_data,
463463

464464
fail:
465465
free(output_state);
466-
send_client_data(3, abort_msg, sizeof(abort_msg),
466+
send_client_data(3, abort_msg, strlen(abort_msg),
467467
pack_data->use_sideband);
468468
die("git upload-pack: %s", abort_msg);
469469
}

0 commit comments

Comments
 (0)