From: akoszewski Date: Mon, 18 Sep 2017 12:22:45 +0000 (+0200) Subject: Fix error checking for socket fd X-Git-Tag: accepted/tizen/4.0/unified/20171011.150507^0 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=69cf735e393962bd4b01a6f4b64862c6c1a9c25d;p=platform%2Fcore%2Fsecurity%2Ftef-simulator.git Fix error checking for socket fd This is needed for cases when socket fd is equal to 0 Change-Id: Idb5926594f47cfad21fb8c6cc36a3b815ef667a0 --- diff --git a/TEECLib/src/teec_connection.c b/TEECLib/src/teec_connection.c index 889ee82..af623ea 100644 --- a/TEECLib/src/teec_connection.c +++ b/TEECLib/src/teec_connection.c @@ -116,7 +116,7 @@ static uint32_t sendCommandtoDaemon(int32_t sockfd, char* fdata, size_t size) { ssize_t nwrite = 0; size_t nbytes = 0; - if (sockfd > 0) { + if (sockfd >= 0) { // send size number of bytes to Simulator Daemon do { nwrite = send(sockfd, fdata + nbytes, size - nbytes, 0); @@ -145,7 +145,7 @@ static uint32_t receiveResponse(int32_t sockfd, char* fdata, size_t size) { ssize_t nread = 0; size_t nbytes = 0; - if (sockfd > 0) { + if (sockfd >= 0) { // receive size number of bytes to Simulator Daemon do { nread = recv(sockfd, fdata + nbytes, size - nbytes, 0); diff --git a/ssflib/src/ssf_client.cpp b/ssflib/src/ssf_client.cpp index 14b7f8d..00b07e4 100644 --- a/ssflib/src/ssf_client.cpp +++ b/ssflib/src/ssf_client.cpp @@ -101,7 +101,7 @@ static uint32_t sendCommandtoDaemon(int32_t sockfd, char* fdata, size_t size) { LOGD(SSF_LIB, "Entry"); ssize_t nwrite = 0; size_t nbytes = 0; - if (sockfd > 0) { + if (sockfd >= 0) { do { nwrite = send(sockfd, fdata + nbytes, size - nbytes, 0); } while ((nwrite == -1 && errno == EINTR) || (nwrite > 0 && ((nbytes += @@ -124,7 +124,7 @@ static uint32_t receiveResponse(int32_t sockfd, char* fdata, size_t size) { LOGD(SSF_LIB, "Entry"); ssize_t nread = 0; size_t nbytes = 0; - if (sockfd > 0) { + if (sockfd >= 0) { do { nread = recv(sockfd, fdata + nbytes, size - nbytes, 0); } while ((nread == -1 && errno == EINTR)