-
Notifications
You must be signed in to change notification settings - Fork 848
Fixes silent header duplication that occurs upon successful revalidation when duplicate headers are present #9527
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
Merged
elsloo
merged 3 commits into
apache:master
from
elsloo:fix_revalidation_duplicate_header_corruption
Mar 22, 2023
Merged
Fixes silent header duplication that occurs upon successful revalidation when duplicate headers are present #9527
elsloo
merged 3 commits into
apache:master
from
elsloo:fix_revalidation_duplicate_header_corruption
Mar 22, 2023
Conversation
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
…s upon successful revalidation when duplicate headers are present - Inner loop's auto `spot2` iterator contains a member variable, `_block` that references the memory address of the response headers, not the cached headers - Method called on the `cached_headers` object uses a memory address, not a named header, and leads to all response headers being deleted from the duplicate header forward - Once response headers are deleted, the first duplicate header is written to the cached headers as a new and *additional* field which leads to duplication in the cached object's headers, then the current iteration ends - The iterator of the outer loop then attempts to increment forward one step via the overridden `++` operator on `spot`, and due to header slot checks via `MIMEField::is_live()` within `MIMEHdrImpl::iterator::step()`, `_slot` is incremented to `limit` and iteration of the outer loop halts, because all response headers from that point forward were deleted in the prior iteration - This change moves away from the address-based approach to delete the header and instead uses the header name - Using the header name instead of relying on header alignment also fixes a secondary issue that could arise if response header ordering does not match the cached object's header ordering - Using the header name is slightly less efficient due to having to call `find_header`, however, this is necessary to ensure the cached headers are correctly removed before the response headers are merged into the cached object - Using a slightly less efficient approach that occurs only on successful revalidations that also contain duplicate headers should be acceptable given the tradeoff is allowing duplication if response header ordering differs from the cached object - Due to the existing logic, if a cached header is *not* in the response, it will remain in the cached object's headers Thanks to Masakazu and Leif for providing the unit test and helping with the fix, respectively. Co-Authored-By: Masakazu Kitajo <maskit@apache.org> Co-Authored-By: Leif Hedstrom <zwoop@apache.org>
Contributor
|
This is a serious bug introduced with v9.2.0, from #7476. The fix here restores the behavior as it was prior to that PR, using the API that ends up calling |
Co-Authored-By: Masakazu Kitajo <maskit@apache.org>
SolidWallOfCode
approved these changes
Mar 21, 2023
zwoop
added a commit
that referenced
this pull request
Mar 31, 2023
…ion when duplicate headers are present (#9527) * Fixes silent header duplication and early loop termination that occurs upon successful revalidation when duplicate headers are present - Inner loop's auto `spot2` iterator contains a member variable, `_block` that references the memory address of the response headers, not the cached headers - Method called on the `cached_headers` object uses a memory address, not a named header, and leads to all response headers being deleted from the duplicate header forward - Once response headers are deleted, the first duplicate header is written to the cached headers as a new and *additional* field which leads to duplication in the cached object's headers, then the current iteration ends - The iterator of the outer loop then attempts to increment forward one step via the overridden `++` operator on `spot`, and due to header slot checks via `MIMEField::is_live()` within `MIMEHdrImpl::iterator::step()`, `_slot` is incremented to `limit` and iteration of the outer loop halts, because all response headers from that point forward were deleted in the prior iteration - This change moves away from the address-based approach to delete the header and instead uses the header name - Using the header name instead of relying on header alignment also fixes a secondary issue that could arise if response header ordering does not match the cached object's header ordering - Using the header name is slightly less efficient due to having to call `find_header`, however, this is necessary to ensure the cached headers are correctly removed before the response headers are merged into the cached object - Using a slightly less efficient approach that occurs only on successful revalidations that also contain duplicate headers should be acceptable given the tradeoff is allowing duplication if response header ordering differs from the cached object - Due to the existing logic, if a cached header is *not* in the response, it will remain in the cached object's headers Thanks to Masakazu and Leif for providing the unit test and helping with the fix, respectively. Co-Authored-By: Masakazu Kitajo <maskit@apache.org> Co-Authored-By: Leif Hedstrom <zwoop@apache.org> * Attempt to fix the Debian build failure. Co-Authored-By: Masakazu Kitajo <maskit@apache.org> * Added a dependency for the unit test. --------- Co-authored-by: Masakazu Kitajo <maskit@apache.org> Co-authored-by: Leif Hedstrom <zwoop@apache.org> (cherry picked from commit c7ed799)
Contributor
|
Reverted from 9.2.x, in favor of #9534 |
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.
spot2iterator contains a member variable,_blockthat references the memory address of the response headers, not the cached headerscached_headersobject uses a memory address, not a named header, and leads to all response headers being deleted from the duplicate header forward++operator onspot, and due to header slot checks viaMIMEField::is_live()withinMIMEHdrImpl::iterator::step(),_slotis incremented tolimitand iteration of the outer loop halts, because all response headers from that point forward were deleted in the prior iterationfind_header, however, this is necessary to ensure the cached headers are correctly removed before the response headers are merged into the cached objectThanks to Masakazu and Leif for providing the unit test and helping with the fix, respectively.