From: InHong Han Date: Tue, 18 Jan 2022 07:41:34 +0000 (+0900) Subject: Fix issue detected by static analysis tool X-Git-Tag: accepted/tizen/unified/20220125.121610~1 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=84368c4023423dcc445b862f5a17f2ed96d802ab;p=platform%2Fcore%2Fuifw%2Fisf.git Fix issue detected by static analysis tool Time of check time of use (TOCTOU) Change-Id: I2e762e6170d14e423c855df39d3795e88e0c8cc2 --- diff --git a/ism/src/scim_socket.cpp b/ism/src/scim_socket.cpp index d84a0ea..4ae1c3f 100644 --- a/ism/src/scim_socket.cpp +++ b/ism/src/scim_socket.cpp @@ -623,20 +623,14 @@ public: // by connecting to it. SCIM_DEBUG_SOCKET (2) << "Try to remove the broken socket file: " << data_un->sun_path << "\n"; - if (::access (data_un->sun_path, F_OK) == 0) { - SocketClient tmp_socket (addr); - - if (!tmp_socket.is_connected ()) { - struct stat statbuf; - - // If it's a socket file, then - // delete it. - if (::stat (data_un->sun_path, &statbuf) == 0 && S_ISSOCK (statbuf.st_mode)) - ::unlink (data_un->sun_path); - } - - tmp_socket.close (); + SocketClient tmp_socket (addr); + if (!tmp_socket.is_connected ()) { + LOGE ("the connection is broken"); + if (::unlink (data_un->sun_path) != 0) + LOGE ("unlink() failed"); } + + tmp_socket.close (); } if (::bind (m_id, data, len) == 0) {