Use headerSize const instead of hardcoded 12 (#894)

This commit is contained in:
Tom Thorogood 2019-01-04 20:49:01 +10:30 committed by Miek Gieben
parent 34be74deeb
commit 57ca5ae8f4
3 changed files with 3 additions and 3 deletions

View File

@ -243,7 +243,7 @@ func IsSubDomain(parent, child string) bool {
// The checking is performed on the binary payload.
func IsMsg(buf []byte) error {
// Header
if len(buf) < 12 {
if len(buf) < headerSize {
return errors.New("dns: bad message header")
}
// Header: Opcode

2
msg.go
View File

@ -988,7 +988,7 @@ func (dns *Msg) Len() int {
}
func msgLenWithCompressionMap(dns *Msg, compression map[string]struct{}) int {
l := 12 // Message header is always 12 bytes
l := headerSize
for _, r := range dns.Question {
l += r.len(l, compression)

View File

@ -103,7 +103,7 @@ func (rr *SIG) Verify(k *KEY, buf []byte) error {
anc := binary.BigEndian.Uint16(buf[6:])
auc := binary.BigEndian.Uint16(buf[8:])
adc := binary.BigEndian.Uint16(buf[10:])
offset := 12
offset := headerSize
var err error
for i := uint16(0); i < qdc && offset < buflen; i++ {
_, offset, err = UnpackDomainName(buf, offset)