Commit a9fb25c7 authored by Marek Vavruša's avatar Marek Vavruša

modules/dns64: bad expectation of ffi.copy semantics

the copy doesn't take cdata length into account, but measures string len

refs #43
parent 623a7631
......@@ -334,7 +334,7 @@ ffi.metatype( knot_pkt_t, {
end,
begin = function (pkt, section) return knot.knot_pkt_begin(pkt, section) end,
put = function (pkt, owner, ttl, rclass, rtype, rdata)
return C.kr_pkt_put(pkt, owner, ttl, rclass, rtype, rdata, string.len(rdata))
return C.kr_pkt_put(pkt, owner, ttl, rclass, rtype, rdata, #rdata)
end,
clear = function (pkt) return C.kr_pkt_recycle(pkt) end,
question = function(pkt, qname, qclass, qtype)
......
......@@ -28,7 +28,7 @@ mod.layer = {
local rr = answer[i]
-- Synthesise AAAA from A
if rr.type == kres.type.A then
ffi.copy(addr_buf, mod.proxy)
ffi.copy(addr_buf, mod.proxy, 16)
ffi.copy(addr_buf + 12, rr.rdata, 4)
req.answer:put(rr.owner, rr.ttl, rr.class, kres.type.AAAA, ffi.string(addr_buf, 16))
end
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment