varlink: ensure that userdata is always valid#18171
Closed
topimiettinen wants to merge 1 commit intosystemd:masterfrom
Closed
varlink: ensure that userdata is always valid#18171topimiettinen wants to merge 1 commit intosystemd:masterfrom
topimiettinen wants to merge 1 commit intosystemd:masterfrom
Conversation
Member
|
structured initialization in C sets unmentioned fields to zero implicitly, hence you patch changes exactly nothing. We typically only initialize the fields that shall not be zero when using structured initialization. |
Contributor
Author
|
The fix could also/instead include one or more of the below
|
Contributor
Author
|
Hmm. Could this be a bug in the compiler? |
Contributor
Author
|
How about this: varlink_server_add_connection() invoked by connect_callback() sets the Varlink->userdata from VarlinkServer->userdata. In case of resolved, it expects Varlink->userdata to be a DnsQuery but VarlinkServer->userdata is a Manager. So perhaps the fix could be to change varlink_server_add_connection() to use NULL instead. |
Contributor
Author
|
Actually, just remove this line. |
In case the callers use struct Varlink field `userdata` without first setting it, it will contain a non-NULL pointer but possibly pointing to wrong data, so let's keep the NULL from varlink_new() instead of initializing it from VarlinkServer->userdata.
d3e1f6e to
77247bd
Compare
Contributor
Author
|
Let's scratch this, it doesn't work. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
a48481d removed zero initialization of struct Varlink in
varlink_new(). However, the callers may (wrongly) use field
userdatawithoutfirst setting it, so let's set it to NULL.