qemu/qga
Daniel Xu d6f67b83b8 qga: Fix memory leak when output stream is unused
If capture-output is requested but one of the channels goes unused (eg.
we attempt to capture stderr but the command never writes to stderr), we
can leak memory.

guest_exec_output_watch() is (from what I understand) unconditionally
called for both streams if output capture is requested. The first call
will always pass the `p->size == p->length` check b/c both values are
0. Then GUEST_EXEC_IO_SIZE bytes will be allocated for the stream.

But when we reap the exited process there's a `gei->err.length > 0`
check to actually free the buffer. Which does not get run if the command
doesn't write to the stream.

Fix by making free() unconditional.

Reviewed-by: Konstantin Kostiuk <kkostiuk@redhat.com>
Signed-off-by: Daniel Xu <dxu@dxuuu.xyz>
Signed-off-by: Konstantin Kostiuk <kkostiuk@redhat.com>
2023-10-11 14:30:54 +03:00
..
installer qga/win/installer: add VssOption to installer 2023-03-08 18:26:49 +02:00
vss-win32 qga/: spelling fixes 2023-09-08 13:08:52 +03:00
channel-posix.c qga/: spelling fixes 2023-09-08 13:08:52 +03:00
channel-win32.c qga: Add spaces around operator 2021-03-16 20:20:37 -05:00
channel.h qga: add systemd socket activation support 2017-03-06 00:54:18 -06:00
commands-bsd.c qga: Add initial OpenBSD and NetBSD support 2022-12-20 15:54:41 +02:00
commands-common.h qga: Move HW address getting to a separate function 2022-10-26 20:35:07 +03:00
commands-linux.c qga: Move Linux-specific FS freeze/thaw code to a separate file 2022-10-26 20:35:07 +03:00
commands-posix-ssh.c qga/: spelling fixes 2023-09-08 13:08:52 +03:00
commands-posix.c qga/: spelling fixes 2023-09-08 13:08:52 +03:00
commands-win32.c qga: Remove platform GUID definitions 2023-10-11 14:30:45 +03:00
commands.c qga: Fix memory leak when output stream is unused 2023-10-11 14:30:54 +03:00
cutils.c qga: Clean up includes 2023-02-08 07:16:23 +01:00
cutils.h qga: Clean up includes 2023-02-08 07:16:23 +01:00
guest-agent-command-state.c qga: use local path for local headers 2018-06-01 19:20:38 +03:00
guest-agent-core.h qga: Replace 'blacklist' and 'whitelist' in the guest agent sources 2022-09-20 12:37:00 +02:00
main.c qga/: spelling fixes 2023-09-08 13:08:52 +03:00
meson.build configure, meson: remove target OS symbols from config-host.mak 2023-09-07 13:32:37 +02:00
messages-win32.mc qga-win: add logging to Windows event log 2022-12-20 15:54:41 +02:00
qapi-schema.json spelling: information 2023-06-09 23:38:16 +03:00
service-win32.c qga: Remove unnecessary glib.h includes 2016-06-07 18:19:24 +03:00
service-win32.h qga-win: changing --retry-path option behavior 2018-10-31 09:04:20 -05:00
vss-win32.c qga-win: add support for qmp_guest_fsfreeze_freeze_list 2018-10-30 16:48:49 -05:00
vss-win32.h qga-win: add support for qmp_guest_fsfreeze_freeze_list 2018-10-30 16:48:49 -05:00