Fix DS overflow when unpacking

This commit is contained in:
Miek Gieben 2012-01-23 20:29:47 +01:00
parent 7b67cbff49
commit 04cbdae47a
1 changed files with 4 additions and 4 deletions

8
msg.go
View File

@ -764,10 +764,6 @@ func unpackStructValue(val reflect.Value, msg []byte, off int) (off1 int, ok boo
case "hex":
// Rest of the RR is hex encoded, network order an issue here?
rdlength := int(val.FieldByName("Hdr").FieldByName("Rdlength").Uint())
if off+rdlength > lenmsg {
// too large
return lenmsg, false
}
var consumed int
switch val.Type().Name() {
case "RR_DS":
@ -781,6 +777,10 @@ func unpackStructValue(val reflect.Value, msg []byte, off int) (off1 int, ok boo
default:
consumed = 0 // return len(msg), false?
}
if off+rdlength-consumed > lenmsg {
println("dns: overflow when unpacking hex string")
return lenmsg, false
}
s = hex.EncodeToString(msg[off : off+rdlength-consumed])
off += rdlength - consumed
case "base64":