提交 73d60fa5 编写于 作者: C Cédric Le Goater 提交者: Paolo Bonzini

ipmi: sensor number should not exceed MAX_SENSORS

Fix a number of off-by-ones, one of them spotted by Coverity.
Signed-off-by: NCédric Le Goater <clg@fr.ibm.com>
Signed-off-by: NPaolo Bonzini <pbonzini@redhat.com>
上级 9155b760
...@@ -534,7 +534,7 @@ static void ipmi_init_sensors_from_sdrs(IPMIBmcSim *s) ...@@ -534,7 +534,7 @@ static void ipmi_init_sensors_from_sdrs(IPMIBmcSim *s)
continue; /* Not a sensor SDR we set from */ continue; /* Not a sensor SDR we set from */
} }
if (sdr->sensor_owner_number > MAX_SENSORS) { if (sdr->sensor_owner_number >= MAX_SENSORS) {
continue; continue;
} }
sens = s->sensors + sdr->sensor_owner_number; sens = s->sensors + sdr->sensor_owner_number;
...@@ -1448,7 +1448,7 @@ static void set_sensor_evt_enable(IPMIBmcSim *ibs, ...@@ -1448,7 +1448,7 @@ static void set_sensor_evt_enable(IPMIBmcSim *ibs,
IPMISensor *sens; IPMISensor *sens;
IPMI_CHECK_CMD_LEN(4); IPMI_CHECK_CMD_LEN(4);
if ((cmd[2] > MAX_SENSORS) || if ((cmd[2] >= MAX_SENSORS) ||
!IPMI_SENSOR_GET_PRESENT(ibs->sensors + cmd[2])) { !IPMI_SENSOR_GET_PRESENT(ibs->sensors + cmd[2])) {
rsp[2] = IPMI_CC_REQ_ENTRY_NOT_PRESENT; rsp[2] = IPMI_CC_REQ_ENTRY_NOT_PRESENT;
return; return;
...@@ -1500,7 +1500,7 @@ static void get_sensor_evt_enable(IPMIBmcSim *ibs, ...@@ -1500,7 +1500,7 @@ static void get_sensor_evt_enable(IPMIBmcSim *ibs,
IPMISensor *sens; IPMISensor *sens;
IPMI_CHECK_CMD_LEN(3); IPMI_CHECK_CMD_LEN(3);
if ((cmd[2] > MAX_SENSORS) || if ((cmd[2] >= MAX_SENSORS) ||
!IPMI_SENSOR_GET_PRESENT(ibs->sensors + cmd[2])) { !IPMI_SENSOR_GET_PRESENT(ibs->sensors + cmd[2])) {
rsp[2] = IPMI_CC_REQ_ENTRY_NOT_PRESENT; rsp[2] = IPMI_CC_REQ_ENTRY_NOT_PRESENT;
return; return;
...@@ -1521,7 +1521,7 @@ static void rearm_sensor_evts(IPMIBmcSim *ibs, ...@@ -1521,7 +1521,7 @@ static void rearm_sensor_evts(IPMIBmcSim *ibs,
IPMISensor *sens; IPMISensor *sens;
IPMI_CHECK_CMD_LEN(4); IPMI_CHECK_CMD_LEN(4);
if ((cmd[2] > MAX_SENSORS) || if ((cmd[2] >= MAX_SENSORS) ||
!IPMI_SENSOR_GET_PRESENT(ibs->sensors + cmd[2])) { !IPMI_SENSOR_GET_PRESENT(ibs->sensors + cmd[2])) {
rsp[2] = IPMI_CC_REQ_ENTRY_NOT_PRESENT; rsp[2] = IPMI_CC_REQ_ENTRY_NOT_PRESENT;
return; return;
...@@ -1543,7 +1543,7 @@ static void get_sensor_evt_status(IPMIBmcSim *ibs, ...@@ -1543,7 +1543,7 @@ static void get_sensor_evt_status(IPMIBmcSim *ibs,
IPMISensor *sens; IPMISensor *sens;
IPMI_CHECK_CMD_LEN(3); IPMI_CHECK_CMD_LEN(3);
if ((cmd[2] > MAX_SENSORS) || if ((cmd[2] >= MAX_SENSORS) ||
!IPMI_SENSOR_GET_PRESENT(ibs->sensors + cmd[2])) { !IPMI_SENSOR_GET_PRESENT(ibs->sensors + cmd[2])) {
rsp[2] = IPMI_CC_REQ_ENTRY_NOT_PRESENT; rsp[2] = IPMI_CC_REQ_ENTRY_NOT_PRESENT;
return; return;
...@@ -1565,7 +1565,7 @@ static void get_sensor_reading(IPMIBmcSim *ibs, ...@@ -1565,7 +1565,7 @@ static void get_sensor_reading(IPMIBmcSim *ibs,
IPMISensor *sens; IPMISensor *sens;
IPMI_CHECK_CMD_LEN(3); IPMI_CHECK_CMD_LEN(3);
if ((cmd[2] > MAX_SENSORS) || if ((cmd[2] >= MAX_SENSORS) ||
!IPMI_SENSOR_GET_PRESENT(ibs->sensors + cmd[2])) { !IPMI_SENSOR_GET_PRESENT(ibs->sensors + cmd[2])) {
rsp[2] = IPMI_CC_REQ_ENTRY_NOT_PRESENT; rsp[2] = IPMI_CC_REQ_ENTRY_NOT_PRESENT;
return; return;
...@@ -1588,7 +1588,7 @@ static void set_sensor_type(IPMIBmcSim *ibs, ...@@ -1588,7 +1588,7 @@ static void set_sensor_type(IPMIBmcSim *ibs,
IPMI_CHECK_CMD_LEN(5); IPMI_CHECK_CMD_LEN(5);
if ((cmd[2] > MAX_SENSORS) || if ((cmd[2] >= MAX_SENSORS) ||
!IPMI_SENSOR_GET_PRESENT(ibs->sensors + cmd[2])) { !IPMI_SENSOR_GET_PRESENT(ibs->sensors + cmd[2])) {
rsp[2] = IPMI_CC_REQ_ENTRY_NOT_PRESENT; rsp[2] = IPMI_CC_REQ_ENTRY_NOT_PRESENT;
return; return;
...@@ -1607,7 +1607,7 @@ static void get_sensor_type(IPMIBmcSim *ibs, ...@@ -1607,7 +1607,7 @@ static void get_sensor_type(IPMIBmcSim *ibs,
IPMI_CHECK_CMD_LEN(3); IPMI_CHECK_CMD_LEN(3);
if ((cmd[2] > MAX_SENSORS) || if ((cmd[2] >= MAX_SENSORS) ||
!IPMI_SENSOR_GET_PRESENT(ibs->sensors + cmd[2])) { !IPMI_SENSOR_GET_PRESENT(ibs->sensors + cmd[2])) {
rsp[2] = IPMI_CC_REQ_ENTRY_NOT_PRESENT; rsp[2] = IPMI_CC_REQ_ENTRY_NOT_PRESENT;
return; return;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册