mirror of https://github.com/proxmox/mirror_qemu
smbios: sanitize type from external type before checking have_fields_bitmap
test_bit uses header->type as an offset; if the file incorrectly specifies a type greater than 127, smbios_entry_add will read and write garbage. To fix this, just pass the smbios data through, assuming the user knows what to do. Reported by Coverity as CID 1487255. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>master
parent
b00e2c68c5
commit
57e3069641
|
@ -1205,13 +1205,15 @@ void smbios_entry_add(QemuOpts *opts, Error **errp)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (test_bit(header->type, have_fields_bitmap)) {
|
if (header->type <= SMBIOS_MAX_TYPE) {
|
||||||
error_setg(errp,
|
if (test_bit(header->type, have_fields_bitmap)) {
|
||||||
"can't load type %d struct, fields already specified!",
|
error_setg(errp,
|
||||||
header->type);
|
"can't load type %d struct, fields already specified!",
|
||||||
return;
|
header->type);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
set_bit(header->type, have_binfile_bitmap);
|
||||||
}
|
}
|
||||||
set_bit(header->type, have_binfile_bitmap);
|
|
||||||
|
|
||||||
if (header->type == 4) {
|
if (header->type == 4) {
|
||||||
smbios_type4_count++;
|
smbios_type4_count++;
|
||||||
|
|
Loading…
Reference in New Issue