Skip to content

Commit

Permalink
Modify msg verify checks
Browse files Browse the repository at this point in the history
  • Loading branch information
ackleymi committed Sep 9, 2024
1 parent 7194eee commit 2e7e077
Showing 1 changed file with 20 additions and 5 deletions.
25 changes: 20 additions & 5 deletions session.go
Original file line number Diff line number Diff line change
Expand Up @@ -509,7 +509,8 @@ func (s *session) handleLogon(msg *Message) error {

nextSenderMsgNumAtLogonReceived := s.store.NextSenderMsgSeqNum()

if err := s.verifyIgnoreSeqNumTooHigh(msg); err != nil {
// Make sure this is a valid session before resetting the store.
if err := s.verifyMsgAgainstAppImpl(msg); err != nil {
return err
}

Expand All @@ -529,6 +530,12 @@ func (s *session) handleLogon(msg *Message) error {
}
}

// Verify seq num too high but dont check against app implementation since we just did that.
// Don't need to double check.
if err := s.verifySelect(msg, false, true, false); err != nil {
return err
}

if !s.InitiateLogon {
if !s.HeartBtIntOverride {
var heartBtInt FIXInt
Expand Down Expand Up @@ -586,18 +593,18 @@ func (s *session) initiateLogoutInReplyTo(reason string, inReplyTo *Message) (er
}

func (s *session) verify(msg *Message) MessageRejectError {
return s.verifySelect(msg, true, true)
return s.verifySelect(msg, true, true, true)
}

func (s *session) verifyIgnoreSeqNumTooHigh(msg *Message) MessageRejectError {
return s.verifySelect(msg, false, true)
return s.verifySelect(msg, false, true, true)
}

func (s *session) verifyIgnoreSeqNumTooHighOrLow(msg *Message) MessageRejectError {
return s.verifySelect(msg, false, false)
return s.verifySelect(msg, false, false, true)
}

func (s *session) verifySelect(msg *Message, checkTooHigh bool, checkTooLow bool) MessageRejectError {
func (s *session) verifySelect(msg *Message, checkTooHigh bool, checkTooLow bool, checkAppImpl bool) MessageRejectError {
if reject := s.checkBeginString(msg); reject != nil {
return reject
}
Expand Down Expand Up @@ -626,6 +633,14 @@ func (s *session) verifySelect(msg *Message, checkTooHigh bool, checkTooLow bool
}
}

if checkAppImpl {
return s.verifyMsgAgainstAppImpl(msg)
}

return nil
}

func (s *session) verifyMsgAgainstAppImpl(msg *Message) MessageRejectError {
if s.Validator != nil {
if reject := s.Validator.Validate(msg); reject != nil {
return reject
Expand Down

0 comments on commit 2e7e077

Please sign in to comment.