commit 423f4bb77221c4eddedec84554eca9b036abef3c
parent c3610791a32991d46814afa36c19a9c2521424ec
Author: Drew DeVault <sir@cmpwn.com>
Date: Wed, 23 Jun 2021 17:58:25 -0400
net::dns: fix AAAA decoding error
Signed-off-by: Drew DeVault <sir@cmpwn.com>
Diffstat:
2 files changed, 5 insertions(+), 6 deletions(-)
diff --git a/net/dns/decode.ha b/net/dns/decode.ha
@@ -102,7 +102,6 @@ fn decode_name(dec: *decoder) ([]str | format) = {
dec.cur = dec.cur[z..];
for (let i = 0z; i < len(name); i += 1) {
if (!ascii::isascii(name[i]: u32: rune)) {
- fmt::errorfln("not ascii at index {}", i)!;
return format;
};
};
@@ -160,12 +159,12 @@ fn decode_a(dec: *decoder) (rdata | format) = {
};
fn decode_aaaa(dec: *decoder) (rdata | format) = {
- if (len(dec.cur) < 8) {
+ if (len(dec.cur) < 16) {
return format;
};
let ip: ip::addr6 = [0...];
- ip[..] = dec.cur[..8];
- dec.cur = dec.cur[8..];
+ ip[..] = dec.cur[..16];
+ dec.cur = dec.cur[16..];
return ip: aaaa;
};
diff --git a/net/dns/query.ha b/net/dns/query.ha
@@ -15,7 +15,7 @@ export fn query(query: *message, servers: ip::addr...) (*message | error) = {
servers = [[127, 0, 0, 1]: ip::addr4];
};
- let socket = udp::listen(ip::ANY_V4, 0)?;
+ const socket = udp::listen(ip::ANY_V4, 0)?;
defer udp::close(socket);
// TODO: Use TCP for messages >512 bytes
@@ -46,7 +46,7 @@ export fn query(query: *message, servers: ip::addr...) (*message | error) = {
continue;
};
- let dec = decoder_init(recvbuf[..z]);
+ const dec = decoder_init(recvbuf[..z]);
decode_header(&dec, &header)?;
if (header.id == query.header.id && header.op.qr == qr::RESPONSE) {
break;