vhost-user-test: fix predictable filename on tmpfs
authorMichael S. Tsirkin <mst@redhat.com>
Thu, 1 Oct 2015 12:50:52 +0000 (15:50 +0300)
committerMichael S. Tsirkin <mst@redhat.com>
Fri, 2 Oct 2015 14:04:32 +0000 (17:04 +0300)
vhost-user-test uses getpid to create a unique filename. This name is
predictable, and a security problem.  Instead, use a tmp directory
created by mkdtemp, which is a suggested best practice.

Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Reviewed-by: Marc-André Lureau <marcandre.lureau@redhat.com>
tests/vhost-user-test.c

index 5e63cbc..56df5cc 100644 (file)
@@ -330,7 +330,7 @@ int main(int argc, char **argv)
         root = tmpfs;
     }
 
-    socket_path = g_strdup_printf("/tmp/vhost-%d.sock", getpid());
+    socket_path = g_strdup_printf("%s/vhost.sock", tmpfs);
 
     /* create char dev and add read handlers */
     qemu_add_opts(&qemu_chardev_opts);