Skip to content

Commit 057489d

Browse files
berrangemdroth
authored andcommitted
qga: fix leak of base64 decoded data on command error
If the guest command fails to be spawned, then we would leak the decoded base64 input used for the command's stdin feed. Signed-off-by: Daniel P. Berrangé <[email protected]> Reviewed-by: Marc-André Lureau <[email protected]> Signed-off-by: Michael Roth <[email protected]>
1 parent dee6424 commit 057489d

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

qga/commands.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,7 @@ GuestExec *qmp_guest_exec(const char *path,
402402
GIOChannel *in_ch, *out_ch, *err_ch;
403403
GSpawnFlags flags;
404404
bool has_output = (has_capture_output && capture_output);
405-
uint8_t *input = NULL;
405+
g_autofree uint8_t *input = NULL;
406406
size_t ninput = 0;
407407

408408
arglist.value = (char *)path;
@@ -441,7 +441,7 @@ GuestExec *qmp_guest_exec(const char *path,
441441
g_child_watch_add(pid, guest_exec_child_watch, gei);
442442

443443
if (has_input_data) {
444-
gei->in.data = input;
444+
gei->in.data = g_steal_pointer(&input);
445445
gei->in.size = ninput;
446446
#ifdef G_OS_WIN32
447447
in_ch = g_io_channel_win32_new_fd(in_fd);

0 commit comments

Comments
 (0)