Remove nameoffset variable from packDomainName

This is now always equal to off, so use that instead.
This commit is contained in:
Tom Thorogood 2018-11-26 15:05:51 +10:30
parent 03053758d4
commit 926752f160
No known key found for this signature in database
GPG Key ID: 86C63CDA416C6D2F
1 changed files with 3 additions and 5 deletions

8
msg.go
View File

@ -208,7 +208,6 @@ func packDomainName(s string, msg []byte, off int, compression map[string]int, c
// There is also a trailing zero.
// Compression
nameoffset := -1
pointer := -1
// Emit sequence of counted strings, chopping at dots.
@ -281,8 +280,7 @@ loop:
// If compress is true, we're allowed to compress this dname
if compress {
pointer = p // Where to point to
nameoffset = off // Where to point from
pointer = p // Where to point to
break loop
}
} else if off < maxCompressionOffset {
@ -322,8 +320,8 @@ loop:
if pointer != -1 {
// We have two bytes (14 bits) to put the pointer in
// if msg == nil, we will never do compression
binary.BigEndian.PutUint16(msg[nameoffset:], uint16(pointer^0xC000))
off = nameoffset + 1
binary.BigEndian.PutUint16(msg[off:], uint16(pointer^0xC000))
off++
} else if msg != nil && off < len(msg) {
msg[off] = 0
}