]> git.ipfire.org Git - thirdparty/systemd.git/commit - src/test/test-fileio.c
test-fileio: fix bogus error when /proc/cmdline contains newlines
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Fri, 13 Dec 2019 11:21:11 +0000 (12:21 +0100)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Sat, 28 Mar 2020 10:46:47 +0000 (11:46 +0100)
commit30b84c78eac027819eafc25e7f0486f2079bd63e
treed08851c589535f6ad8e9e5a117d77bddcfd411b3
parentb49325d028803bacefcf3817a84206b31197826c
test-fileio: fix bogus error when /proc/cmdline contains newlines

The kernel does not sanitize /proc/cmdline. E.g. when running under qemu, it is
easy to pass a string with newline by mistake. We use read_one_line_file(), so
we would read only the first list of the file, and
write_string_file(WRITE_STRING_FILE_VERIFY_ON_FAILURE) would fail because the
target file is obviously different. Change to a kernel-generated file to avoid
the issue.

v2:
- use /proc/version instead of /proc/uptime for attempted writes, so the test
  test passes even if test_write_string_file_verify() takes more than 10 ms ;]
src/test/test-fileio.c