diff options
authorBryce Kwon <bryce@brycekwon.com>
committerBryce Kwon <bryce@brycekwon.com>
commit
parent
tree
download
Run a config comment to the end of its line
skip_line stopped at a NUL as well as at a newline, so the rest of the comment after one was read as a setting.
Diffstat (limited to '')
-rw-r--r--source/config.c2
-rwxr-xr-xtests/t0205-config.sh16
2 files changed, 17 insertions, 1 deletion
diff --git a/source/config.c b/source/config.c
index 2e79791..b029613 100644
--- a/source/config.c
+++ b/source/config.c
@@ -33,7 +33,7 @@ static void skip_line(FILE *f)
{
int c;
- while ((c = next_char(f)) && c != '\n' && c != EOF)
+ while ((c = next_char(f)) != '\n' && c != EOF)
;
}
diff --git a/tests/t0205-config.sh b/tests/t0205-config.sh
index 4691b8f..4536e49 100755
--- a/tests/t0205-config.sh
+++ b/tests/t0205-config.sh
@@ -95,4 +95,20 @@ test_expect_success 'a fully understood config stays silent' '
! grep "\[cgit\]" err
'
+# A comment runs to the end of its line, whatever bytes it holds, so nothing
+# after a NUL inside one is read as a setting.
+test_expect_success 'a NUL inside a comment does not end it' '
+ {
+ echo "virtual-root=/" &&
+ echo "cache-size=0" &&
+ printf "# note\\000root-title=Smuggled\\n" &&
+ echo "repo.url=foo" &&
+ echo "repo.path=$PWD/repos/foo/.git"
+ } >nulrc &&
+ grep -c Smuggled nulrc &&
+ CGIT_CONFIG="$PWD/nulrc" QUERY_STRING="url=" cgit >tmp &&
+ grep "</html>" tmp &&
+ ! grep Smuggled tmp
+'
+
test_done