Check nsec unpacking

This commit is contained in:
Miek Gieben 2012-01-15 20:46:11 +01:00
parent 84700f043f
commit 1ae8cb4101
1 changed files with 10 additions and 5 deletions

15
msg.go
View File

@ -642,14 +642,15 @@ func unpackStructValue(val reflect.Value, msg []byte, off int) (off1 int, ok boo
seen := 2
for seen < rdlength {
window = int(msg[off])
//println("off", off, "lenmsg", lenmsg)
length = int(msg[off+1])
if length == 0 {
// Last one
break
}
if length == 0 {
// Last one
break
}
if length > 32 {
//println("dns: overflow unpacking NSEC")
// Funny, this happens, but isn't an error. TODO(mg)
// Funny, this happens, but isn't an error. TODO(mg)
break
}
@ -684,6 +685,10 @@ func unpackStructValue(val reflect.Value, msg []byte, off int) (off1 int, ok boo
}
off += length
seen += length + 2
if off+1 > lenmsg {
println("dns: overflow unpacking NSEC")
return lenmsg, false
}
}
fv.Set(reflect.ValueOf(nsec))
}