all lists on lists.proxmox.com
 help / color / mirror / Atom feed
* [pve-devel] [PATCH qemu] fix #4726: avoid superfluous check in vma code
@ 2024-06-14 10:50 Fiona Ebner
  2024-07-02 15:17 ` Fabian Grünbichler
  0 siblings, 1 reply; 2+ messages in thread
From: Fiona Ebner @ 2024-06-14 10:50 UTC (permalink / raw)
  To: pve-devel

The 'status' pointer is dereferenced after the NULL check. Since all
callers pass in the address of a struct on the stack, the pointer can
never be NULL. Remove the superfluous check and add an assert instead.

Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
---
 ...VE-Backup-add-vma-backup-format-code.patch | 23 +++++++++----------
 1 file changed, 11 insertions(+), 12 deletions(-)

diff --git a/debian/patches/pve/0027-PVE-Backup-add-vma-backup-format-code.patch b/debian/patches/pve/0027-PVE-Backup-add-vma-backup-format-code.patch
index ee40ab8..d6d7767 100644
--- a/debian/patches/pve/0027-PVE-Backup-add-vma-backup-format-code.patch
+++ b/debian/patches/pve/0027-PVE-Backup-add-vma-backup-format-code.patch
@@ -16,10 +16,10 @@ Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
  block/meson.build |   2 +
  meson.build       |   5 +
  vma-reader.c      | 870 ++++++++++++++++++++++++++++++++++++++++++++
- vma-writer.c      | 818 +++++++++++++++++++++++++++++++++++++++++
+ vma-writer.c      | 817 +++++++++++++++++++++++++++++++++++++++++
  vma.c             | 901 ++++++++++++++++++++++++++++++++++++++++++++++
  vma.h             | 150 ++++++++
- 6 files changed, 2746 insertions(+)
+ 6 files changed, 2745 insertions(+)
  create mode 100644 vma-reader.c
  create mode 100644 vma-writer.c
  create mode 100644 vma.c
@@ -939,10 +939,10 @@ index 0000000000..d0b6721812
 +
 diff --git a/vma-writer.c b/vma-writer.c
 new file mode 100644
-index 0000000000..126b296647
+index 0000000000..a466652a5d
 --- /dev/null
 +++ b/vma-writer.c
-@@ -0,0 +1,818 @@
+@@ -0,0 +1,817 @@
 +/*
 + * VMA: Virtual Machine Archive
 + *
@@ -1517,17 +1517,16 @@ index 0000000000..126b296647
 +    int i;
 +
 +    g_assert(vmaw != NULL);
++    g_assert(status != NULL);
 +
-+    if (status) {
-+        status->status = vmaw->status;
-+        g_strlcpy(status->errmsg, vmaw->errmsg, sizeof(status->errmsg));
-+        for (i = 0; i <= 255; i++) {
-+            status->stream_info[i] = vmaw->stream_info[i];
-+        }
-+
-+        uuid_unparse_lower(vmaw->uuid, status->uuid_str);
++    status->status = vmaw->status;
++    g_strlcpy(status->errmsg, vmaw->errmsg, sizeof(status->errmsg));
++    for (i = 0; i <= 255; i++) {
++        status->stream_info[i] = vmaw->stream_info[i];
 +    }
 +
++    uuid_unparse_lower(vmaw->uuid, status->uuid_str);
++
 +    status->closed = vmaw->closed;
 +
 +    return vmaw->status;
-- 
2.39.2



_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel


^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: [pve-devel] [PATCH qemu] fix #4726: avoid superfluous check in vma code
  2024-06-14 10:50 [pve-devel] [PATCH qemu] fix #4726: avoid superfluous check in vma code Fiona Ebner
@ 2024-07-02 15:17 ` Fabian Grünbichler
  0 siblings, 0 replies; 2+ messages in thread
From: Fabian Grünbichler @ 2024-07-02 15:17 UTC (permalink / raw)
  To: Proxmox VE development discussion

On June 14, 2024 12:50 pm, Fiona Ebner wrote:
> The 'status' pointer is dereferenced after the NULL check. Since all
> callers pass in the address of a struct on the stack, the pointer can
> never be NULL. Remove the superfluous check and add an assert instead.
> 
> Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>

Reviewed-by: Fabian Grünbichler <f.gruenbichler@proxmox.com>

> ---
>  ...VE-Backup-add-vma-backup-format-code.patch | 23 +++++++++----------
>  1 file changed, 11 insertions(+), 12 deletions(-)
> 
> diff --git a/debian/patches/pve/0027-PVE-Backup-add-vma-backup-format-code.patch b/debian/patches/pve/0027-PVE-Backup-add-vma-backup-format-code.patch
> index ee40ab8..d6d7767 100644
> --- a/debian/patches/pve/0027-PVE-Backup-add-vma-backup-format-code.patch
> +++ b/debian/patches/pve/0027-PVE-Backup-add-vma-backup-format-code.patch
> @@ -16,10 +16,10 @@ Signed-off-by: Fiona Ebner <f.ebner@proxmox.com>
>   block/meson.build |   2 +
>   meson.build       |   5 +
>   vma-reader.c      | 870 ++++++++++++++++++++++++++++++++++++++++++++
> - vma-writer.c      | 818 +++++++++++++++++++++++++++++++++++++++++
> + vma-writer.c      | 817 +++++++++++++++++++++++++++++++++++++++++
>   vma.c             | 901 ++++++++++++++++++++++++++++++++++++++++++++++
>   vma.h             | 150 ++++++++
> - 6 files changed, 2746 insertions(+)
> + 6 files changed, 2745 insertions(+)
>   create mode 100644 vma-reader.c
>   create mode 100644 vma-writer.c
>   create mode 100644 vma.c
> @@ -939,10 +939,10 @@ index 0000000000..d0b6721812
>  +
>  diff --git a/vma-writer.c b/vma-writer.c
>  new file mode 100644
> -index 0000000000..126b296647
> +index 0000000000..a466652a5d
>  --- /dev/null
>  +++ b/vma-writer.c
> -@@ -0,0 +1,818 @@
> +@@ -0,0 +1,817 @@
>  +/*
>  + * VMA: Virtual Machine Archive
>  + *
> @@ -1517,17 +1517,16 @@ index 0000000000..126b296647
>  +    int i;
>  +
>  +    g_assert(vmaw != NULL);
> ++    g_assert(status != NULL);
>  +
> -+    if (status) {
> -+        status->status = vmaw->status;
> -+        g_strlcpy(status->errmsg, vmaw->errmsg, sizeof(status->errmsg));
> -+        for (i = 0; i <= 255; i++) {
> -+            status->stream_info[i] = vmaw->stream_info[i];
> -+        }
> -+
> -+        uuid_unparse_lower(vmaw->uuid, status->uuid_str);
> ++    status->status = vmaw->status;
> ++    g_strlcpy(status->errmsg, vmaw->errmsg, sizeof(status->errmsg));
> ++    for (i = 0; i <= 255; i++) {
> ++        status->stream_info[i] = vmaw->stream_info[i];
>  +    }
>  +
> ++    uuid_unparse_lower(vmaw->uuid, status->uuid_str);
> ++
>  +    status->closed = vmaw->closed;
>  +
>  +    return vmaw->status;
> -- 
> 2.39.2
> 
> 
> 
> _______________________________________________
> pve-devel mailing list
> pve-devel@lists.proxmox.com
> https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel
> 
> 
> 


_______________________________________________
pve-devel mailing list
pve-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pve-devel

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2024-07-02 15:17 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-06-14 10:50 [pve-devel] [PATCH qemu] fix #4726: avoid superfluous check in vma code Fiona Ebner
2024-07-02 15:17 ` Fabian Grünbichler

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal