Skip to content

Commit

Permalink
daemon: unix socket checking before creating new
Browse files Browse the repository at this point in the history
+ unix socket used for unittesting (gateway)
+ unix socket spamming removed

Signed-off-by: LUU QUANG MINH <[email protected]>
  • Loading branch information
LUU QUANG MINH authored and LUU QUANG MINH committed Jun 27, 2024
1 parent 8fc4e8e commit b1b757d
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,7 @@ if(WITH_GIT_SUBMODULE)
endif()

if(WITH_DLT_UNIT_TESTS)
set(DLT_IPC "UNIX_SOCKET")
find_package(GTest)
if(GTEST_FOUND)
find_package(PkgConfig REQUIRED)
Expand Down
8 changes: 5 additions & 3 deletions src/daemon/dlt_daemon_unix_socket.c
Original file line number Diff line number Diff line change
Expand Up @@ -145,9 +145,11 @@ int dlt_daemon_unix_socket_open(int *sock, char *sock_path, int type, int mask)
addr.sun_family = AF_UNIX;
memcpy(addr.sun_path, sock_path, sizeof(addr.sun_path));

if (unlink(sock_path) != 0) {
dlt_vlog(LOG_WARNING, "%s: unlink() failed: %s\n",
__func__, strerror(errno));
if (access(sock_path, F_OK) == 0) {
if(unlink(sock_path) != 0) {

Check failure

Code scanning / CodeQL

Time-of-check time-of-use filesystem race condition High

The
filename
being operated upon was previously
checked
, but the underlying file may have been changed since then.
dlt_vlog(LOG_WARNING, "%s: unlink() failed: %s\n",
__func__, strerror(errno));
}
}

/* set appropriate access permissions */
Expand Down

0 comments on commit b1b757d

Please sign in to comment.