diff options
author | Zdenek Styblik <stybla@turnovfree.net> | 2014-04-25 20:48:40 +0200 |
---|---|---|
committer | Zdenek Styblik <stybla@turnovfree.net> | 2014-04-25 20:48:40 +0200 |
commit | 166ae1da23f462c72684caa9d75bb3dbb6b7813a (patch) | |
tree | 0f36a732764a4b01e108a78661788b0d46e3bb2f | |
parent | 4f0967779e5c4716ee189ef2e552f5411c641e54 (diff) | |
download | ipmitool-166ae1da23f462c72684caa9d75bb3dbb6b7813a.tar.gz |
ID: 308 - "fru edit" no longer works for non-zero fields
1. Warnings about "FRU Area Length" based on uninitialized (malloc'd) memory
contents (due to fru->max_read_size not being initialized, left at 0) and
fru_data not being zeroed after malloc() in ipmi_fru_set_field_string().
2. "fru edit" commands for any field index other than 0 would fail (with "Field
not found !" error) due to a couple offset and length calculation errors (for
all the supported "area" types) in ipmi_fru_set_field_string().
3. "fru edit" commands would corrupt the FRU Inventory Area due to incorrect
"source offset" value being specified in write_fru_area() call in
impi_fru_set_field_string().
Commit for Rob Swindell
-rw-r--r-- | lib/ipmi_fru.c | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/lib/ipmi_fru.c b/lib/ipmi_fru.c index 6aeead0..80d1ad6 100644 --- a/lib/ipmi_fru.c +++ b/lib/ipmi_fru.c @@ -641,7 +641,7 @@ read_fru_area(struct ipmi_intf * intf, struct fru_info *fru, uint8_t id, fru->max_read_size = 255; } else { /* subtract 1 byte for bytes count */ - fru->max_write_size = max_rs_size - 1; + fru->max_read_size = max_rs_size - 1; } /* check word access */ @@ -4717,22 +4717,22 @@ f_type, uint8_t f_index, char *f_string) if (f_type == 'c' ) { header_offset = (header.offset.chassis * 8); read_fru_area(intf ,&fru, fruId, header_offset , 3 , fru_data); - fru_field_offset = (header.offset.chassis * 8) + 3; - fru_section_len = *(fru_data + header_offset + 1) * 8; + fru_field_offset = 3; + fru_section_len = *(fru_data + 1) * 8; } /* Board type field */ else if (f_type == 'b' ) { header_offset = (header.offset.board * 8); read_fru_area(intf ,&fru, fruId, header_offset , 3 , fru_data); - fru_field_offset = (header.offset.board * 8) + 6; - fru_section_len = *(fru_data + header_offset + 1) * 8; + fru_field_offset = 6; + fru_section_len = *(fru_data + 1) * 8; } /* Product type field */ else if (f_type == 'p' ) { header_offset = (header.offset.product * 8); read_fru_area(intf ,&fru, fruId, header_offset , 3 , fru_data); - fru_field_offset = (header.offset.product * 8) + 3; - fru_section_len = *(fru_data + header_offset + 1) * 8; + fru_field_offset = 3; + fru_section_len = *(fru_data + 1) * 8; } else { @@ -4782,8 +4782,8 @@ f_type, uint8_t f_index, char *f_string) checksum = (~checksum) + 1; fru_data[header_offset + fru_section_len - 1] = checksum; - /* Write the updated section to the FRU data */ - if( write_fru_area(intf, &fru, fruId, header_offset, + /* Write the updated section to the FRU data; source offset: */ + if( write_fru_area(intf, &fru, fruId, 0, header_offset, fru_section_len, fru_data) < 0 ) { printf("Write to FRU data failed.\n"); |