-
Notifications
You must be signed in to change notification settings - Fork 299
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
dlt-user: fix invalid return in dlt_user_log_write_start_internal #641
dlt-user: fix invalid return in dlt_user_log_write_start_internal #641
Conversation
dlt_user_log_write_start_internal might return OK when the buffer was not initalized, this can lead to other functions assuming that the buffer was setup correctly and thus access invalid memory. Signed-off-by: Alexander Mohr <alexander.m.mohr@mercedes-benz.com>
3087a41
to
c6eeabe
Compare
@@ -1838,7 +1838,7 @@ DltReturnValue dlt_user_log_write_start_internal(DltContext *handle, | |||
return DLT_RETURN_WRONG_PARAMETER; | |||
} else if (ret == DLT_RETURN_LOGGING_DISABLED) { | |||
log->handle = NULL; | |||
return DLT_RETURN_OK; |
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.
Would it be meaning that the behavior of some scenarios when logging disabled should be by-passed here?
I believe there could be some reasons behind doing this.
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.
Would it be meaning that the behavior of some scenarios when logging disabled should be by-passed here?
I didn't find such a thing but maybe I just missed it. But I'm not sure if it's a good idea to abuse it like this.
If we keep return OK here it should be clearly documented that log->buffer is only initialized when log->handle is not null. We had a crash because an application assumed that the buffer is set up when ok is returned and did not check log->handle.
Closing this as it has unintended side effects in dlt-qnx-system leading to breaking that service. |
Hello @alexmohr |
so the actual crash that we had is due to an internal feature we're developing at the moment (which we will upstream eventually once its mature)
The crash happened when dlt_user_log_write returned true when the buffer in fact was not initialized, so it was logical to me to introduce the change in this pull request. In dlt-qnx-slogger2-adapter.cppsloggerinfo_callback::sloggerinfo_callback It's just a bit confusing that |
dlt_user_log_write_start_internal might return OK when the buffer was not initialized, this can lead to other functions assuming that the buffer was setup correctly and thus access invalid memory.
The program was tested solely for our own use cases, which might differ from yours.
Licensed under Mozilla Public License Version 2.0
Alexander Mohr, alexander.m.mohr@mercedes-benz.com, Mercedes-Benz Tech Innovation GmbH, imprint