Skip to content

Commit

Permalink
deps: patch to fix *.onion MX query on c-ares
Browse files Browse the repository at this point in the history
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 <[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]>
  • Loading branch information
XadillaX authored and addaleax committed Feb 6, 2019
1 parent 015ed0b commit a6c8e40
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
8 changes: 4 additions & 4 deletions deps/cares/src/ares_create_query.c
Original file line number Diff line number Diff line change
Expand Up @@ -94,14 +94,14 @@ int ares_create_query(const char *name, int dnsclass, int type,
size_t buflen;
unsigned char *buf;

/* Per RFC 7686, reject queries for ".onion" domain names with NXDOMAIN. */
if (ares__is_onion_domain(name))
return ARES_ENOTFOUND;

/* Set our results early, in case we bail out early with an error. */
*buflenp = 0;
*bufp = NULL;

/* Per RFC 7686, reject queries for ".onion" domain names with NXDOMAIN. */
if (ares__is_onion_domain(name))
return ARES_ENOTFOUND;

/* Allocate a memory area for the maximum size this packet might need. +2
* is for the length byte and zero termination if no dots or ecscaping is
* used.
Expand Down
10 changes: 10 additions & 0 deletions test/parallel/test-dns.js
Original file line number Diff line number Diff line change
Expand Up @@ -314,3 +314,13 @@ common.expectsError(() => {
code: 'ERR_INVALID_CALLBACK',
type: TypeError
});

{
dns.resolveMx('foo.onion', function(err) {
assert.deepStrictEqual(err.errno, 'ENOTFOUND');
assert.deepStrictEqual(err.code, 'ENOTFOUND');
assert.deepStrictEqual(err.syscall, 'queryMx');
assert.deepStrictEqual(err.hostname, 'foo.onion');
assert.deepStrictEqual(err.message, 'queryMx ENOTFOUND foo.onion');
});
}

0 comments on commit a6c8e40

Please sign in to comment.