From 57ca5ae8f427ca95d7e7bb9d70c3022ffdff3a0f Mon Sep 17 00:00:00 2001 From: Tom Thorogood Date: Fri, 4 Jan 2019 20:49:01 +1030 Subject: [PATCH] Use headerSize const instead of hardcoded 12 (#894) --- defaults.go | 2 +- msg.go | 2 +- sig0.go | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/defaults.go b/defaults.go index 6eb079d2..c6d108dc 100644 --- a/defaults.go +++ b/defaults.go @@ -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 diff --git a/msg.go b/msg.go index f5be33fc..bfd0011b 100644 --- a/msg.go +++ b/msg.go @@ -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) diff --git a/sig0.go b/sig0.go index 2657f847..ec65dd7f 100644 --- a/sig0.go +++ b/sig0.go @@ -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)