]> git.ipfire.org Git - thirdparty/qemu.git/commitdiff
vfio/pci: Fix buffer overrun when writing the VF token
authorCédric Le Goater <clg@redhat.com>
Thu, 26 Oct 2023 07:06:35 +0000 (09:06 +0200)
committerMichael Tokarev <mjt@tls.msk.ru>
Thu, 9 Nov 2023 13:39:13 +0000 (16:39 +0300)
qemu_uuid_unparse() includes a trailing NUL when writing the uuid
string and the buffer size should be UUID_FMT_LEN + 1 bytes. Use the
recently added UUID_STR_LEN which defines the correct size.

Fixes: CID 1522913
Fixes: 2dca1b37a760 ("vfio/pci: add support for VF token")
Cc: Alex Williamson <alex.williamson@redhat.com>
Reviewed-by: Alex Williamson <alex.williamson@redhat.com>
Reviewed-by: Juan Quintela <quintela@redhat.com>
Reviewed-by: "Denis V. Lunev" <den@openvz.org>
Signed-off-by: Cédric Le Goater <clg@redhat.com>
(cherry picked from commit f8d6f3b16c37bd516a026e92a31dade5d761d3a6)
Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
hw/vfio/pci.c

index a205c6b1130fe44c66381ce8d18ba0b44f795395..aab02ebb98570ce62b692525889f996cb02d4d7f 100644 (file)
@@ -2987,7 +2987,7 @@ static void vfio_realize(PCIDevice *pdev, Error **errp)
     int groupid;
     int i, ret;
     bool is_mdev;
-    char uuid[UUID_FMT_LEN];
+    char uuid[UUID_STR_LEN];
     char *name;
 
     if (!vbasedev->sysfsdev) {