Skip to content
This repository has been archived by the owner on Aug 29, 2024. It is now read-only.

Commit

Permalink
[smbios] Allow reading an entire SMBIOS data structure as a setting
Browse files Browse the repository at this point in the history
The general syntax for SMBIOS settings:

  smbios/<instance>.<type>.<offset>.<length>

is currently extended such that a <length> of zero indicates that the
byte at <offset> contains a string index, and an <offset> of zero
indicates that the <length> 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 <length> and <offset> being zero is currently invalid and will
always return "not found".

Extend the syntax such that the combination of both <length> and
<offset> being zero may be used to read the entire data structure.

Signed-off-by: Michael Brown <[email protected]>
  • Loading branch information
mcb30 committed Jul 31, 2024
1 parent 60d6824 commit c117e6a
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/interface/smbios/smbios_settings.c
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,16 @@ static int smbios_fetch ( struct settings *settings __unused,
* <offset> contains a string index. An <offset> of
* zero indicates that the <length> 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 <length> and
* <offset> 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,
Expand Down

0 comments on commit c117e6a

Please sign in to comment.