Skip to content

Commit 053c179

Browse files
addaleaxtargos
authored andcommitted
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>
1 parent d6c211d commit 053c179

2 files changed

Lines changed: 3 additions & 2 deletions

File tree

‎src/cares_wrap.cc‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -906,7 +906,8 @@ int ParseTxtReply(Environment* env,
906906
uint32_t i = 0, j;
907907
uint32_t offset = ret->Length();
908908
for (j = 0; current != nullptr; current = current->next) {
909-
Local<String> txt = OneByteString(env->isolate(), current->txt);
909+
Local<String> txt =
910+
OneByteString(env->isolate(), current->txt, current->length);
910911

911912
// New record found - write out the current chunk
912913
if (current->record_start) {

‎test/parallel/test-dns-resolveany.js‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ const answers = [
1111
{type: 'AAAA',address: '::42',ttl: 123},
1212
{type: 'MX',priority: 42,exchange: 'foobar.com',ttl: 124},
1313
{type: 'NS',value: 'foobar.org',ttl: 457},
14-
{type: 'TXT',entries: ['v=spf1 ~all','xyz']},
14+
{type: 'TXT',entries: ['v=spf1 ~all','xyz\0foo']},
1515
{type: 'PTR',value: 'baz.org',ttl: 987},
1616
{
1717
type: 'SOA',

0 commit comments

Comments
 (0)