tests/qtest: generic_fuzz: Avoid using hardcoded /tmp
authorBin Meng <bin.meng@windriver.com>
Sun, 25 Sep 2022 11:29:48 +0000 (19:29 +0800)
committerThomas Huth <thuth@redhat.com>
Tue, 27 Sep 2022 18:51:20 +0000 (20:51 +0200)
This case was written to use hardcoded /tmp directory for temporary
files. Update to use g_dir_make_tmp() for a portable implementation.

Signed-off-by: Bin Meng <bin.meng@windriver.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
Message-Id: <20220925113032.1949844-11-bmeng.cn@gmail.com>
Signed-off-by: Thomas Huth <thuth@redhat.com>
tests/qtest/fuzz/generic_fuzz_configs.h

index 0775e6702b6b85f7ad58d28c8d08ae77f3accbe7..a825b78c14f6cc3955388809ccf9050adab414b6 100644 (file)
@@ -20,8 +20,8 @@ typedef struct generic_fuzz_config {
 } generic_fuzz_config;
 
 static inline gchar *generic_fuzzer_virtio_9p_args(void){
-    char tmpdir[] = "/tmp/qemu-fuzz.XXXXXX";
-    g_assert_nonnull(g_mkdtemp(tmpdir));
+    g_autofree char *tmpdir = g_dir_make_tmp("qemu-fuzz.XXXXXX", NULL);
+    g_assert_nonnull(tmpdir);
 
     return g_strdup_printf("-machine q35 -nodefaults "
     "-device virtio-9p,fsdev=hshare,mount_tag=hshare "