Skip to content
This repository was archived by the owner on Sep 16, 2023. It is now read-only.

Commit 4cc9b5f

Browse files
XadillaXdanbev
authored andcommitted
deps: patch to fix *.onion MX query on c-ares
c-ares rejects *.onion MX query but forgot to set `*bufp` to NULL. This will occur SegmentFault when free `*bufp`. I make this quick fix and then will make a PR for c-ares either. PR-URL: nodejs#25840 Fixes: nodejs#25839 Refs: https://github.com/c-ares/c-ares/blob/955df98/ares_create_query.c#L97-L103 Refs: https://github.com/c-ares/c-ares/blob/955df98/ares_query.c#L124 Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Anna Henningsen <[email protected]> Reviewed-By: Richard Lau <[email protected]> Reviewed-By: James M Snell <[email protected]>
1 parent 686043e commit 4cc9b5f

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

deps/cares/src/ares_create_query.c

+4-4
Original file line numberDiff line numberDiff line change
@@ -94,14 +94,14 @@ int ares_create_query(const char *name, int dnsclass, int type,
9494
size_t buflen;
9595
unsigned char *buf;
9696

97-
/* Per RFC 7686, reject queries for ".onion" domain names with NXDOMAIN. */
98-
if (ares__is_onion_domain(name))
99-
return ARES_ENOTFOUND;
100-
10197
/* Set our results early, in case we bail out early with an error. */
10298
*buflenp = 0;
10399
*bufp = NULL;
104100

101+
/* Per RFC 7686, reject queries for ".onion" domain names with NXDOMAIN. */
102+
if (ares__is_onion_domain(name))
103+
return ARES_ENOTFOUND;
104+
105105
/* Allocate a memory area for the maximum size this packet might need. +2
106106
* is for the length byte and zero termination if no dots or ecscaping is
107107
* used.

test/parallel/test-dns.js

+10
Original file line numberDiff line numberDiff line change
@@ -314,3 +314,13 @@ common.expectsError(() => {
314314
code: 'ERR_INVALID_CALLBACK',
315315
type: TypeError
316316
});
317+
318+
{
319+
dns.resolveMx('foo.onion', function(err) {
320+
assert.deepStrictEqual(err.errno, 'ENOTFOUND');
321+
assert.deepStrictEqual(err.code, 'ENOTFOUND');
322+
assert.deepStrictEqual(err.syscall, 'queryMx');
323+
assert.deepStrictEqual(err.hostname, 'foo.onion');
324+
assert.deepStrictEqual(err.message, 'queryMx ENOTFOUND foo.onion');
325+
});
326+
}

0 commit comments

Comments
 (0)