Remove nameoffset variable from packDomainName
This is now always equal to off, so use that instead.
This commit is contained in:
parent
03053758d4
commit
926752f160
8
msg.go
8
msg.go
|
@ -208,7 +208,6 @@ func packDomainName(s string, msg []byte, off int, compression map[string]int, c
|
||||||
// There is also a trailing zero.
|
// There is also a trailing zero.
|
||||||
|
|
||||||
// Compression
|
// Compression
|
||||||
nameoffset := -1
|
|
||||||
pointer := -1
|
pointer := -1
|
||||||
|
|
||||||
// Emit sequence of counted strings, chopping at dots.
|
// 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 is true, we're allowed to compress this dname
|
||||||
if compress {
|
if compress {
|
||||||
pointer = p // Where to point to
|
pointer = p // Where to point to
|
||||||
nameoffset = off // Where to point from
|
|
||||||
break loop
|
break loop
|
||||||
}
|
}
|
||||||
} else if off < maxCompressionOffset {
|
} else if off < maxCompressionOffset {
|
||||||
|
@ -322,8 +320,8 @@ loop:
|
||||||
if pointer != -1 {
|
if pointer != -1 {
|
||||||
// We have two bytes (14 bits) to put the pointer in
|
// We have two bytes (14 bits) to put the pointer in
|
||||||
// if msg == nil, we will never do compression
|
// if msg == nil, we will never do compression
|
||||||
binary.BigEndian.PutUint16(msg[nameoffset:], uint16(pointer^0xC000))
|
binary.BigEndian.PutUint16(msg[off:], uint16(pointer^0xC000))
|
||||||
off = nameoffset + 1
|
off++
|
||||||
} else if msg != nil && off < len(msg) {
|
} else if msg != nil && off < len(msg) {
|
||||||
msg[off] = 0
|
msg[off] = 0
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue