[libvirt PATCH 00/19] Overhaul test/commandhelper.c

Tim Wiederhake twiederh at redhat.com
Fri Jan 29 16:16:10 UTC 2021

I stumbled upon a buffer overflow / stack smash present in
"test/commandhelper.c" that could be triggered by e.g.

  $ ./tests/commandhelper --readfd 0 --readfd 0 --readfd 0 --readfd x
  Could not parse fd x
  *** stack smashing detected ***: terminated
  Aborted (core dumped)

This series cleans up the file, fixes the buffer overflow and converts
(most) memory handling to g_auto*.

Note that it does not touch the "prevent malloc with zero size" issue
discussed in
this will be done in the other series.

Please feel free to comment on whether the copyright year in the file's
header should be updated and whether a prefix for the function names
and the new type is required.


Tim Wiederhake (19):
  commandhelper: Remove origenv variable
  commandhelper: Remove numpollfds variable
  commandhelper: Simplify envsort
  commandhelper: Consolidate error paths
  commandhelper: Consolidate argument parsing
  commandhelper: Split argument parsing and printing
  commandhelper: Factor out parseArguments
  commandhelper: Factor out printArguments
  commandhelper: Factor out printEnvironment
  commandhelper: Factor out printFds
  commandhelper: Factor out printDaemonization
  commandhelper: Factor out printCwd
  commandhelper: Factor out printInput
  commandhelper: Make number of fds variable in printInput
  commandhelper: Make number of fds variable in parseArguments
  commandhelper: Convert parseArguments to g_auto*
  commandhelper: Convert printEnvironment to g_auto*
  commandhelper: Convert printCwd to g_auto*
  commandhelper: Convert main to g_auto*

 tests/commandhelper.c | 295 +++++++++++++++++++++++++++---------------
 1 file changed, 188 insertions(+), 107 deletions(-)


More information about the libvir-list mailing list