Fix sendToServer function.
authorBartlomiej Grzelewski <b.grzelewski@samsung.com>
Tue, 16 Jul 2013 17:06:47 +0000 (19:06 +0200)
committerBartlomiej Grzelewski <b.grzelewski@samsung.com>
Thu, 6 Feb 2014 16:13:21 +0000 (17:13 +0100)
Security server closes connection when protocol is broken.
Client was not able to handle this situation.

[Issue#]   N/A
[Bug]      Client program may hang.
[Cause]    sendToServer function does not support
           situation when read returns 0.
[Problem]  N/A
[Solution] N/A

[Verification] Run tests.

Change-Id: Ie3002ae88c6ac4b55958b4e0d2d81ca5aacd5c43

src/server2/client/client-common.cpp

index b21c25d..e626f68 100644 (file)
@@ -194,6 +194,12 @@ int sendToServer(char const * const interface, const RawBuffer &send, SocketBuff
             LogError("Error in read: " << strerror(err));
             return SECURITY_SERVER_API_ERROR_SOCKET;
         }
+
+        if (0 == temp) {
+            LogError("Read return 0/Connection closed by server(?)");
+            return SECURITY_SERVER_API_ERROR_SOCKET;
+        }
+
         RawBuffer raw(buffer, buffer+temp);
         recv.Push(raw);
     } while(!recv.Ready());