diff options
-rw-r--r-- | daemon.c | 6 | ||||
-rwxr-xr-x | t/t5570-git-daemon.sh | 15 |
2 files changed, 17 insertions, 4 deletions
@@ -760,10 +760,8 @@ static int execute(void) alarm(0); len = strlen(line); - if (len && line[len-1] == '\n') { - line[--len] = 0; - pktlen--; - } + if (len && line[len-1] == '\n') + line[len-1] = 0; /* parse additional args hidden behind a NUL byte */ if (len != pktlen) diff --git a/t/t5570-git-daemon.sh b/t/t5570-git-daemon.sh index b556469db6..755b05a8ae 100755 --- a/t/t5570-git-daemon.sh +++ b/t/t5570-git-daemon.sh @@ -196,5 +196,20 @@ test_expect_success 'daemon log records all attributes' ' test_cmp expect actual ' +test_expect_success FAKENC 'hostname interpolation works after LF-stripping' ' + { + printf "git-upload-pack /interp.git\n\0host=localhost" | packetize + printf "0000" + } >input && + fake_nc "$GIT_DAEMON_HOST_PORT" <input >output && + depacketize <output >output.raw && + + # just pick out the value of master, which avoids any protocol + # particulars + perl -lne "print \$1 if m{^(\\S+) refs/heads/master}" <output.raw >actual && + git -C "$repo" rev-parse master >expect && + test_cmp expect actual +' + stop_git_daemon test_done |