sensorcommands: check for reserved sensor number in sensor commands.
Add support to check for reserved sensor number (0xFF) in sensor
commands.
Tested:
Command: Set Sensor Threshold
ipmitool raw 0x04 0x26 0xff 0x00 0x3a 0xab 0x03 0x02 0xef 0x63
Response: Unable to send RAW command (channel=0x0 netfn=0x4 lun=0x0
cmd=0x26 rsp=0xcc): Invalid data field in request
Ported From:
https://gerrit.openbmc-project.xyz/c/openbmc/intel-ipmi-oem/+/44032
Signed-off-by: Chalapathi Venkataramashetty <chalapathix.venkataramashetty@intel.com>
Change-Id: Id99f5ef1515263ac3dbf2edec7f94b0b4badb4e3
Signed-off-by: Willy Tu <wltu@google.com>
diff --git a/dbus-sdr/sensorcommands.cpp b/dbus-sdr/sensorcommands.cpp
index f0f99a3..7cbd29f 100644
--- a/dbus-sdr/sensorcommands.cpp
+++ b/dbus-sdr/sensorcommands.cpp
@@ -643,6 +643,11 @@
std::string connection;
std::string path;
+ if (sensnum == reservedSensorNumber)
+ {
+ return ipmi::responseInvalidFieldRequest();
+ }
+
auto status = getSensorConnection(ctx, sensnum, connection, path);
if (status)
{
@@ -868,7 +873,7 @@
uint8_t upperNonCritical, uint8_t upperCritical,
uint8_t upperNonRecoverable)
{
- if (reserved)
+ if (sensorNum == reservedSensorNumber || reserved)
{
return ipmi::responseInvalidFieldRequest();
}
@@ -1090,6 +1095,11 @@
std::string connection;
std::string path;
+ if (sensorNumber == reservedSensorNumber)
+ {
+ return ipmi::responseInvalidFieldRequest();
+ }
+
auto status = getSensorConnection(ctx, sensorNumber, connection, path);
if (status)
{
@@ -1178,6 +1188,11 @@
uint8_t deassertionEnabledLsb = 0;
uint8_t deassertionEnabledMsb = 0;
+ if (sensorNum == reservedSensorNumber)
+ {
+ return ipmi::responseInvalidFieldRequest();
+ }
+
auto status = getSensorConnection(ctx, sensorNum, connection, path);
if (status)
{