[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PULL 16/51] vl: fix direct firmware directories leak
From: |
Paolo Bonzini |
Subject: |
[Qemu-devel] [PULL 16/51] vl: fix direct firmware directories leak |
Date: |
Tue, 16 Jan 2018 15:16:58 +0100 |
From: Marc-André Lureau <address@hidden>
Note that data_dir[] will now point to allocated strings.
Fixes:
Direct leak of 16 byte(s) in 1 object(s) allocated from:
#0 0x7f1448181850 in malloc (/lib64/libasan.so.4+0xde850)
#1 0x7f1446ed8f0c in g_malloc ../glib/gmem.c:94
#2 0x7f1446ed91cf in g_malloc_n ../glib/gmem.c:331
#3 0x7f1446ef739a in g_strsplit ../glib/gstrfuncs.c:2364
#4 0x55cf276439d7 in main /home/elmarco/src/qq/vl.c:4311
#5 0x7f143dfad039 in __libc_start_main (/lib64/libc.so.6+0x21039)
Signed-off-by: Marc-André Lureau <address@hidden>
Reviewed-by: Eric Blake <address@hidden>
Message-Id: <address@hidden>
Signed-off-by: Paolo Bonzini <address@hidden>
---
vl.c | 9 ++++++---
1 file changed, 6 insertions(+), 3 deletions(-)
diff --git a/vl.c b/vl.c
index 444b750..3599485 100644
--- a/vl.c
+++ b/vl.c
@@ -2318,7 +2318,7 @@ static void qemu_add_data_dir(const char *path)
return; /* duplicate */
}
}
- data_dir[data_dir_idx++] = path;
+ data_dir[data_dir_idx++] = g_strdup(path);
}
static inline bool nonempty_str(const char *str)
@@ -3078,7 +3078,7 @@ int main(int argc, char **argv, char **envp)
Error *main_loop_err = NULL;
Error *err = NULL;
bool list_data_dirs = false;
- char **dirs;
+ char *dir, **dirs;
typedef struct BlockdevOptions_queue {
BlockdevOptions *bdo;
Location loc;
@@ -4181,9 +4181,12 @@ int main(int argc, char **argv, char **envp)
for (i = 0; dirs[i] != NULL; i++) {
qemu_add_data_dir(dirs[i]);
}
+ g_strfreev(dirs);
/* try to find datadir relative to the executable path */
- qemu_add_data_dir(os_find_datadir());
+ dir = os_find_datadir();
+ qemu_add_data_dir(dir);
+ g_free(dir);
/* add the datadir specified when building */
qemu_add_data_dir(CONFIG_QEMU_DATADIR);
--
1.8.3.1
- [Qemu-devel] [PULL 11/51] build-sys: add a rule to print a variable, (continued)
- [Qemu-devel] [PULL 11/51] build-sys: add a rule to print a variable, Paolo Bonzini, 2018/01/16
- [Qemu-devel] [PULL 05/51] i386/cpu/kvm: look at PMU's CPUID before setting MSRs, Paolo Bonzini, 2018/01/16
- [Qemu-devel] [PULL 07/51] chardev: let g_idle_add() be with chardev gcontext, Paolo Bonzini, 2018/01/16
- [Qemu-devel] [PULL 08/51] chardev: introduce qemu_chr_timeout_add_ms(), Paolo Bonzini, 2018/01/16
- [Qemu-devel] [PULL 12/51] build-sys: compile with -Og or -O1 when --enable-debug, Paolo Bonzini, 2018/01/16
- [Qemu-devel] [PULL 14/51] tests/docker: add test-debug, Paolo Bonzini, 2018/01/16
- [Qemu-devel] [PULL 09/51] build-sys: fix qemu-ga -pthread linking, Paolo Bonzini, 2018/01/16
- [Qemu-devel] [PULL 17/51] readline: add a free function, Paolo Bonzini, 2018/01/16
- [Qemu-devel] [PULL 13/51] tests/docker: add some sanitizers to fedora dockerfile, Paolo Bonzini, 2018/01/16
- [Qemu-devel] [PULL 15/51] tests: fix check-qobject leak, Paolo Bonzini, 2018/01/16
- [Qemu-devel] [PULL 16/51] vl: fix direct firmware directories leak,
Paolo Bonzini <=
- [Qemu-devel] [PULL 18/51] tests: fix migration-test leak, Paolo Bonzini, 2018/01/16
- [Qemu-devel] [PULL 20/51] qemu-config: fix leak in query-command-line-options, Paolo Bonzini, 2018/01/16
- [Qemu-devel] [PULL 23/51] mips: fix potential fopen(NULL,...), Paolo Bonzini, 2018/01/16
- [Qemu-devel] [PULL 25/51] scsi-disk: release AioContext in unaligned WRITE SAME case, Paolo Bonzini, 2018/01/16
- [Qemu-devel] [PULL 19/51] crypto: fix stack-buffer-overflow error, Paolo Bonzini, 2018/01/16
- [Qemu-devel] [PULL 26/51] tests/boot-serial-test: Add tests for microblaze boards, Paolo Bonzini, 2018/01/16
- [Qemu-devel] [PULL 22/51] tests: fix coroutine leak in /basic/entered, Paolo Bonzini, 2018/01/16
- [Qemu-devel] [PULL 27/51] tests/boot-serial-test: Add a test for the moxiesim machine, Paolo Bonzini, 2018/01/16
- [Qemu-devel] [PULL 24/51] disas/s390: fix global-buffer-overflow, Paolo Bonzini, 2018/01/16
- [Qemu-devel] [PULL 21/51] tests: fix qmp-test leak, Paolo Bonzini, 2018/01/16