Do not assume ModSecurityIntervention argument to transaction::intervention has been initialized/cleaned #3212
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.
what
Minor changes to transaction::intervention to guarantee to caller that all members of the
ModSecurityIntervention
have been initialized if an intervention should be made and that the return value of the function is consistent with the state of the transaction.why
The current version of Transaction::intervention assumes (and implicitly requires) that the
ModSecurityIntervention
argument has been initialized/cleaned before the call.This is not necessarily expected because the parameter is used as an output parameter and it's not clear that any input is provided to the function.
Additionally, in order to make the API more robust, when the function returns that an intervention should be made, initialize all members in the structure to guarantee to the caller that all of them can be safely accessed and interpreted.
changes
m_it->disruptive
value and use it as return value to guarantee that the value is correct.m_it->disruptive
isfalse
and theit
argument has not been initialized/cleaned, the function may incorrectly return a non-zero value.log
&url
fields toNULL
if there's no such data to provide to the caller.it
argument, after returning fromtransaction::intervention
, the user can safely read thelog
&url
fields (and call cleanup functions such asintervention::free
ormsc_intervention_cleanup
-introduced in PR Add cleanup methods to complete C based ABI #3209).Transaction::intervention
&msc_intervention
.