From: matthias.bgg at kernel.org <matthias.bgg@kernel.org>
To: u-boot@lists.denx.de
Subject: [PATCH v2] smbios: Fix table when no string is present
Date: Tue, 6 Apr 2021 11:04:35 +0200 [thread overview]
Message-ID: <20210406090435.19357-1-matthias.bgg@kernel.org> (raw)
From: Matthias Brugger <mbrugger@suse.com>
When no string is present in a table, next_ptr points to the same
location as eos. When calculating the string table length, we would only
reserve one \0. By spec a SMBIOS table has to end with two \0\0 when no
strings a present.
Signed-off-by: Matthias Brugger <mbrugger@suse.com>
---
Changes in v2:
- check in smbios_string_table_len if no string present and return value
accordingly
lib/smbios.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/lib/smbios.c b/lib/smbios.c
index 9eb226ec9f..fd57d8694f 100644
--- a/lib/smbios.c
+++ b/lib/smbios.c
@@ -191,6 +191,10 @@ int smbios_update_version(const char *version)
*/
static int smbios_string_table_len(const struct smbios_ctx *ctx)
{
+ /* In case no string is defined we have to return two \0 */
+ if (ctx->next_ptr == ctx->eos)
+ return 2;
+
/* Allow for the final \0 after all strings */
return (ctx->next_ptr + 1) - ctx->eos;
}
--
2.30.2
next reply other threads:[~2021-04-06 9:04 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-04-06 9:04 matthias.bgg at kernel.org [this message]
2021-04-07 16:14 ` [PATCH v2] smbios: Fix table when no string is present Simon Glass
2024-01-31 21:25 ` Heinrich Schuchardt
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210406090435.19357-1-matthias.bgg@kernel.org \
--to=matthias.bgg@kernel.org \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox