fix segfault when dimm spd > 128 bytes

check for at least 92 bytes of spd before proceeding
This commit is contained in:
Duncan Laurie 2003-12-18 18:22:01 +00:00
parent 7d910260e4
commit 4879ab9d21

View File

@ -65,6 +65,11 @@ const struct valstr spd_voltage_vals[] = {
{ 0x00, NULL }, { 0x00, NULL },
}; };
/*
* JEDEC Standard Manufacturers Identification Code
* publication JEP106N, December 2003
*/
const struct valstr jedec_id1_vals[] = { const struct valstr jedec_id1_vals[] = {
{ 0x01, "AMD" }, { 0x01, "AMD" },
{ 0x02, "AMI" }, { 0x02, "AMI" },
@ -713,6 +718,8 @@ void ipmi_spd_print(struct ipmi_intf * intf, unsigned char id)
printf(" Timeout while reading FRU data. (Device not present?)\n"); printf(" Timeout while reading FRU data. (Device not present?)\n");
return; return;
} }
if (rsp->ccode)
break;
len = rsp->data[0]; len = rsp->data[0];
memcpy(&spd_data[offset], rsp->data + 1, len); memcpy(&spd_data[offset], rsp->data + 1, len);
@ -722,6 +729,9 @@ void ipmi_spd_print(struct ipmi_intf * intf, unsigned char id)
if (verbose) if (verbose)
printbuf(spd_data, offset, "SPD DATA"); printbuf(spd_data, offset, "SPD DATA");
if (offset < 92)
return; /* we need first 91 bytes to do our thing */
size = spd_data[5] * (spd_data[31] << 2); size = spd_data[5] * (spd_data[31] << 2);
printf(" Memory Size : %d MB\n", size); printf(" Memory Size : %d MB\n", size);
printf(" Memory Type : %s\n", val2str(spd_data[2], spd_memtype_vals)); printf(" Memory Type : %s\n", val2str(spd_data[2], spd_memtype_vals));