]> git.ipfire.org Git - thirdparty/rsync.git/commit
wildtest: don't read past the buffer when scanning a test line master
authorAndrew Tridgell <andrew@tridgell.net>
Sat, 13 Jun 2026 08:36:53 +0000 (18:36 +1000)
committerAndrew Tridgell <andrew@tridgell.net>
Sat, 13 Jun 2026 08:56:49 +0000 (18:56 +1000)
commite9eda5d5df167c722426ba741342db58e2cdae12
tree9106da40ea2de2559e7ee0a4ee517bcbaa56dd2b
parent04e4ee4ecef3d79571fd0aabf9f7691794d54e2e
wildtest: don't read past the buffer when scanning a test line

main()'s line parser stepped through the fgets() buffer with `*++s` in
three places without first checking for the terminating NUL, so a test
line whose last token runs to the end of the buffer (e.g. a final line
with no trailing newline) could advance s past the NUL and read out of
bounds.

Guard the flag-separator check and rewrite the two whitespace-skip loops
so they never step past the NUL. No behaviour change for well-formed
input: the existing wildtest.txt still passes, and the crafted overflow
input is now clean under valgrind.

Fixes #776
Reported-by: vikk777 (@vikk777)
wildtest.c