diff options
author | Alexander Mohr <alexander.m.mohr@daimler.com> | 2020-12-16 17:31:50 +0100 |
---|---|---|
committer | Saya Sugiura <ssugiura@jp.adit-jv.com> | 2021-01-06 09:12:00 +0900 |
commit | cbd51314c3245174b42070a66089b27472486b00 (patch) | |
tree | e5a57eb24e17b081088da5115e0afaa03d96601e /src/shared/dlt_user_shared.c | |
parent | e7858cfa226f760b6f7ba9a43501ac071b2fd8a8 (diff) | |
download | DLT-daemon-cbd51314c3245174b42070a66089b27472486b00.tar.gz |
bug-fix: fix invalid file descriptor check
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>
Diffstat (limited to 'src/shared/dlt_user_shared.c')
-rw-r--r-- | src/shared/dlt_user_shared.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/src/shared/dlt_user_shared.c b/src/shared/dlt_user_shared.c index 857a6e9..732301c 100644 --- a/src/shared/dlt_user_shared.c +++ b/src/shared/dlt_user_shared.c @@ -108,7 +108,7 @@ DltReturnValue dlt_user_log_out2(int handle, void *ptr1, size_t len1, void *ptr2 struct iovec iov[2]; uint32_t bytes_written; - if (handle <= 0) + if (handle < 0) /* Invalid handle */ return DLT_RETURN_ERROR; @@ -130,7 +130,7 @@ DltReturnValue dlt_user_log_out3(int handle, void *ptr1, size_t len1, void *ptr2 struct iovec iov[3]; uint32_t bytes_written; - if (handle <= 0) + if (handle < 0) /* Invalid handle */ return DLT_RETURN_ERROR; @@ -145,6 +145,11 @@ DltReturnValue dlt_user_log_out3(int handle, void *ptr1, size_t len1, void *ptr2 if (bytes_written != (len1 + len2 + len3)) { switch (errno) { + case ETIMEDOUT: + { + return DLT_RETURN_PIPE_ERROR; /* ETIMEDOUT - connect timeout */ + break; + } case EBADF: { return DLT_RETURN_PIPE_ERROR; /* EBADF - handle not open */ |