summaryrefslogtreecommitdiff
path: root/src/shared
Commit message (Collapse)AuthorAgeFilesLines
* Add verbose mode attribute handling (#292)Martin Willers2021-03-161-28/+107
| | | | | | dlt_user_log_write_*_attr() enables to writing these types, but also support adding "attributes" for them, i.e. a "name" and a "unit". Signed-off-by: Martin Willers <M.Willers@gmx.net>
* fscanf() uses dynamic formatting to prevent buffer overflow (#288)Kevin-Luong2021-01-291-2/+5
| | | | | | | CVE: CVE-2020-29394 Signed-off-by: KHANH LUONG HONG DUY <khanh.luonghongduy@vn.bosch.com> Co-authored-by: KHANH LUONG HONG DUY <khanh.luonghongduy@vn.bosch.com>
* gtest_dlt_common: fix seg fault when using memcpy().Dinh Cong Toan2021-01-061-5/+9
| | | | | | | | - Checking size of buffer and size of message before using memcpy(). - Adding configuration file for testfilter in /tests/CMakeLists.txt. Signed-off-by: Dinh Cong Toan <toan.dinhcong@vn.bosch.com>
* other: fix remaining conversion warningsDinh Cong Toan2021-01-062-40/+40
| | | | | | | | | | | - Converting datatype to the correct one. - As macro do not perform type-checking before, so these functions used it with different datatype could create a lot of conversion warnings. For this reason, these warnings could be consider as normal information and will not be fixed. Signed-off-by: Dinh Cong Toan <toan.dinhcong@vn.bosch.com>
* library: fix conversion warningsDinh Cong Toan(RBVH/ECM12)2021-01-061-21/+42
| | | | | | | | | | | | - Change the data type of variable 'size' in DltContextData struct (dlt_user.h.in). Variable 'size' was used repeated with function 'sizeof()' many time, so change type to 'size_t' can avoid a lot of warnings. - Adding temporary variable to calculate the datasize header (define in dlt_common.h) in 'dlt_common.c' file. Signed-off-by: Dinh Cong Toan(RBVH/ECM12) <Toan.DinhCong@vn.bosch.com>
* shared: fix conversion warningsiod1hc2021-01-062-69/+69
| | | | | | | | | | | - Data type of 'textlength' create a lot of warnings while using in function 'snprintf()', so change data type to 'size_t' will resolve these warnings. - Change data type of variable 'size' to the right type 'unsigned int', which is located in struct DltBuffer in dlt_common.h (line 832). Signed-off-by: Dinh Cong Toan <toan.dinhcong@vn.bosch.com> Signed-off-by: Saya Sugiura <ssugiura@jp.adit-jv.com>
* gateway: fix compile warningsDinh Cong Toan(RBVH/ECM12)2021-01-061-4/+3
| | | | | | | | | - Correct the data type of 'headersize' and 'datasize' variables in header 'dlt_common.h', then config those functions using this library. - Explicit the data type. Signed-off-by: Dinh Cong Toan(RBVH/ECM12) <Toan.DinhCong@vn.bosch.com>
* dlt_common: Execute system command using execvpKHANH LUONG HONG DUY2021-01-061-0/+55
| | | | | | | Add function dlt_execute_command() to execute system command using execvp. Signed-off-by: KHANH LUONG HONG DUY <khanh.luonghongduy@vn.bosch.com>
* bug-fix: fix invalid file descriptor checkAlexander Mohr2021-01-062-4/+9
| | | | | | | | | | | Some functions validated file descriptor to be greater 0. If a process is started without stdin, stdout and stderr the first file descriptor allocated by the process will be 0. This also will be the case if the above mentioned file descriptors will be closed on purpose. As 0 is a valid fd, some methods had to be changed to reflect this. Signed-off-by: Alexander Mohr <alexander.m.mohr@daimler.com>
* Add support for logging with VSOCK (#255)Martin Ejdestig2020-12-141-46/+12
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | For more information about VSOCK, see "man vsock" ( https://man7.org/linux/man-pages/man7/vsock.7.html ). Makes it possible for processes in a virtual machine to log directly in DLT running on host without setting up a network connection between guest and host. It is also probably more efficient. Have not done any performance measurements (not main reason for patch), but no forwarding is required as when running DLT in a multi-node setup. When building dlt-daemon for host, WITH_DLT_DAEMON_VSOCK_IPC should be enabled for daemon to listen on incoming VSOCK requests. Local communication method between applications and daemon is still determined with DLT_IPC. When building for guest, WITH_DLT_LIB_VSOCK_IPC should be enabled and DLT_IPC will be ignored, which will make libdlt open a VSOCK socket to the deamon for logging messages. VSOCK can be tested without a virtual machine. Since VMADDR_CID_HOST is used by libdlt when connecting, see vsock man page, clients can be run on host to test VSOCK communication. Some modifications has been done to be able to handle logging through FIFO pipe and socket in the same build of dlt-daemon: - dlt_receiver_init/free_unix_socket() is renamed to dlt_receiver_init/free_global_buffer() and used for FIFO as well. Also fixes memory leak since dlt_receiver_free_unix_socket() was used regardless of whether DLT_USE_UNIX_SOCKET was defined or not. - Pass type to dlt_receiver_init() instead of dlt_receiver_receive(). And remove preprocessor conditionals for handling DLT_CONNECTION_APP_MSG in dlt_daemon_process_user_messages(). Also fixes wrong enum type being passed to dlt_receiver_receive() in dlt_client.c (DltClient::mode was used as a DltReceiverType enum but it is a DltClientMode enum). - Add a flag to DltDaemonApplication to indicate whether file descriptor is "owned" by the DltDaemonApplication or not. When dlt_daemon_application_add() is called due to message received on a socket, fd is passed as an argument (app does not own fd). For FIFO, a per application FIFO is opened (app owns the fd). Also fixes so that user handle is reset for both application and all its contexts when resetting any. Prevents fd from being used by accident after it has been closed. dlt_mkdir_recursive() is moved to src/daemon since it is only used in the daemon. Minimizes use of DLT_USE_UNIX_SOCKET_IPC. Other bugfixes: - Call DLT_SEM_FREE() if setting socket to O_NONBLOCK fails in src/lib/dlt_user.c:dlt_initialize_socket_connection(). - Close socket if dlt_receiver_init() fails in src/lib/dlt_user.c:dlt_initialize_socket_connection(). Signed-off-by: Martin Ejdestig <martin.ejdestig@volvocars.com>
* Check size of ring buffer (#269)schrewe2020-12-071-12/+26
| | | | | | | | | | | | | | There is no check if "data" fits into the ring buffer buffer. This causes a write heap buffer overflow. If data is too big for the ringbuffer nothing is written to the ringbuffer and a error is logged If the buffers are bigger than the free space in the ringbuffer, the ringbuffer is increased by a step size set at initialization. But there is no check if this increase was sufficient. Fix this by using a while loop that increases the ring buffer size until it is big enough or the buffer can not be further increased. Signed-off-by: Jan Schrewe <schrewe@uni-bonn.de>
* dlt_common: Fix buffer overflow in dlt_filter_load (#275)gy7412020-11-301-2/+2
| | | | | | | A buffer overflow in the dlt_filter_load function in dlt_common.c in dlt-daemon allows arbitrary code execution via an unsafe usage of fscanf, because it does not limit the number of characters to be read in a format argument. Fixed: #274 Signed-off-by: GwanYeong Kim <gy741.kim@gmail.com>
* Avoid memory access errors with 4-chars context ids (#250)Martin Willers2020-11-171-8/+15
| | | | | | | | | | | | | | | | | | | | | | | | For a 4-chars CTXID, i.e. one that does not include a null character, the strlen() calls were happily accessing memory until they eventually encountered a null character somewhere in memory. This was detected by valgrind, which reported a memory error when using a CTXID such as "INTM": ==21924== Conditional jump or move depends on uninitialised value(s) ==21924== at 0x4C30F78: strlen (in /usr/lib/valgrind/vgpreload_memcheck-amd64-linux.so) ==21924== by 0x4E4B5A0: dlt_print_id (dlt_common.c:303) ==21924== by 0x4E4CF47: dlt_message_header_flags (dlt_common.c:687) ==21924== by 0x4E51434: dlt_message_print_ascii (dlt_common.c:3169) ==21924== by 0x4E4247A: dlt_user_print_msg (dlt_user.c:4108) ==21924== by 0x4E46D92: dlt_user_log_send_log (dlt_user.c:3670) ==21924== by 0x4E46F14: dlt_user_log_write_finish (dlt_user.c:1611) Sanitize some code Using memset() and memcpy() is always preferable to hand-rolled loops, because compilers have built-in support for them. Signed-off-by: Martin Willers <M.Willers@gmx.net>
* dlt-common.c: ensure null terminated string (#256)Moritz Warning2020-11-101-1/+1
| | | Signed-off-by: Moritz Warning <moritzwarning@web.de>
* Implement DLTClient for UDP multicast (#240)João Sousa2020-08-311-1/+14
| | | | | | | | | * Add UDP multicast support on client side UDP multicast support is already present on server side. This patch add seemless support for UDP multicast on client side in dlt-receive. Signed-off-by: Joao Sousa <joao.sa.sousa@ctw.bmwgroup.com>
* common: Isolate FIFO/Unix socketLUONG HONG DUY KHANH(RBVH/ENG42)2020-07-061-3/+9
| | | | | | | | | | | | | | dlt_common - Add preprocessor DLT_USE_UNIX_SOCKET_IPC for dlt_log_set_fifo_basedir() and dltFifoBaseDir variable - Rename input parameter of dlt_log_set_fifo_basedir() dlt-daemon - Replace setting dltFifoBaseDir by dlt_log_set_fifo_basedir() and add preproc DLT_USE_UNIX_SOCKET_IPC - Update -h opt and flags.loggingFilename based on IPC type Signed-off-by: LUONG HONG DUY KHANH(RBVH/ENG42) <KHANH.LUONGHONGDUY@vn.bosch.com>
* libdlt: Relocate dltFifoBaseDir settingLUONG HONG DUY KHANH(RBVH/ENG42)2020-07-061-0/+3
| | | | | | | Relocate the setting of dltFifoBaseDir variable from dlt_init() to dlt_check_envvar() Signed-off-by: LUONG HONG DUY KHANH(RBVH/ENG42) <KHANH.LUONGHONGDUY@vn.bosch.com>
* Improve performance of DLT file parsingBui Nguyen Quoc Thanh2020-07-061-0/+69
| | | | | | Introduce new API to support quick parsing a DLT file. Signed-off-by: Bui Nguyen Quoc Thanh <thanh.buinguyenquoc@vn.bosch.com>
* Redirect stdout to stderrLUONG HONG DUY KHANH(RBVH/ENG42)2020-07-061-13/+45
| | | | | | | | | | | | - daemon: New feature for LoggingMode at /etc/dlt.conf to be able to set value at 3 in order to redirect all stdout messages to stderr. - libdlt: New feature for DLT_LOG_MODE environment variable to be able to set value at 3 in order to redirect all stdout messages to stderr. - unit test: Add test cases for DLT_LOG_TO_STDERR Signed-off-by: LUONG HONG DUY KHANH(RBVH/ENG42) <KHANH.LUONGHONGDUY@vn.bosch.com>
* gateway: Improvement of handling Gateway configBui Nguyen Quoc Thanh2020-07-062-1/+29
| | | | | | | | | | | | | | In the current implementation, we believe in user to treat General section as Mandatory. Hence system could be reset due to memory of connections incorrectly. At the moment, General could be handled as Optional with default value of interval. It means General could be absent from config file. Improvement is to raise WARNING to user, set default value and update the number of connections properly. Signed-off-by: Bui Nguyen Quoc Thanh <Thanh.BuiNguyenQuoc@vn.bosch.com>
* gateway: Configurable interval timeBui Nguyen Quoc Thanh2020-07-061-0/+3
| | | | | | | | | - Introduce "General" section for dlt_gateway.conf - In new section, the interval is used for gateway timer. This entry is optional. By default, it is set to 1 second as the existing hardcoded value. Signed-off-by: Bui Nguyen Quoc Thanh <Thanh.BuiNguyenQuoc@vn.bosch.com>
* fix some gcc9 compiler warningsFelix Herrmann2020-07-063-15/+22
| | | | | | | | | Many stringop-truncation and stringop-overflow warnings are still there (so many). https://developers.redhat.com/blog/2018/05/24/detecting-string-truncation-with-gcc-8/ Signed-off-by: Felix Herrmann <fherrmann@de.adit-jv.com> Signed-off-by: KHANH LUONG HONG DUY <khanh.luonghongduy@vn.bosch.com>
* fix clang warnings about GNU stuffFelix Herrmann2020-07-061-2/+2
| | | | | Signed-off-by: Felix Herrmann <fherrmann@de.adit-jv.com> Signed-off-by: KHANH LUONG HONG DUY <khanh.luonghongduy@vn.bosch.com>
* Android: Enable Android buildFelix Herrmann2020-07-061-2/+5
| | | | | Signed-off-by: Felix Herrmann <fherrmann@de.adit-jv.com> Signed-off-by: KHANH LUONG HONG DUY <khanh.luonghongduy@vn.bosch.com>
* shared: Read DLT header until it's foundSaya Sugiura2020-07-061-13/+31
| | | | | | | | | Current dlt_file_read_header() function which is used for e.g. dlt-convert, dlt-sortbytimestamp, etc. stops finding DLT header if it's not available in the next file position. It is improved to read the header in a loop until it's found. Signed-off-by: Saya Sugiura <ssugiura@jp.adit-jv.com>
* rename definition PACKED to DLT_PACKEDFelix Herrmann2020-07-061-11/+11
| | | | | Signed-off-by: Felix Herrmann <external.Felix.Herrmann3@de.bosch.com> Signed-off-by: KHANH LUONG HONG DUY <khanh.luonghongduy@vn.bosch.com>
* Revert "dlt_common: Fix buffer overflow in dlt_buffer_get (#215)"Saya Sugiura2020-06-161-4/+2
| | | | This reverts commit e420ee62d89d5efab6ad7275910cb3eec8497da6.
* common: Fix uint64 type (#217)Saya Sugiura2020-04-021-1/+1
| | | | | | The log message was printed as a signed value for uint64 type. This commit fixes to print as an unsigned value. Signed-off-by: Saya Sugiura <ssugiura@jp.adit-jv.com>
* dlt_common: Fix buffer overflow in dlt_buffer_get (#215)Ricardo Leite2020-03-301-2/+4
| | | | | | A DLT lib user can create a message large enough that dlt_user.resend_buffer is not large enough, and thus it will overflow Signed-off-by: Ricardo Leite <rleite@dcc.fc.up.pt>
* FIX: Check validity of `file` pointer before usage.Sebastian Kloska2020-02-201-3/+3
| | | | | | | Check for file == null before accessing the pointer for a debug message Signed-off-by: Sebastian Kloska <sebastian.kloska@snafu.de>
* BugFix: SEGFAULT when using AppArmor (#192)Sebastian Kloska2019-12-101-14/+17
| | | | | | | | | | | | | | | | | | | | | | | * Symptome: If access to the trace directory is not granted by AppArmor access(...) still reports otherwise. dlt_offline_trace_get_total_size(...) tries to open the dir via opendir(...) and tries a readdir without any further check, which results in an SEGFAULT * Solution: (1) Make dlt_offline_trace_get_total_size return ssize_t instead of unsigned long, which gives us a chance to return an error state (2) Check the return value from opendir(...) and bail out on error. Use this to return DLT_RETURN_ERROR in dlt_offline_trace_check_size. * ToDo: (1) Error state is not yet checked and reported back. On Error we just don't generate any offline log files without any further complain. (2) Find a replacement for access(...) which reports properly under AppArmor. (3) Report the confusing behaviour of access(...) to the AppArmor team. Signed-off-by: Sebastian Kloska <seebastian.kloska@snafu.de>
* Fix compiler warnings: pointer of type ‘void *’ used in arithmetic (#196)Sebastian Lipponer2019-12-101-2/+2
| | | Signed-off-by: Sebastian Lipponer <mail@sebastianlipponer.de>
* Change the DLT_CHECK_RCV_DATA_SIZE macro to an internal function (#191)Sebastian Lipponer2019-11-251-0/+10
| | | | | | | | | The use of this macro in a if condition is actually non-standard C++ code. GCC issues a warning that ISO C++ forbids braced-groups within expressions when compiled with -Wpedantic. Other compilers fail with an error. Change the macro to an internal function in order to improve the portability to other platforms (i.e. MSVC, proprietary embedded). Signed-off-by: Sebastian Lipponer <mail@sebastianlipponer.de>
* dlt-offline-trace: fix bug and hardcode (#174) (#186)Vo Trung Chi2019-11-141-20/+37
| | | | | | | | Fix the issue that DLT offline trace creating mutiple files even after reaching MaxTrace size when filename is index based. Related to: https://github.com/GENIVI/dlt-daemon/pull/174 Signed-off-by: Vo Trung Chi <chi.votrung@vn.bosch.com>
* Avoided Seg fault in dlt_message_payload (#179) (#181)Vo Trung Chi2019-11-141-54/+60
| | | | | | | | | * Avoided Seg fault in dlt_message_payload (#179) Avoided Seg fault by adding boundary check before buffer access. Signed-off-by: Ravi Sankar P <ponnurangamravi.sankar@in.bosch.com> Signed-off-by: Vo Trung Chi <chi.votrung@vn.bosch.com>
* fix the dlt offline trace file name creation (#178)Vo Trung Chi2019-10-291-13/+16
| | | | | | | The function dlt_offline_trace_file_name() use sizeof the pointer as the maximum file name size, so it cannot create the file name as expected. Signed-off-by: Vo Trung Chi <chi.votrung@vn.bosch.com>
* libdlt: fix memory leakVo Trung Chi2019-10-241-8/+20
| | | | | | | This commit is fixed the memory leak in case the dlt application do reattach to the daemon. Signed-off-by: Vo Trung Chi <chi.votrung@vn.bosch.com>
* dlt-system: Call tzset before localtime_r (#165)Saya Sugiura2019-09-232-0/+2
| | | | | | Since localtime() was calling tzset() internally, it should be used before localtime_r(). Refer to man page of localtime_r() for detail. Signed-off-by: Saya Sugiura <ssugiura@jp.adit-jv.com>
* parser: Change maximum number of config sectionVo Trung Chi2019-09-132-3/+3
| | | | | | This commit includes improvement of related code. Signed-off-by: Vo Trung Chi <Chi.VoTrung@vn.bosch.com>
* dlt_common: Use defined macroVo Trung Chi2019-09-131-1/+1
| | | | Signed-off-by: Vo Trung Chi <Chi.VoTrung@vn.bosch.com>
* protocol: Remove non supported user service ID (#159)Saya Sugiura2019-09-021-3/+7
| | | | | | | | | | With this commit, following DLT user service IDs are now free to use: - 0xF0A - 0xF0F to 0xFFE Also the cases in dlt_daemon_client_process_control() is reordered so that it matches the order of dlt_user_services enum. Signed-off-by: Saya Sugiura <ssugiura@jp.adit-jv.com>
* using POSIX shared memory APIs (#90) (#151)Vo Trung Chi2019-08-012-100/+259
| | | | | Replace all Linux specific shared memory APIs with POSIX alternatives. Signed-off-by: Vo Trung Chi <Chi.VoTrung@vn.bosch.com>
* Correct sa findingsSaya Sugiura2019-07-241-12/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | dlt_offline_logstorage.c - Parameter to isdigit is not correct - Handle the size of memset() and strncpy() properly dlt-test-stress-user.c - Parameter d is duplicated dlt_env_ll.c - Parameter env is used before NULL check - Remove redundant line dlt-control-common.c dlt_daemon_event_handler.c - Do not use NULL variable to print log dlt_config_file_parser.c - Remove unnecessary loop dlt_daemon_client.c - Return error in NULL check dlt_user.c - Free allocated memory in error case Related commit: 5c8f88d logstorage: fix compile error Signed-off-by: Saya Sugiura <ssugiura@jp.adit-jv.com>
* doxygen: Remove licenceSaya Sugiura2019-07-1910-20/+0
| | | | Signed-off-by: Saya Sugiura <ssugiura@jp.adit-jv.com>
* doxygen: Get rid of warningsSaya Sugiura2019-07-192-1/+2
| | | | Signed-off-by: Saya Sugiura <ssugiura@jp.adit-jv.com>
* fix config path for dlt-dbusRadoslaw Kaczorowski2019-07-031-1/+1
| | | | | | use default config path relative to CONFIGURATION_FILES_DIR Signed-off-by: Vo Trung Chi <Chi.VoTrung@vn.bosch.com>
* define DLT_PATH_MAX for max path buffer lengthRadoslaw Kaczorowski2019-07-031-4/+4
| | | | | | | | DLT limits the path length and does not do anything else to determine the actual value, because the least that is supported on any system that DLT runs on is 1024 bytes. Signed-off-by: Vo Trung Chi <Chi.VoTrung@vn.bosch.com>
* fix the warning of strncat sizePhong Tran2019-06-241-4/+4
| | | | | | | | | | | | | clang warns that warning: size argument in 'strncat' call appears to be size of the source [-Wstrncat-size] strncat(log_file_name, file_index, sizeof(file_index)); ^~~~~~~~~~~~~~~~~~ do as the https://github.com/llvm-mirror/clang/blob/05be53c9524408516651d5678d55d0d4a5d3a894/test/Sema/warn-strncat-size.c#L30 Signed-off-by: Phong Tran <tranmanphong@gmail.com>
* fix warning of self assignPhong Tran2019-06-241-1/+1
| | | | | | | | | | use (void)xyz instead of self assign error log: error: explicitly assigning value of variable of type 'void *' to itself [-Werror,-Wself-assign] Signed-off-by: Phong Tran <tranmanphong@gmail.com>
* cleanup: Use dlt_vlog()Saya Sugiura2019-06-192-101/+56
| | | | | | | There were a couple of places which used snprintf-dlt_log. It is now replaced with dlt_vlog(). Signed-off-by: Saya Sugiura <ssugiura@jp.adit-jv.com>