diff options
author | Michael Brown | 2013-05-01 23:00:51 +0200 |
---|---|---|
committer | Michael Brown | 2013-05-01 23:11:04 +0200 |
commit | a352fde45ef58ed4766c074d772c3cf9f4410fd7 (patch) | |
tree | 96777e21dab0caf378da3dd0bbc7769a2c0cf81c /src/interface/smbios | |
parent | [settings] Eliminate settings "tag magic" (diff) | |
download | ipxe-a352fde45ef58ed4766c074d772c3cf9f4410fd7.tar.gz ipxe-a352fde45ef58ed4766c074d772c3cf9f4410fd7.tar.xz ipxe-a352fde45ef58ed4766c074d772c3cf9f4410fd7.zip |
[smbios] Allow access to unreferenced SMBIOS strings
iPXE allows access to general SMBIOS settings using the syntax:
smbios/<type>.<offset>.<length>
This provides access to any fixed-offset field within an SMBIOS
structure. This syntax is currently overloaded to interpret a zero
<length> as meaning that the byte at <offset> contains a string index;
this provides access to SMBIOS strings (which are not located at fixed
offsets).
The "OEM Strings" SMBIOS structure contains strings which are not
referenced by any fixed string index field within the structure. iPXE
currently provides no way to access these strings.
Fix by overloading the syntax for numerical SMBIOS settings to
interpret an <offset> of zero as implying that <length> contains a
literal string index. The OEM Strings can then be accessed using:
smbios/11.0.1
smbios/11.0.2
smbios/11.0.3
...
The actual byte at offset zero will always contain the structure type,
which is already known since it must be specified in order to access
the structure. There is thus no plausible existing use case for an
offset of zero; overloading the syntax in this way should therefore
not break compatibility with any existing scripts.
The corner case where both <offset> and <length> are zero is undefined
(and, for now, will simply return a "not found" error).
Signed-off-by: Michael Brown <mcb30@ipxe.org>
Diffstat (limited to 'src/interface/smbios')
-rw-r--r-- | src/interface/smbios/smbios_settings.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/src/interface/smbios/smbios_settings.c b/src/interface/smbios/smbios_settings.c index 7b2efcd7..17f9a48e 100644 --- a/src/interface/smbios/smbios_settings.c +++ b/src/interface/smbios/smbios_settings.c @@ -99,16 +99,22 @@ static int smbios_fetch ( struct settings *settings __unused, uint8_t buf[structure.header.len]; const void *raw; union uuid uuid; + unsigned int index; /* Read SMBIOS structure */ if ( ( rc = read_smbios_structure ( &structure, buf, sizeof ( buf ) ) ) != 0 ) return rc; - /* A tag length of zero indicates a string */ - if ( tag_len == 0 ) { - if ( ( rc = read_smbios_string ( &structure, - buf[tag_offset], + /* A <length> of zero indicates that the byte at + * <offset> contains a string index. An <offset> of + * zero indicates that the <length> contains a literal + * string index. + */ + if ( ( tag_len == 0 ) || ( tag_offset == 0 ) ) { + index = ( ( tag_offset == 0 ) ? + tag_len : buf[tag_offset] ); + if ( ( rc = read_smbios_string ( &structure, index, data, len ) ) < 0 ) { return rc; } |