Fix the nsec/3 length calculation
This overshoots, 'cause it only counts the windows, not the actual bitmap sizes in the window. But it keeps the code simple and fast.
This commit is contained in:
parent
3f40afaafd
commit
9fa50d8ac2
4
msg.go
4
msg.go
|
@ -1255,7 +1255,7 @@ func (dns *Msg) Pack() (msg []byte, err error) {
|
|||
dh.Nscount = uint16(len(ns))
|
||||
dh.Arcount = uint16(len(extra))
|
||||
|
||||
msg = make([]byte, dns.packLen()+10) // TODO(miekg): +10 should go soon
|
||||
msg = make([]byte, dns.packLen()+1) // TODO(miekg): +10 should go soon
|
||||
// Pack it in: header and then the pieces.
|
||||
off := 0
|
||||
off, err = packStructCompress(&dh, msg, off, compression, dns.Compress)
|
||||
|
@ -1489,8 +1489,8 @@ func compressionLenSearch(c map[string]int, s string) (int, bool) {
|
|||
}
|
||||
off, end = NextLabel(s, off)
|
||||
}
|
||||
// TODO(miek): not sure if need, leave this for later debugging
|
||||
if _, ok := c[s[off:]]; ok {
|
||||
println("HIERO", s[off:]) // TODO(miek): remove this println
|
||||
return len(s[off:]), true
|
||||
}
|
||||
return 0, false
|
||||
|
|
25
types.go
25
types.go
|
@ -756,9 +756,16 @@ func (rr *NSEC) String() string {
|
|||
}
|
||||
|
||||
func (rr *NSEC) len() int {
|
||||
l := len(rr.NextDomain) + 1
|
||||
return rr.Hdr.len() + l + 32 + 1
|
||||
// TODO: +32 is max type bitmap
|
||||
l := rr.Hdr.len() + len(rr.NextDomain) + 1
|
||||
lastwindow := uint32(2^32+1)
|
||||
for _, t := range rr.TypeBitMap {
|
||||
window := t / 256
|
||||
if uint32(window) != lastwindow {
|
||||
l += 1 + 32
|
||||
}
|
||||
lastwindow = uint32(window)
|
||||
}
|
||||
return l
|
||||
}
|
||||
|
||||
type DS struct {
|
||||
|
@ -1023,8 +1030,16 @@ func (rr *NSEC3) String() string {
|
|||
}
|
||||
|
||||
func (rr *NSEC3) len() int {
|
||||
return rr.Hdr.len() + 6 + len(rr.Salt)/2 + 1 + len(rr.NextDomain) + 1 + 32
|
||||
// TODO: +32 is MAX type bit map
|
||||
l := rr.Hdr.len() + 6 + len(rr.Salt)/2 + 1 + len(rr.NextDomain) + 1
|
||||
lastwindow := uint32(2^32+1)
|
||||
for _, t := range rr.TypeBitMap {
|
||||
window := t / 256
|
||||
if uint32(window) != lastwindow {
|
||||
l += 1 + 32
|
||||
}
|
||||
lastwindow = uint32(window)
|
||||
}
|
||||
return l
|
||||
}
|
||||
|
||||
type NSEC3PARAM struct {
|
||||
|
|
Loading…
Reference in New Issue