Skip to content

Commit a6c8e40

Browse files
XadillaXaddaleax
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: #25840 Fixes: #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 <info@bnoordhuis.nl> Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: James M Snell <jasnell@gmail.com>
1 parent 015ed0b commit a6c8e40

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)