-
Notifications
You must be signed in to change notification settings - Fork 371
Open
Description
Hi,
In some cases , the "pos" value in RFC5322 class (mail/rfc5321/address.go) becomes -2, that leads to an runtime error (index out of range) in the functions peek() & next() in Parser class (mail/rfc5321/parse.go).
It happens here, if pos = -1.
s.pos = pos - 1 //- 1 // rewind to the saved position
This is line from this function (mail/rfc5321/address.go).
// mailbox = name-addr / addr-spec
func (s *RFC5322) mailbox() error {
pos := s.pos // save the position
if err := s.nameAddr(); err != nil {
if err == errExpectingAngleAddress && s.ch != ':' { // ':' means it's a group
// we'll attempt to parse as an email address without angle brackets
s.addr.DisplayName = ""
s.addr.DisplayNameQuoted = false
s.pos = pos - 1 //- 1 // rewind to the saved position
if s.pos > -1 {
s.ch = s.buf[s.pos]
}
if err = s.Parser.mailbox(); err != nil {
return err
}
s.addAddress()
} else {
return err
}
}
return nil
}
Thanks!
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels