Fix duplicate 10= checksum when resending a message ending in a repeating group#767
Open
raphaelroshan wants to merge 1 commit into
Open
Conversation
… group When a stored message whose body ends in a repeating group is parsed with a DataDictionary, parseGroup set trailerBytes to the (now-empty) rawBytes after consuming the trailer field, so the caller's bodyBytes strip removed nothing and left the 10= trailer embedded in bodyBytes. On resend, buildWithBodyBytes wrote that contaminated bodyBytes and appended a fresh 10=, producing two checksum tags and a wrong BodyLength, which the counterparty rejects. parseGroup now restores the pre-extract buffer (which still holds the trailer) when it detects the trailer field, so the strip removes it as in the non-group path. Adds a dictionary-based resend test covering a body that ends in a group.
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.
Fixes #761.
Problem
When a stored outbound message whose body ends in a repeating group is parsed with a
DataDictionary(the resend path always uses one),parseGroupleaks the10=trailer intoMessage.bodyBytes. On resend,buildWithBodyByteswrites that contaminatedbodyBytesand appends a freshly computed10=on top — producing two10=tags and a wrongBodyLength. The counterparty rejects withInvalid checksumand drops the session.All three conditions are required: a
DataDictionaryis configured, the body contains a repeating group, and the counterparty sends aResendRequest.Root cause
parseGroup's loop setsmp.trailerBytes = mp.rawBytesafterextractFieldconsumes each field. When it consumes the trailer field (10=NNN),rawBytesis empty, sotrailerBytes = "". The caller's stripthen removes zero bytes, leaving the trailer embedded. The non-group
defaultpath is unaffected because it setstrailerByteswhilerawBytesstill includes the upcoming trailer.Fix
parseGroupsnapshots the pre-extract buffer and, on detecting the trailer field, restorestrailerBytesto it (the buffer that still holds10=NNN), so the strip removes the trailer exactly as the non-group path does.Test
Added
TestReBuildWithRepeatingGroupWithDictionaryForResend: parses a message ending in a453group with a FIX44 dictionary and asserts (a)bodyBytesno longer contains the trailer and (b) the resend built frombodyBytescarries exactly one10=. Fails before, passes after. Existing tests and the full package suite pass.