Commit 7a059e96 authored by Michael Ott's avatar Michael Ott
Browse files

Handle too short IPMI raw reads, move check for too long raw data extraction...

Handle too short IPMI raw reads, move check for too long raw data extraction length to IPMIConfigurator::readSensor()
parent d5834d58
......@@ -228,6 +228,11 @@ bool IPMIConfigurator::readSensor(DCDB::IPMISensor *sensor, boost::property_tree
}
}
if ((sensor->getRecordId() == 0) && ((sensor->getStop() - sensor->getStart()) >= 8)) {
LOG(warning) << " Sensor \"" << sensor->getName() << "\": Maximum IPMI raw command return length is 8 bytes (currently " << sensor->getStop()-sensor->getStart()+1 << "), adjusting stop position to " << sensor->getStart()+7;
sensor->setStop(sensor->getStart() + 7);
}
sensor->setCacheInterval(_cacheInterval);
return true;
}
......
......@@ -202,7 +202,7 @@ uint64_t IPMIHost::sendRawCmd(const std::vector<uint8_t>& rawCmd,
while (retries--) {
if ((len = ipmi_cmd_raw(_ipmiCtx, rawCmd[0], rawCmd[1], &rawCmd[2], rawCmd.size() - 2, buf, sizeof(buf))) < 0) {
if (retries == 0) {
LOG(error) << _hostName << ": ipmi_sensor_read " << ipmi_ctx_errormsg(_ipmiCtx);
LOG(error) << _hostName << ": ipmi_cmd_raw " << ipmi_ctx_errormsg(_ipmiCtx);
}
increaseErrorCount();
disconnect();
......@@ -227,13 +227,11 @@ uint64_t IPMIHost::sendRawCmd(const std::vector<uint8_t>& rawCmd,
std::cout << std::dec << std::endl;
#endif
if (stop == 0 || stop >= len) {
stop = len - 1;
}
if ((stop - start) >= 8) {
stop = start + 7;
if ((stop > len) || ((stop - start) >= 8)) {
throw std::runtime_error("Error processing IPMI raw data");
return 0;
}
uint64_t val = 0;
for (i = start; i <= stop; i++) {
val |= ((uint64_t) buf[i]) << (stop - i) * 8;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment