-
Notifications
You must be signed in to change notification settings - Fork 307
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor legacy code to bypass warning - Phase 1 #736
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -302,7 +302,7 @@ static DltReturnValue dlt_initialize_socket_connection(void) | |
} | ||
|
||
remote.sun_family = AF_UNIX; | ||
snprintf(dltSockBaseDir, DLT_IPC_PATH_MAX, "%s/dlt", DLT_USER_IPC_PATH); | ||
snprintf(dltSockBaseDir, DLT_IPC_PATH_MAX, "%.1019s/dlt", DLT_USER_IPC_PATH); | ||
strncpy(remote.sun_path, dltSockBaseDir, sizeof(remote.sun_path)); | ||
|
||
if (strlen(DLT_USER_IPC_PATH) > DLT_IPC_PATH_MAX) | ||
|
@@ -401,8 +401,9 @@ static DltReturnValue dlt_initialize_fifo_connection(void) | |
char filename[DLT_PATH_MAX]; | ||
int ret; | ||
|
||
snprintf(dlt_user_dir, DLT_PATH_MAX, "%s/dltpipes", dltFifoBaseDir); | ||
snprintf(dlt_daemon_fifo, DLT_PATH_MAX, "%s/dlt", dltFifoBaseDir); | ||
// Explicitly truncate long paths | ||
snprintf(dlt_user_dir, DLT_PATH_MAX, "%.1014s/dltpipes", dltFifoBaseDir); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hi @minminlittleshrimp |
||
snprintf(dlt_daemon_fifo, DLT_PATH_MAX, "%.1019s/dlt", dltFifoBaseDir); | ||
ret = mkdir(dlt_user_dir, S_IRUSR | S_IWUSR | S_IXUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH | S_ISVTX); | ||
|
||
if ((ret == -1) && (errno != EEXIST)) { | ||
|
@@ -424,7 +425,13 @@ static DltReturnValue dlt_initialize_fifo_connection(void) | |
} | ||
|
||
/* create and open DLT user FIFO */ | ||
snprintf(filename, DLT_PATH_MAX, "%s/dlt%d", dlt_user_dir, getpid()); | ||
/* /dlt%d consists of 4 bytes "/dlt" and pid field (INT_MAX = 2147483647 - 32 bit) | ||
* The worst case: "/dlt2147483647" | ||
* Total: 4 + 4 + '\0' = 9 bytes | ||
* DLT_PATH_MAX = 1024 bytes | ||
* Space left: 1024 - 9 = 1015 bytes | ||
*/ | ||
snprintf(filename, DLT_PATH_MAX, "%.1015s/dlt%d", dlt_user_dir, getpid()); | ||
|
||
/* Try to delete existing pipe, ignore result of unlink */ | ||
unlink(filename); | ||
|
@@ -1082,7 +1089,7 @@ DltReturnValue dlt_free(void) | |
if (dlt_user.dlt_user_handle != DLT_FD_INIT) { | ||
close(dlt_user.dlt_user_handle); | ||
dlt_user.dlt_user_handle = DLT_FD_INIT; | ||
snprintf(filename, DLT_PATH_MAX, "%s/dlt%d", dlt_user_dir, getpid()); | ||
snprintf(filename, DLT_PATH_MAX, "%.1015s/dlt%d", dlt_user_dir, getpid()); | ||
unlink(filename); | ||
} | ||
|
||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -13,33 +13,33 @@ | |
# For further information see http://www.covesa.org/. | ||
####### | ||
|
||
set(TARGET_LIST ${TARGET_LIST} dlt-test-multi-process) | ||
set(TARGET_LIST ${TARGET_LIST} dlt-test-multi-process-client) | ||
set(TARGET_LIST ${TARGET_LIST} dlt-test-user) | ||
set(TARGET_LIST ${TARGET_LIST} dlt-test-client) | ||
set(TARGET_LIST ${TARGET_LIST} dlt-test-stress-user) | ||
set(TARGET_LIST ${TARGET_LIST} dlt-test-stress-client) | ||
set(TARGET_LIST ${TARGET_LIST} dlt-test-stress) | ||
set(TARGET_LIST ${TARGET_LIST} dlt-test-fork-handler) | ||
set(TARGET_LIST ${TARGET_LIST} dlt-test-init-free) | ||
set(TARGET_LIST ${TARGET_LIST} dlt-test-preregister-context) | ||
set(TARGET_LIST ${TARGET_LIST} dlt-test-filetransfer) | ||
set(TARGET_LIST ${TARGET_LIST} dlt-test-multi-process.c) | ||
set(TARGET_LIST ${TARGET_LIST} dlt-test-multi-process-client.c) | ||
set(TARGET_LIST ${TARGET_LIST} dlt-test-user.c) | ||
set(TARGET_LIST ${TARGET_LIST} dlt-test-client.c) | ||
set(TARGET_LIST ${TARGET_LIST} dlt-test-stress-user.c) | ||
set(TARGET_LIST ${TARGET_LIST} dlt-test-stress-client.c) | ||
set(TARGET_LIST ${TARGET_LIST} dlt-test-stress.c) | ||
set(TARGET_LIST ${TARGET_LIST} dlt-test-fork-handler.c) | ||
set(TARGET_LIST ${TARGET_LIST} dlt-test-init-free.c) | ||
set(TARGET_LIST ${TARGET_LIST} dlt-test-preregister-context.c) | ||
set(TARGET_LIST ${TARGET_LIST} dlt-test-filetransfer.c) | ||
install(FILES dlt-test-filetransfer-file dlt-test-filetransfer-image.png | ||
DESTINATION share/dlt-filetransfer) | ||
|
||
if(WITH_DLT_CXX11_EXT) | ||
set(TARGET_LIST ${TARGET_LIST} dlt-test-cpp-extension) | ||
set(TARGET_LIST ${TARGET_LIST} dlt-test-cpp-extension.cpp) | ||
endif() | ||
|
||
#TODO: Enable again once dlt-test-non-verbose is adapted to non-macro usage | ||
if (NOT WITH_DLT_DISABLE_MACRO) | ||
set(TARGET_LIST ${TARGET_LIST} dlt-test-non-verbose) | ||
set(TARGET_LIST ${TARGET_LIST} dlt-test-non-verbose.c) | ||
endif() | ||
|
||
if(WITH_DLT_QNX_SYSTEM) | ||
set(TARGET_LIST ${TARGET_LIST} dlt-test-qnx-slogger) | ||
set(TARGET_LIST ${TARGET_LIST} dlt-test-qnx-slogger.c) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hi @minminlittleshrimp |
||
endif() | ||
|
||
foreach(TARGET IN LISTS TARGET_LIST) | ||
set(TARGET_SRCS ${TARGET}) | ||
add_executable(${TARGET} ${TARGET_SRCS}) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @minminlittleshrimp
Can you give explaination of this code change? Why do we need to remove this checking?