Fix DS overflow when unpacking
This commit is contained in:
parent
7b67cbff49
commit
04cbdae47a
8
msg.go
8
msg.go
|
@ -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":
|
||||
|
|
Loading…
Reference in New Issue