Fix bug found by Klocwork 61/52161/1
authorKrzysztof Jackiewicz <k.jackiewicz@samsung.com>
Thu, 19 Nov 2015 10:43:20 +0000 (11:43 +0100)
committerKrzysztof Jackiewicz <k.jackiewicz@samsung.com>
Thu, 19 Nov 2015 10:46:10 +0000 (11:46 +0100)
[Problem] The command received from encryption service is deserialized into a
variable hiding function argument of the same name. Also the received command
was ignored.
[Solution] Check if received command is equal to requested one.

[Verification] Run ckm-tests --group=CKM_ENCRYPTION_DECRYPTION

Change-Id: I16e14dbc8497a9b6ea11d93c8c0a48071562d684

src/manager/client/client-manager-impl.cpp

index 790e541..d6a464e 100644 (file)
@@ -794,11 +794,11 @@ int Manager::Impl::crypt(EncryptionCommand command,
         if (CKM_API_SUCCESS != retCode)
             return retCode;
 
-        int command;
+        int retCommand;
         int counter;
-        recv.Deserialize(command, counter, retCode, output);
+        recv.Deserialize(retCommand, counter, retCode, output);
 
-        if (my_counter != counter) {
+        if (my_counter != counter || retCommand != static_cast<int>(command)) {
             return CKM_API_ERROR_UNKNOWN;
         }