|
|
6a2d3c |
From ba6951c82c8af1c9fd4669d8561517bd7850eeee Mon Sep 17 00:00:00 2001
|
|
|
6a2d3c |
From: Gerd Hoffmann <kraxel@redhat.com>
|
|
|
6a2d3c |
Date: Wed, 22 Jan 2014 09:32:53 -0500
|
|
|
6a2d3c |
Subject: [PATCH 2/6] smbios: catch zero-length strings
|
|
|
6a2d3c |
|
|
|
6a2d3c |
Message-id: <1390383173-24339-2-git-send-email-kraxel@redhat.com>
|
|
|
6a2d3c |
Patchwork-id: 56881
|
|
|
6a2d3c |
O-Subject: [RHEL-7 seabios PATCH 1/1] smbios: catch zero-length strings
|
|
|
6a2d3c |
Bugzilla: 1052837
|
|
|
6a2d3c |
RH-Acked-by: Markus Armbruster <armbru@redhat.com>
|
|
|
6a2d3c |
RH-Acked-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
6a2d3c |
RH-Acked-by: Igor Mammedov <imammedo@redhat.com>
|
|
|
6a2d3c |
|
|
|
6a2d3c |
qemu may pass us zero-length strings for smbios fields, when starting
|
|
|
6a2d3c |
qemu this way ...
|
|
|
6a2d3c |
|
|
|
6a2d3c |
qemu -smbios type=1,version=,serial=test
|
|
|
6a2d3c |
|
|
|
6a2d3c |
... for example.
|
|
|
6a2d3c |
|
|
|
6a2d3c |
Today we don't specifically handle them and simply append them to the
|
|
|
6a2d3c |
string list. Therefore we get two string-terminating zeros in a row.
|
|
|
6a2d3c |
Result is that we by accident create a end-of-entry marker in the middle
|
|
|
6a2d3c |
of the entry.
|
|
|
6a2d3c |
|
|
|
6a2d3c |
Fix this by handling zero-length strings like non-present strings.
|
|
|
6a2d3c |
|
|
|
6a2d3c |
Cc: armbru@redhat.com
|
|
|
6a2d3c |
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
|
|
|
6a2d3c |
(cherry picked from commit 344496fae4bee9243be7f9719a60b01189c12f00)
|
|
|
6a2d3c |
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
6a2d3c |
|
|
|
6a2d3c |
Conflicts:
|
|
|
6a2d3c |
src/smbios.c
|
|
|
6a2d3c |
---
|
|
|
6a2d3c |
src/smbios.c | 10 +++++++---
|
|
|
6a2d3c |
1 file changed, 7 insertions(+), 3 deletions(-)
|
|
|
6a2d3c |
---
|
|
|
6a2d3c |
src/smbios.c | 10 +++++++---
|
|
|
6a2d3c |
1 file changed, 7 insertions(+), 3 deletions(-)
|
|
|
6a2d3c |
|
|
|
6a2d3c |
diff --git a/src/smbios.c b/src/smbios.c
|
|
|
6a2d3c |
index 23713a2..4e6df14 100644
|
|
|
6a2d3c |
--- a/src/smbios.c
|
|
|
6a2d3c |
+++ b/src/smbios.c
|
|
|
6a2d3c |
@@ -61,13 +61,17 @@ smbios_entry_point_init(u16 max_structure_size,
|
|
|
6a2d3c |
size = qemu_cfg_smbios_load_field(type, \
|
|
|
6a2d3c |
offsetof(struct smbios_type_##type, \
|
|
|
6a2d3c |
field), end); \
|
|
|
6a2d3c |
- if (size > 0) { \
|
|
|
6a2d3c |
+ if (size == 1) { \
|
|
|
6a2d3c |
+ /* zero-length string, skip to avoid bogus end marker */ \
|
|
|
6a2d3c |
+ p->field = 0; \
|
|
|
6a2d3c |
+ } else if (size > 1) { \
|
|
|
6a2d3c |
end += size; \
|
|
|
6a2d3c |
+ p->field = ++str_index; \
|
|
|
6a2d3c |
} else { \
|
|
|
6a2d3c |
memcpy(end, def, sizeof(def)); \
|
|
|
6a2d3c |
end += sizeof(def); \
|
|
|
6a2d3c |
+ p->field = ++str_index; \
|
|
|
6a2d3c |
} \
|
|
|
6a2d3c |
- p->field = ++str_index; \
|
|
|
6a2d3c |
} while (0)
|
|
|
6a2d3c |
|
|
|
6a2d3c |
#define load_str_field_or_skip(type, field) \
|
|
|
6a2d3c |
@@ -75,7 +79,7 @@ smbios_entry_point_init(u16 max_structure_size,
|
|
|
6a2d3c |
size = qemu_cfg_smbios_load_field(type, \
|
|
|
6a2d3c |
offsetof(struct smbios_type_##type, \
|
|
|
6a2d3c |
field), end); \
|
|
|
6a2d3c |
- if (size > 0) { \
|
|
|
6a2d3c |
+ if (size > 1) { \
|
|
|
6a2d3c |
end += size; \
|
|
|
6a2d3c |
p->field = ++str_index; \
|
|
|
6a2d3c |
} else { \
|
|
|
6a2d3c |
--
|
|
|
6a2d3c |
1.8.3.1
|
|
|
6a2d3c |
|