Skip to content
Permalink
Browse files

dns: use length for building TXT string

Rely on the length reported by C-Ares rather than `\0`-termination
for creating the JS string for a dns TXT response.

Fixes: #30688

PR-URL: #30690
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: David Carlier <devnexen@gmail.com>
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: James M Snell <jasnell@gmail.com>
  • Loading branch information
addaleax authored and MylesBorins committed Nov 27, 2019
1 parent 646b81c commit ded0748dea3933c231a9734be5dfb816ff55b61f
Showing with 3 additions and 2 deletions.
  1. +2 −1 src/cares_wrap.cc
  2. +1 −1 test/parallel/test-dns-resolveany.js
@@ -906,7 +906,8 @@ int ParseTxtReply(Environment* env,
uint32_t i = 0, j;
uint32_t offset = ret->Length();
for (j = 0; current != nullptr; current = current->next) {
Local<String> txt = OneByteString(env->isolate(), current->txt);
Local<String> txt =
OneByteString(env->isolate(), current->txt, current->length);

// New record found - write out the current chunk
if (current->record_start) {
@@ -11,7 +11,7 @@ const answers = [
{ type: 'AAAA', address: '::42', ttl: 123 },
{ type: 'MX', priority: 42, exchange: 'foobar.com', ttl: 124 },
{ type: 'NS', value: 'foobar.org', ttl: 457 },
{ type: 'TXT', entries: [ 'v=spf1 ~all', 'xyz' ] },
{ type: 'TXT', entries: [ 'v=spf1 ~all', 'xyz\0foo' ] },
{ type: 'PTR', value: 'baz.org', ttl: 987 },
{
type: 'SOA',

0 comments on commit ded0748

Please sign in to comment.
You can’t perform that action at this time.