apphandler: fix Set System Info command

Return proper error response for reserved data bytes

as per the ipmi specification,Set System Info parameters
takes block of string data and the first byte indicates the
encoding of the string. the bits[7:4] are reserved.

string data byte 1:
[7:4] - reserved
[3:0] - encoding
0h = ASCII+Latin1
1h = UTF-8
2h = UNICODE
all other = reserved.

This patch verifies if the reserveds bits
are being used and return proper error response

tested
//Before Fix:
1)Paramter 1
 ipmitool raw 0x06 0x58 0x01 0x00 0x03 0x0e 0x56 0x65 0x72 0x73 0x69 0x6f 0x6e 0x32 0x2e 0x31 0x32 0x33 0x34 0x35

2)Parameter 2
ipmitool raw 0x06 0x58 0x02 0x00 0x03 0x0e 0x56 0x65 0x72 0x73 0x69 0x6f 0x6e 0x32 0x2e 0x31 0x32 0x33 0x34 0x35

3)Parameter 3:
ipmitool raw 0x06 0x58 0x01 0x00 0x03 0x0e 0x56 0x65 0x72 0x73 0x69 0x6f 0x6e 0x32 0x2e 0x31 0x32 0x33 0x34 0x35

//After Fix:
1)Parameter 1
ipmitool  raw 0x06 0x58 0x01 0x00 0x03 0x0e 0x56 0x65 0x72 0x73 0x69 0x6f 0x6e 0x32 0x2e 0x31 0x32 0x33 0x34  0x35
Unable to send RAW command (channel=0x0 netfn=0x6 lun=0x0 cmd=0x58 rsp=0xcc): Invalid data field in request

2)Parameter 2
ipmitool raw 0x06 0x58 0x02 0x00 0x03 0x0e 0x56 0x65 0x72 0x73 0x69 0x6f 0x6e 0x32 0x2e 0x31 0x32 0x33 0x34 0x35
Unable to send RAW command (channel=0x0 netfn=0x6 lun=0x0 cmd=0x58 rsp=0xcc): Invalid data field in request

3)Parameter 3:
ipmitool raw 0x06 0x58 0x01 0x00 0x03 0x0e 0x56 0x65 0x72 0x73 0x69 0x6f 0x6e 0x32 0x2e 0x31 0x32 0x33 0x34 0x35
Unable to send RAW command (channel=0x0 netfn=0x6 lun=0x0 cmd=0x58 rsp=0xcc): Invalid data field in request

Change-Id: I8ac2c582bfc9029dc01008bbd665603562a9f275
Signed-off-by: krishnar4 <krishnar@ami.com>
diff --git a/apphandler.cpp b/apphandler.cpp
index fd735bb..65390c1 100644
--- a/apphandler.cpp
+++ b/apphandler.cpp
@@ -1315,6 +1315,7 @@
 static constexpr size_t smallChunkSize = 14;
 static constexpr size_t fullChunkSize = 16;
 static constexpr uint8_t progressMask = 0x3;
+static constexpr uint8_t maxValidEncodingData = 0x02;
 
 static constexpr uint8_t setComplete = 0x0;
 static constexpr uint8_t setInProgress = 0x1;
@@ -1492,8 +1493,14 @@
 
     uint8_t setSelector = data1;
     size_t count = 0;
-    if (setSelector == 0)                    // First chunk has only 14 bytes.
+    if (setSelector == 0) // First chunk has only 14 bytes.
     {
+        uint8_t encoding = configData.at(0);
+        if (encoding > maxValidEncodingData)
+        {
+            return ipmi::responseInvalidFieldRequest();
+        }
+
         size_t stringLen = configData.at(1); // string length
         // maxBytesPerParamter is 256. It will always be greater than stringLen
         // (unit8_t) if maxBytes changes in future, then following line is