]> xenbits.xensource.com Git - qemu-xen.git/commit
i386: Change X86CPUDefinition::model_id to const char*
authorEduardo Habkost <ehabkost@redhat.com>
Tue, 9 Jan 2018 15:45:13 +0000 (13:45 -0200)
committerMichael Roth <mdroth@linux.vnet.ibm.com>
Tue, 23 Jan 2018 23:08:04 +0000 (17:08 -0600)
commit4b220d88ba76fb2623ce4b8ba1f1eea66b82144e
tree02070a229c3285e83961dc3b7379a963ca929266
parent1027f3419b20329776696df343dbc8dc320d6b1b
i386: Change X86CPUDefinition::model_id to const char*

It is valid to have a 48-character model ID on CPUID, however the
definition of X86CPUDefinition::model_id is char[48], which can
make the compiler drop the null terminator from the string.

If a CPU model happens to have 48 bytes on model_id, "-cpu help"
will print garbage and the object_property_set_str() call at
x86_cpu_load_def() will read data outside the model_id array.

We could increase the array size to 49, but this would mean the
compiler would not issue a warning if a 49-char string is used by
mistake for model_id.

To make things simpler, simply change model_id to be const char*,
and validate the string length using an assert() on
x86_register_cpudef_type().

Reported-by: "Dr. David Alan Gilbert" <dgilbert@redhat.com>
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
Message-Id: <20180109154519.25634-2-ehabkost@redhat.com>
Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
(cherry picked from commit 807e9869b8c4119b81df902625af818519e01759)
Signed-off-by: Michael Roth <mdroth@linux.vnet.ibm.com>
target/i386/cpu.c