diff mbox series

[1/1] smbios: empty strings in smbios_add_string()

Message ID 20200601134400.18273-1-xypron.glpk@gmx.de
State Accepted, archived
Commit 00a871d34e2f0a12eec4da9c297588026ce55b9a
Delegated to: Heinrich Schuchardt
Headers show
Series [1/1] smbios: empty strings in smbios_add_string() | expand

Commit Message

Heinrich Schuchardt June 1, 2020, 1:44 p.m. UTC
smbios_add_string() cannot deal with empty strings. This leads to incorrect
property values and invalid tables. E.g. for the pine64-lts_defconfig
CONFIG_SMBIOS_MANUFACTURER="". Linux command dmidecode shows:

Table 1:
    Manufacturer: sunxi
    Product Name: sunxi

Table 3:
    Invalid entry length (2). DMI table is broken! Stop.

Replace empty strings by "Unknown".

Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
---
 lib/smbios.c | 2 ++
 1 file changed, 2 insertions(+)

--
2.26.2

Comments

Simon Glass June 5, 2020, 3:36 a.m. UTC | #1
On Mon, 1 Jun 2020 at 07:44, Heinrich Schuchardt <xypron.glpk@gmx.de> wrote:
>
> smbios_add_string() cannot deal with empty strings. This leads to incorrect
> property values and invalid tables. E.g. for the pine64-lts_defconfig
> CONFIG_SMBIOS_MANUFACTURER="". Linux command dmidecode shows:
>
> Table 1:
>     Manufacturer: sunxi
>     Product Name: sunxi
>
> Table 3:
>     Invalid entry length (2). DMI table is broken! Stop.
>
> Replace empty strings by "Unknown".
>
> Signed-off-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
> ---
>  lib/smbios.c | 2 ++
>  1 file changed, 2 insertions(+)

Reviewed-by: Simon Glass <sjg@chromium.org>
diff mbox series

Patch

diff --git a/lib/smbios.c b/lib/smbios.c
index 7b74971f68..a8c8519dcf 100644
--- a/lib/smbios.c
+++ b/lib/smbios.c
@@ -31,6 +31,8 @@  static int smbios_add_string(char *start, const char *str)
 {
 	int i = 1;
 	char *p = start;
+	if (!*str)
+		str = "Unknown";

 	for (;;) {
 		if (!*p) {