summaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authorLibravatar Jeff King <peff@peff.net>2018-01-24 19:56:20 -0500
committerLibravatar Junio C Hamano <gitster@pobox.com>2018-01-25 13:50:17 -0800
commit550fbcad1c464df9e32cab15a8c6a01f91b1629c (patch)
tree8a32f4ef94a53c590c167052c6bec9ca54d1c6aa /t
parentdaemon: fix off-by-one in logging extended attributes (diff)
downloadtgif-550fbcad1c464df9e32cab15a8c6a01f91b1629c.tar.xz
daemon: handle NULs in extended attribute string
If we receive a request with extended attributes after the NUL, we try to write those attributes to the log. We do so with a "%s" format specifier, which will only show characters up to the first NUL. That's enough for printing a "host=" specifier. But since dfe422d04d (daemon: recognize hidden request arguments, 2017-10-16) we may have another NUL, followed by protocol parameters, and those are not logged at all. Let's cut out the attempt to show the whole string, and instead log when we parse individual attributes. We could leave the "extended attributes (%d bytes) exist" part of the log, which in theory could alert us to attributes that fail to parse. But anything we don't parse as a "host=" parameter gets blindly added to the "protocol" attribute, so we'd see it in that part of the log. Signed-off-by: Jeff King <peff@peff.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't')
-rwxr-xr-xt/t5570-git-daemon.sh8
1 files changed, 5 insertions, 3 deletions
diff --git a/t/t5570-git-daemon.sh b/t/t5570-git-daemon.sh
index 359af3994a..b556469db6 100755
--- a/t/t5570-git-daemon.sh
+++ b/t/t5570-git-daemon.sh
@@ -183,13 +183,15 @@ test_expect_success 'hostname cannot break out of directory' '
git ls-remote "$GIT_DAEMON_URL/escape.git"
'
-test_expect_success 'daemon log records hostnames' '
+test_expect_success 'daemon log records all attributes' '
cat >expect <<-\EOF &&
- Extended attributes (15 bytes) exist <host=localhost>
+ Extended attribute "host": localhost
+ Extended attribute "protocol": version=1
EOF
>daemon.log &&
GIT_OVERRIDE_VIRTUAL_HOST=localhost \
- git ls-remote "$GIT_DAEMON_URL/interp.git" &&
+ git -c protocol.version=1 \
+ ls-remote "$GIT_DAEMON_URL/interp.git" &&
grep -i extended.attribute daemon.log | cut -d" " -f2- >actual &&
test_cmp expect actual
'