From 025f196aec731aa418d66aa72640c1e7b6e7dbc1 Mon Sep 17 00:00:00 2001 From: Carol Hebert Date: Wed, 28 Jan 2009 19:54:06 +0000 Subject: [PATCH] Dmitry Konyshev 1/23/09 sdr-read-fix patch to fix a crash when dumping SDRs in a file and there's an error getting an sdr. Improve algorithm for finding optimal packet size --- ipmitool/lib/ipmi_sdr.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/ipmitool/lib/ipmi_sdr.c b/ipmitool/lib/ipmi_sdr.c index 814b010..1a7ae6f 100644 --- a/ipmitool/lib/ipmi_sdr.c +++ b/ipmitool/lib/ipmi_sdr.c @@ -2743,14 +2743,21 @@ ipmi_sdr_get_record(struct ipmi_intf * intf, struct sdr_get_rs * header, rsp = intf->sendrecv(intf, &req); if (rsp == NULL) { + sdr_max_read_len = sdr_rq.length - 1; + if (sdr_max_read_len > 0) { + /* no response may happen if requests are bridged + and too many bytes are requested */ + continue; + } else { free(data); return NULL; + } } switch (rsp->ccode) { case 0xca: /* read too many bytes at once */ - sdr_max_read_len = (sdr_max_read_len >> 1) - 1; + sdr_max_read_len = sdr_rq.length - 1; continue; case 0xc5: /* lost reservation */ @@ -4037,6 +4044,11 @@ ipmi_sdr_dump_bin(struct ipmi_intf *intf, const char *ofile) sdrr->length = header->length; sdrr->raw = ipmi_sdr_get_record(intf, header, itr); + if (sdrr->raw == NULL) { + lprintf(LOG_ERR, "ipmitool: cannot obtain SDR record %04x", header->id); + return -1; + } + if (sdr_list_head == NULL) sdr_list_head = sdrr; else