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
Signed-off-by: Chalapathi Venkataramashetty <chalapathix.venkataramashetty@intel.com>
Change-Id: Id99f5ef1515263ac3dbf2edec7f94b0b4badb4e3
diff --git a/src/sensorcommands.cpp b/src/sensorcommands.cpp
index ff429b6..2fd0fbe 100644
--- a/src/sensorcommands.cpp
+++ b/src/sensorcommands.cpp
@@ -398,6 +398,11 @@
std::string connection;
std::string path;
+ if (sensnum == reservedSensorNumber)
+ {
+ return ipmi::responseInvalidFieldRequest();
+ }
+
auto status = getSensorConnection(ctx, sensnum, connection, path);
if (status)
{
@@ -574,6 +579,11 @@
{
constexpr uint8_t thresholdMask = 0xFF;
+ if (sensorNum == reservedSensorNumber)
+ {
+ return ipmi::responseInvalidFieldRequest();
+ }
+
if (reserved)
{
return ipmi::responseInvalidFieldRequest();
@@ -796,6 +806,11 @@
std::string connection;
std::string path;
+ if (sensorNumber == reservedSensorNumber)
+ {
+ return ipmi::responseInvalidFieldRequest();
+ }
+
auto status = getSensorConnection(ctx, sensorNumber, connection, path);
if (status)
{
@@ -884,6 +899,11 @@
uint8_t deassertionEnabledLsb = 0;
uint8_t deassertionEnabledMsb = 0;
+ if (sensorNum == reservedSensorNumber)
+ {
+ return ipmi::responseInvalidFieldRequest();
+ }
+
auto status = getSensorConnection(ctx, sensorNum, connection, path);
if (status)
{