Skip to content

Commit

Permalink
fix parse error for z_sender_sockaddr
Browse files Browse the repository at this point in the history
  • Loading branch information
krawthekrow authored and davidben committed Apr 16, 2018
1 parent 32b16d1 commit c24380c
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
8 changes: 7 additions & 1 deletion notice.go
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,13 @@ func DecodeRawNotice(r *RawNotice) (*Notice, error) {

var senderAddress net.IP
if len(r.HeaderFields) > senderSockaddrIndex {
ipBytes, err := DecodeZcode(r.HeaderFields[senderSockaddrIndex])
sockaddrField := r.HeaderFields[senderSockaddrIndex]
var ipBytes []byte
if len(sockaddrField) != 0 && sockaddrField[0] == 'Z' {
ipBytes, err = DecodeZcode(sockaddrField)
} else {
ipBytes, err = DecodeZAscii(sockaddrField)
}
if err != nil {
return nil, err
}
Expand Down
2 changes: 1 addition & 1 deletion raw_notice.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ const (
multipartIndex // string
multiuidIndex // 12-byte zascii
// Added in 2009; no version bump
senderSockaddrIndex // zcode
senderSockaddrIndex // zcode or zascii
charsetIndex // zascii16 little-endian
// Other fields
numKnownFields
Expand Down

0 comments on commit c24380c

Please sign in to comment.