From c117e6a4811efa057dc70426d58a8dab75245862 Mon Sep 17 00:00:00 2001 From: Michael Brown Date: Wed, 31 Jul 2024 16:26:48 +0100 Subject: [PATCH] [smbios] Allow reading an entire SMBIOS data structure as a setting The general syntax for SMBIOS settings: smbios/... is currently extended such that a of zero indicates that the byte at contains a string index, and an of zero indicates that the contains a literal string index. Since the byte at offset zero can never contain a string index, and a literal string index can never have a zero value, the combination of both and being zero is currently invalid and will always return "not found". Extend the syntax such that the combination of both and being zero may be used to read the entire data structure. Signed-off-by: Michael Brown --- src/interface/smbios/smbios_settings.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/interface/smbios/smbios_settings.c b/src/interface/smbios/smbios_settings.c index ca3f2fe2f..095c35d37 100644 --- a/src/interface/smbios/smbios_settings.c +++ b/src/interface/smbios/smbios_settings.c @@ -117,8 +117,16 @@ static int smbios_fetch ( struct settings *settings __unused, * contains a string index. An of * zero indicates that the contains a literal * string index. + * + * Since the byte at offset zero can never contain a + * string index, and a literal string index can never + * be zero, the combination of both and + * being zero indicates that the entire + * structure is to be read. */ - if ( ( tag_len == 0 ) || ( tag_offset == 0 ) ) { + if ( ( tag_len == 0 ) && ( tag_offset == 0 ) ) { + tag_len = sizeof ( buf ); + } else if ( ( tag_len == 0 ) || ( tag_offset == 0 ) ) { index = ( ( tag_offset == 0 ) ? tag_len : buf[tag_offset] ); if ( ( rc = read_smbios_string ( &structure, index, -- 2.47.2