diff options
author | Michael S. Tsirkin <mst@redhat.com> | 2021-02-02 17:52:53 -0500 |
---|---|---|
committer | Michael S. Tsirkin <mst@redhat.com> | 2021-02-05 08:52:59 -0500 |
commit | 43e229a52b464099afa9449aef587b9a3419b470 (patch) | |
tree | a710eab4f6b57ebbc51a4350295c64f26bb06517 /hw/i386 | |
parent | 602b458201ffd6f261fb8ee16b5175d733d3ec32 (diff) | |
download | qemu-43e229a52b464099afa9449aef587b9a3419b470.zip |
acpi: use constants as strncpy limit
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>
Diffstat (limited to 'hw/i386')
-rw-r--r-- | hw/i386/microvm.c | 4 | ||||
-rw-r--r-- | hw/i386/pc.c | 4 |
2 files changed, 4 insertions, 4 deletions
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) |