fix fru decoding for large areas, was overflowing 8bit counter

This commit is contained in:
Duncan Laurie 2005-04-20 22:42:11 +00:00
parent c7c5b2de37
commit 774c74a64c

View File

@ -771,12 +771,10 @@ __ipmi_fru_print(struct ipmi_intf * intf, uint8_t id)
return -1; return -1;
} }
/* offsets need converted to bytes */ /* offsets need converted to bytes
header.offset.internal *= 8; * but that conversion is not done to the structure
header.offset.chassis *= 8; * because we may end up with offset > 255
header.offset.board *= 8; * which would overflow our 1-byte offset field */
header.offset.product *= 8;
header.offset.multi *= 8;
lprintf(LOG_DEBUG, "fru.header.version: 0x%x", lprintf(LOG_DEBUG, "fru.header.version: 0x%x",
header.version); header.version);
@ -797,20 +795,20 @@ __ipmi_fru_print(struct ipmi_intf * intf, uint8_t id)
*/ */
/* chassis area */ /* chassis area */
if (header.offset.chassis >= sizeof(struct fru_header)) if ((header.offset.chassis*8) >= sizeof(struct fru_header))
fru_area_print_chassis(intf, &fru, id, header.offset.chassis); fru_area_print_chassis(intf, &fru, id, header.offset.chassis*8);
/* board area */ /* board area */
if (header.offset.board >= sizeof(struct fru_header)) if ((header.offset.board*8) >= sizeof(struct fru_header))
fru_area_print_board(intf, &fru, id, header.offset.board); fru_area_print_board(intf, &fru, id, header.offset.board*8);
/* product area */ /* product area */
if (header.offset.product >= sizeof(struct fru_header)) if ((header.offset.product*8) >= sizeof(struct fru_header))
fru_area_print_product(intf, &fru, id, header.offset.product); fru_area_print_product(intf, &fru, id, header.offset.product*8);
/* multirecord area */ /* multirecord area */
if (header.offset.multi >= sizeof(struct fru_header)) if ((header.offset.multi*8) >= sizeof(struct fru_header))
fru_area_print_multirec(intf, &fru, id, header.offset.multi); fru_area_print_multirec(intf, &fru, id, header.offset.multi*8);
return 0; return 0;
} }
@ -910,8 +908,6 @@ ipmi_fru_print_all(struct ipmi_intf * intf)
printf("FRU Device Description : Builtin FRU Device (ID 0)\n"); printf("FRU Device Description : Builtin FRU Device (ID 0)\n");
/* TODO: Figure out if FRU device 0 may show up in SDR records. */ /* TODO: Figure out if FRU device 0 may show up in SDR records. */
rc = ipmi_fru_print(intf, NULL); rc = ipmi_fru_print(intf, NULL);
if (rc < 0)
return rc;
printf("\n"); printf("\n");
if ((itr = ipmi_sdr_start(intf)) == NULL) if ((itr = ipmi_sdr_start(intf)) == NULL)