[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL v2 13/16] acpi: use constants as strncpy limit
From: |
Michael S. Tsirkin |
Subject: |
[PULL v2 13/16] acpi: use constants as strncpy limit |
Date: |
Fri, 5 Feb 2021 10:04:06 -0500 |
gcc is not smart enough to figure out length was validated before use as
strncpy limit, resulting in this warning:
inlined from ‘virt_set_oem_table_id’ at ../../hw/arm/virt.c:2197:5:
/usr/include/aarch64-linux-gnu/bits/string_fortified.h:106:10: error:
‘__builtin_strncpy’ specified bound depends on the length of the
source argument [-Werror=stringop-overflow=]
Simplify things by using a constant limit instead.
Fixes: 97fc5d507fca ("acpi: Permit OEM ID and OEM table ID fields to be
changed")
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
---
hw/arm/virt.c | 4 ++--
hw/i386/microvm.c | 4 ++--
hw/i386/pc.c | 4 ++--
3 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/hw/arm/virt.c b/hw/arm/virt.c
index 0c65fe38a0..371147f3ae 100644
--- a/hw/arm/virt.c
+++ b/hw/arm/virt.c
@@ -2173,7 +2173,7 @@ static void virt_set_oem_id(Object *obj, const char
*value, Error **errp)
return;
}
- strncpy(vms->oem_id, value, len + 1);
+ strncpy(vms->oem_id, value, 6);
}
static char *virt_get_oem_table_id(Object *obj, Error **errp)
@@ -2194,7 +2194,7 @@ static void virt_set_oem_table_id(Object *obj, const char
*value,
"User specified oem-table-id value is bigger than 8 bytes
in size");
return;
}
- strncpy(vms->oem_table_id, value, len + 1);
+ strncpy(vms->oem_table_id, value, 8);
}
diff --git a/hw/i386/microvm.c b/hw/i386/microvm.c
index 1dc2956e72..4e0cf4c522 100644
--- a/hw/i386/microvm.c
+++ b/hw/i386/microvm.c
@@ -668,7 +668,7 @@ static void microvm_machine_set_oem_id(Object *obj, const
char *value,
return;
}
- strncpy(mms->oem_id, value, len + 1);
+ strncpy(mms->oem_id, value, 6);
}
static char *microvm_machine_get_oem_table_id(Object *obj, Error **errp)
@@ -690,7 +690,7 @@ static void microvm_machine_set_oem_table_id(Object *obj,
const char *value,
"8 bytes in size");
return;
}
- strncpy(mms->oem_table_id, value, len + 1);
+ strncpy(mms->oem_table_id, value, 8);
}
static void microvm_machine_initfn(Object *obj)
diff --git a/hw/i386/pc.c b/hw/i386/pc.c
index 437977c49e..8aa85dec54 100644
--- a/hw/i386/pc.c
+++ b/hw/i386/pc.c
@@ -1630,7 +1630,7 @@ static void pc_machine_set_oem_id(Object *obj, const char
*value, Error **errp)
return;
}
- strncpy(pcms->oem_id, value, len + 1);
+ strncpy(pcms->oem_id, value, 6);
}
static char *pc_machine_get_oem_table_id(Object *obj, Error **errp)
@@ -1652,7 +1652,7 @@ static void pc_machine_set_oem_table_id(Object *obj,
const char *value,
"8 bytes in size");
return;
}
- strncpy(pcms->oem_table_id, value, len + 1);
+ strncpy(pcms->oem_table_id, value, 8);
}
static void pc_machine_initfn(Object *obj)
--
MST
- [PULL v2 03/16] virtio: move 'use-disabled-flag' property to hw_compat_4_2, (continued)
- [PULL v2 03/16] virtio: move 'use-disabled-flag' property to hw_compat_4_2, Michael S. Tsirkin, 2021/02/05
- [PULL v2 02/16] pci: add romsize property, Michael S. Tsirkin, 2021/02/05
- [PULL v2 04/16] virtio-mmio: fix guest kernel crash with SHM regions, Michael S. Tsirkin, 2021/02/05
- [PULL v2 05/16] virtio: Add corresponding memory_listener_unregister to unrealize, Michael S. Tsirkin, 2021/02/05
- [PULL v2 06/16] virtio-pmem: add trace events, Michael S. Tsirkin, 2021/02/05
- [PULL v2 07/16] vhost: Unbreak SMMU and virtio-iommu on dev-iotlb support, Michael S. Tsirkin, 2021/02/05
- [PULL v2 08/16] hw/i386: Remove the deprecated pc-1.x machine types, Michael S. Tsirkin, 2021/02/05
- [PULL v2 10/16] vhost: Check for valid vdev in vhost_backend_handle_iotlb_msg, Michael S. Tsirkin, 2021/02/05
- [PULL v2 11/16] tests/acpi: allow updates for expected data files, Michael S. Tsirkin, 2021/02/05
- [PULL v2 12/16] acpi: Permit OEM ID and OEM table ID fields to be changed, Michael S. Tsirkin, 2021/02/05
- [PULL v2 13/16] acpi: use constants as strncpy limit,
Michael S. Tsirkin <=
- [PULL v2 16/16] tests/acpi: disallow updates for expected data files, Michael S. Tsirkin, 2021/02/05
- [PULL v2 15/16] tests/acpi: update expected data files, Michael S. Tsirkin, 2021/02/05
- [PULL v2 14/16] tests/acpi: add OEM ID and OEM TABLE ID test, Michael S. Tsirkin, 2021/02/05
- [PULL v2 09/16] hw/virtio/virtio-balloon: Remove the "class" property, Michael S. Tsirkin, 2021/02/05
- Re: [PULL v2 00/16] pc,virtio,pci: fixes, features,code removal, Peter Maydell, 2021/02/05