diff --git a/src/rs.c b/src/rs.c index 3794190d..fe92062d 100644 --- a/src/rs.c +++ b/src/rs.c @@ -377,9 +377,15 @@ hsk_rs_onrecv( goto fail; } + // Unbound's name resolution API expects a single null-terminated string. + // Since 0x00 is a valid byte mid-label in wire format we need to + // convert `req->name` to presentation format (i.e. "\000" for 0x00) + if (!hsk_dns_name_to_string(req->name, req->namestr)) + goto fail; + rc = hsk_rs_worker_resolve( ns->rs_worker, - req->name, + req->namestr, req->type, req->class, (void *)req, @@ -426,7 +432,9 @@ hsk_rs_respond( goto fail; } - hsk_rs_log(ns, "received answer for: %s\n", req->name); + char namestr[HSK_DNS_MAX_NAME_STRING] = {0}; + assert(hsk_dns_name_to_string(req->name, namestr)); + hsk_rs_log(ns, "received answer for: %s\n", namestr); if (result->canonname) hsk_rs_log(ns, " canonname: %s\n", result->canonname);