]> git.pld-linux.org Git - packages/nodejs.git/blob - system_cares.patch
up to 16.20.2 (fixes CVE-2023-32002 CVE-2023-32006 CVE-2023-32559)
[packages/nodejs.git] / system_cares.patch
1 From aff98a5667c22794e2eaf658f6dfbee54cdd4a3b Mon Sep 17 00:00:00 2001
2 From: Felix Yan <felixonmars@archlinux.org>
3 Date: Thu, 12 Aug 2021 02:44:43 +0800
4 Subject: [PATCH 1/2] deps: fix building with system c-ares on Linux
5
6 The change in #39724 breaks building with system c-ares
7 (`--shared-cares`):
8 ```
9 In file included from ../src/cares_wrap.cc:25:
10 ../src/cares_wrap.h:25:11: fatal error: ares_nameser.h: No such file or
11 directory
12    25 | # include <ares_nameser.h>
13       |           ^~~~~~~~~~~~~~~~
14 ```
15
16 Since `ares_nameser.h` isn't available with a default system c-ares
17 installation, let's copy it as our private header here.
18
19 Tested to build fine on Arch Linux with shared c-ares.
20 ---
21  src/ares_nameser.h | 482 +++++++++++++++++++++++++++++++++++++++++++++
22  1 file changed, 482 insertions(+)
23  create mode 100644 src/ares_nameser.h
24
25 diff --git a/src/ares_nameser.h b/src/ares_nameser.h
26 new file mode 100644
27 index 000000000000..5270e5a3a6a0
28 --- /dev/null
29 +++ b/src/ares_nameser.h
30 @@ -0,0 +1,482 @@
31 +
32 +#ifndef ARES_NAMESER_H
33 +#define ARES_NAMESER_H
34 +
35 +#ifdef HAVE_ARPA_NAMESER_H
36 +#  include <arpa/nameser.h>
37 +#endif
38 +#ifdef HAVE_ARPA_NAMESER_COMPAT_H
39 +#  include <arpa/nameser_compat.h>
40 +#endif
41 +
42 +/* ============================================================================
43 + * arpa/nameser.h may or may not provide ALL of the below defines, so check
44 + * each one individually and set if not
45 + * ============================================================================
46 + */
47 +
48 +#ifndef NS_PACKETSZ
49 +#  define NS_PACKETSZ     512   /* maximum packet size */
50 +#endif
51 +
52 +#ifndef NS_MAXDNAME
53 +#  define NS_MAXDNAME     256   /* maximum domain name */
54 +#endif
55 +
56 +#ifndef NS_MAXCDNAME
57 +#  define NS_MAXCDNAME    255   /* maximum compressed domain name */
58 +#endif
59 +
60 +#ifndef NS_MAXLABEL
61 +#  define NS_MAXLABEL     63
62 +#endif
63 +
64 +#ifndef NS_HFIXEDSZ
65 +#  define NS_HFIXEDSZ     12    /* #/bytes of fixed data in header */
66 +#endif
67 +
68 +#ifndef NS_QFIXEDSZ
69 +#  define NS_QFIXEDSZ     4     /* #/bytes of fixed data in query */
70 +#endif
71 +
72 +#ifndef NS_RRFIXEDSZ
73 +#  define NS_RRFIXEDSZ    10    /* #/bytes of fixed data in r record */
74 +#endif
75 +
76 +#ifndef NS_INT16SZ
77 +#  define NS_INT16SZ      2
78 +#endif
79 +
80 +#ifndef NS_INADDRSZ
81 +#  define NS_INADDRSZ     4
82 +#endif
83 +
84 +#ifndef NS_IN6ADDRSZ
85 +#  define NS_IN6ADDRSZ    16
86 +#endif
87 +
88 +#ifndef NS_CMPRSFLGS
89 +#  define NS_CMPRSFLGS    0xc0  /* Flag bits indicating name compression. */
90 +#endif
91 +
92 +#ifndef NS_DEFAULTPORT
93 +#  define NS_DEFAULTPORT  53    /* For both TCP and UDP. */
94 +#endif
95 +
96 +/* ============================================================================
97 + * arpa/nameser.h should provide these enumerations always, so if not found,
98 + * provide them
99 + * ============================================================================
100 + */
101 +#ifndef HAVE_ARPA_NAMESER_H
102 +
103 +typedef enum __ns_class {
104 +    ns_c_invalid = 0,       /* Cookie. */
105 +    ns_c_in = 1,            /* Internet. */
106 +    ns_c_2 = 2,             /* unallocated/unsupported. */
107 +    ns_c_chaos = 3,         /* MIT Chaos-net. */
108 +    ns_c_hs = 4,            /* MIT Hesiod. */
109 +    /* Query class values which do not appear in resource records */
110 +    ns_c_none = 254,        /* for prereq. sections in update requests */
111 +    ns_c_any = 255,         /* Wildcard match. */
112 +    ns_c_max = 65536
113 +} ns_class;
114 +
115 +typedef enum __ns_type {
116 +    ns_t_invalid = 0,       /* Cookie. */
117 +    ns_t_a = 1,             /* Host address. */
118 +    ns_t_ns = 2,            /* Authoritative server. */
119 +    ns_t_md = 3,            /* Mail destination. */
120 +    ns_t_mf = 4,            /* Mail forwarder. */
121 +    ns_t_cname = 5,         /* Canonical name. */
122 +    ns_t_soa = 6,           /* Start of authority zone. */
123 +    ns_t_mb = 7,            /* Mailbox domain name. */
124 +    ns_t_mg = 8,            /* Mail group member. */
125 +    ns_t_mr = 9,            /* Mail rename name. */
126 +    ns_t_null = 10,         /* Null resource record. */
127 +    ns_t_wks = 11,          /* Well known service. */
128 +    ns_t_ptr = 12,          /* Domain name pointer. */
129 +    ns_t_hinfo = 13,        /* Host information. */
130 +    ns_t_minfo = 14,        /* Mailbox information. */
131 +    ns_t_mx = 15,           /* Mail routing information. */
132 +    ns_t_txt = 16,          /* Text strings. */
133 +    ns_t_rp = 17,           /* Responsible person. */
134 +    ns_t_afsdb = 18,        /* AFS cell database. */
135 +    ns_t_x25 = 19,          /* X_25 calling address. */
136 +    ns_t_isdn = 20,         /* ISDN calling address. */
137 +    ns_t_rt = 21,           /* Router. */
138 +    ns_t_nsap = 22,         /* NSAP address. */
139 +    ns_t_nsap_ptr = 23,     /* Reverse NSAP lookup (deprecated). */
140 +    ns_t_sig = 24,          /* Security signature. */
141 +    ns_t_key = 25,          /* Security key. */
142 +    ns_t_px = 26,           /* X.400 mail mapping. */
143 +    ns_t_gpos = 27,         /* Geographical position (withdrawn). */
144 +    ns_t_aaaa = 28,         /* Ip6 Address. */
145 +    ns_t_loc = 29,          /* Location Information. */
146 +    ns_t_nxt = 30,          /* Next domain (security). */
147 +    ns_t_eid = 31,          /* Endpoint identifier. */
148 +    ns_t_nimloc = 32,       /* Nimrod Locator. */
149 +    ns_t_srv = 33,          /* Server Selection. */
150 +    ns_t_atma = 34,         /* ATM Address */
151 +    ns_t_naptr = 35,        /* Naming Authority PoinTeR */
152 +    ns_t_kx = 36,           /* Key Exchange */
153 +    ns_t_cert = 37,         /* Certification record */
154 +    ns_t_a6 = 38,           /* IPv6 address (deprecates AAAA) */
155 +    ns_t_dname = 39,        /* Non-terminal DNAME (for IPv6) */
156 +    ns_t_sink = 40,         /* Kitchen sink (experimentatl) */
157 +    ns_t_opt = 41,          /* EDNS0 option (meta-RR) */
158 +    ns_t_apl = 42,          /* Address prefix list (RFC3123) */
159 +    ns_t_ds = 43,           /* Delegation Signer (RFC4034) */
160 +    ns_t_sshfp = 44,        /* SSH Key Fingerprint (RFC4255) */
161 +    ns_t_rrsig = 46,        /* Resource Record Signature (RFC4034) */
162 +    ns_t_nsec = 47,         /* Next Secure (RFC4034) */
163 +    ns_t_dnskey = 48,       /* DNS Public Key (RFC4034) */
164 +    ns_t_tkey = 249,        /* Transaction key */
165 +    ns_t_tsig = 250,        /* Transaction signature. */
166 +    ns_t_ixfr = 251,        /* Incremental zone transfer. */
167 +    ns_t_axfr = 252,        /* Transfer zone of authority. */
168 +    ns_t_mailb = 253,       /* Transfer mailbox records. */
169 +    ns_t_maila = 254,       /* Transfer mail agent records. */
170 +    ns_t_any = 255,         /* Wildcard match. */
171 +    ns_t_zxfr = 256,        /* BIND-specific, nonstandard. */
172 +    ns_t_caa = 257,         /* Certification Authority Authorization. */
173 +    ns_t_max = 65536
174 +} ns_type;
175 +
176 +typedef enum __ns_opcode {
177 +    ns_o_query = 0,         /* Standard query. */
178 +    ns_o_iquery = 1,        /* Inverse query (deprecated/unsupported). */
179 +    ns_o_status = 2,        /* Name server status query (unsupported). */
180 +                                /* Opcode 3 is undefined/reserved. */
181 +    ns_o_notify = 4,        /* Zone change notification. */
182 +    ns_o_update = 5,        /* Zone update message. */
183 +    ns_o_max = 6
184 +} ns_opcode;
185 +
186 +typedef enum __ns_rcode {
187 +    ns_r_noerror = 0,       /* No error occurred. */
188 +    ns_r_formerr = 1,       /* Format error. */
189 +    ns_r_servfail = 2,      /* Server failure. */
190 +    ns_r_nxdomain = 3,      /* Name error. */
191 +    ns_r_notimpl = 4,       /* Unimplemented. */
192 +    ns_r_refused = 5,       /* Operation refused. */
193 +    /* these are for BIND_UPDATE */
194 +    ns_r_yxdomain = 6,      /* Name exists */
195 +    ns_r_yxrrset = 7,       /* RRset exists */
196 +    ns_r_nxrrset = 8,       /* RRset does not exist */
197 +    ns_r_notauth = 9,       /* Not authoritative for zone */
198 +    ns_r_notzone = 10,      /* Zone of record different from zone section */
199 +    ns_r_max = 11,
200 +    /* The following are TSIG extended errors */
201 +    ns_r_badsig = 16,
202 +    ns_r_badkey = 17,
203 +    ns_r_badtime = 18
204 +} ns_rcode;
205 +
206 +#endif /* HAVE_ARPA_NAMESER_H */
207 +
208 +
209 +/* ============================================================================
210 + * arpa/nameser_compat.h typically sets these.  However on some systems
211 + * arpa/nameser.h does, but may not set all of them.  Lets conditionally
212 + * define each
213 + * ============================================================================
214 + */
215 +
216 +#ifndef PACKETSZ
217 +#  define PACKETSZ         NS_PACKETSZ
218 +#endif
219 +
220 +#ifndef MAXDNAME
221 +#  define MAXDNAME         NS_MAXDNAME
222 +#endif
223 +
224 +#ifndef MAXCDNAME
225 +#  define MAXCDNAME        NS_MAXCDNAME
226 +#endif
227 +
228 +#ifndef MAXLABEL
229 +#  define MAXLABEL         NS_MAXLABEL
230 +#endif
231 +
232 +#ifndef HFIXEDSZ
233 +#  define HFIXEDSZ         NS_HFIXEDSZ
234 +#endif
235 +
236 +#ifndef QFIXEDSZ
237 +#  define QFIXEDSZ         NS_QFIXEDSZ
238 +#endif
239 +
240 +#ifndef RRFIXEDSZ
241 +#  define RRFIXEDSZ        NS_RRFIXEDSZ
242 +#endif
243 +
244 +#ifndef INDIR_MASK
245 +#  define INDIR_MASK       NS_CMPRSFLGS
246 +#endif
247 +
248 +#ifndef NAMESERVER_PORT
249 +#  define NAMESERVER_PORT  NS_DEFAULTPORT
250 +#endif
251 +
252 +
253 +/* opcodes */
254 +#ifndef O_QUERY
255 +#  define O_QUERY 0  /* ns_o_query */
256 +#endif
257 +#ifndef O_IQUERY
258 +#  define O_IQUERY 1 /* ns_o_iquery */
259 +#endif
260 +#ifndef O_STATUS
261 +#  define O_STATUS 2 /* ns_o_status */
262 +#endif
263 +#ifndef O_NOTIFY
264 +#  define O_NOTIFY 4 /* ns_o_notify */
265 +#endif
266 +#ifndef O_UPDATE
267 +#  define O_UPDATE 5 /* ns_o_update */
268 +#endif
269 +
270 +
271 +/* response codes */
272 +#ifndef SERVFAIL
273 +#  define SERVFAIL        ns_r_servfail
274 +#endif
275 +#ifndef NOTIMP
276 +#  define NOTIMP          ns_r_notimpl
277 +#endif
278 +#ifndef REFUSED
279 +#  define REFUSED         ns_r_refused
280 +#endif
281 +#if defined(_WIN32) && !defined(HAVE_ARPA_NAMESER_COMPAT_H) && defined(NOERROR)
282 +#  undef NOERROR /* it seems this is already defined in winerror.h */
283 +#endif
284 +#ifndef NOERROR
285 +#  define NOERROR         ns_r_noerror
286 +#endif
287 +#ifndef FORMERR
288 +#  define FORMERR         ns_r_formerr
289 +#endif
290 +#ifndef NXDOMAIN
291 +#  define NXDOMAIN        ns_r_nxdomain
292 +#endif
293 +/* Non-standard response codes, use numeric values */
294 +#ifndef YXDOMAIN
295 +#  define YXDOMAIN        6 /* ns_r_yxdomain */
296 +#endif
297 +#ifndef YXRRSET
298 +#  define YXRRSET         7 /* ns_r_yxrrset */
299 +#endif
300 +#ifndef NXRRSET
301 +#  define NXRRSET         8 /* ns_r_nxrrset */
302 +#endif
303 +#ifndef NOTAUTH
304 +#  define NOTAUTH         9 /* ns_r_notauth */
305 +#endif
306 +#ifndef NOTZONE
307 +#  define NOTZONE         10 /* ns_r_notzone */
308 +#endif
309 +#ifndef TSIG_BADSIG
310 +#  define TSIG_BADSIG     16 /* ns_r_badsig */
311 +#endif
312 +#ifndef TSIG_BADKEY
313 +#  define TSIG_BADKEY     17 /* ns_r_badkey */
314 +#endif
315 +#ifndef TSIG_BADTIME
316 +#  define TSIG_BADTIME    18 /* ns_r_badtime */
317 +#endif
318 +
319 +
320 +/* classes */
321 +#ifndef C_IN
322 +#  define C_IN            1 /* ns_c_in */
323 +#endif
324 +#ifndef C_CHAOS
325 +#  define C_CHAOS         3 /* ns_c_chaos */
326 +#endif
327 +#ifndef C_HS
328 +#  define C_HS            4 /* ns_c_hs */
329 +#endif
330 +#ifndef C_NONE
331 +#  define C_NONE          254 /* ns_c_none */
332 +#endif
333 +#ifndef C_ANY
334 +#  define C_ANY           255 /*  ns_c_any */
335 +#endif
336 +
337 +
338 +/* types */
339 +#ifndef T_A
340 +#  define T_A             1   /* ns_t_a */
341 +#endif
342 +#ifndef T_NS
343 +#  define T_NS            2   /* ns_t_ns */
344 +#endif
345 +#ifndef T_MD
346 +#  define T_MD            3   /* ns_t_md */
347 +#endif
348 +#ifndef T_MF
349 +#  define T_MF            4   /* ns_t_mf */
350 +#endif
351 +#ifndef T_CNAME
352 +#  define T_CNAME         5   /* ns_t_cname */
353 +#endif
354 +#ifndef T_SOA
355 +#  define T_SOA           6   /* ns_t_soa */
356 +#endif
357 +#ifndef T_MB
358 +#  define T_MB            7   /* ns_t_mb */
359 +#endif
360 +#ifndef T_MG
361 +#  define T_MG            8   /* ns_t_mg */
362 +#endif
363 +#ifndef T_MR
364 +#  define T_MR            9   /* ns_t_mr */
365 +#endif
366 +#ifndef T_NULL
367 +#  define T_NULL          10  /* ns_t_null */
368 +#endif
369 +#ifndef T_WKS
370 +#  define T_WKS           11  /* ns_t_wks */
371 +#endif
372 +#ifndef T_PTR
373 +#  define T_PTR           12  /* ns_t_ptr */
374 +#endif
375 +#ifndef T_HINFO
376 +#  define T_HINFO         13  /* ns_t_hinfo */
377 +#endif
378 +#ifndef T_MINFO
379 +#  define T_MINFO         14  /* ns_t_minfo */
380 +#endif
381 +#ifndef T_MX
382 +#  define T_MX            15  /* ns_t_mx */
383 +#endif
384 +#ifndef T_TXT
385 +#  define T_TXT           16  /* ns_t_txt */
386 +#endif
387 +#ifndef T_RP
388 +#  define T_RP            17  /* ns_t_rp */
389 +#endif
390 +#ifndef T_AFSDB
391 +#  define T_AFSDB         18  /* ns_t_afsdb */
392 +#endif
393 +#ifndef T_X25
394 +#  define T_X25           19  /* ns_t_x25 */
395 +#endif
396 +#ifndef T_ISDN
397 +#  define T_ISDN          20  /* ns_t_isdn */
398 +#endif
399 +#ifndef T_RT
400 +#  define T_RT            21  /* ns_t_rt */
401 +#endif
402 +#ifndef T_NSAP
403 +#  define T_NSAP          22  /* ns_t_nsap */
404 +#endif
405 +#ifndef T_NSAP_PTR
406 +#  define T_NSAP_PTR      23  /* ns_t_nsap_ptr */
407 +#endif
408 +#ifndef T_SIG
409 +#  define T_SIG           24  /* ns_t_sig */
410 +#endif
411 +#ifndef T_KEY
412 +#  define T_KEY           25  /* ns_t_key */
413 +#endif
414 +#ifndef T_PX
415 +#  define T_PX            26  /* ns_t_px */
416 +#endif
417 +#ifndef T_GPOS
418 +#  define T_GPOS          27  /* ns_t_gpos */
419 +#endif
420 +#ifndef T_AAAA
421 +#  define T_AAAA          28  /* ns_t_aaaa */
422 +#endif
423 +#ifndef T_LOC
424 +#  define T_LOC           29  /* ns_t_loc */
425 +#endif
426 +#ifndef T_NXT
427 +#  define T_NXT           30  /* ns_t_nxt */
428 +#endif
429 +#ifndef T_EID
430 +#  define T_EID           31  /* ns_t_eid */
431 +#endif
432 +#ifndef T_NIMLOC
433 +#  define T_NIMLOC        32  /* ns_t_nimloc */
434 +#endif
435 +#ifndef T_SRV
436 +#  define T_SRV           33  /* ns_t_srv */
437 +#endif
438 +#ifndef T_ATMA
439 +#  define T_ATMA          34  /* ns_t_atma */
440 +#endif
441 +#ifndef T_NAPTR
442 +#  define T_NAPTR         35  /* ns_t_naptr */
443 +#endif
444 +#ifndef T_KX
445 +#  define T_KX            36  /* ns_t_kx */
446 +#endif
447 +#ifndef T_CERT
448 +#  define T_CERT          37  /* ns_t_cert */
449 +#endif
450 +#ifndef T_A6
451 +#  define T_A6            38  /* ns_t_a6 */
452 +#endif
453 +#ifndef T_DNAME
454 +#  define T_DNAME         39  /* ns_t_dname */
455 +#endif
456 +#ifndef T_SINK
457 +#  define T_SINK          40  /* ns_t_sink */
458 +#endif
459 +#ifndef T_OPT
460 +#  define T_OPT           41  /* ns_t_opt */
461 +#endif
462 +#ifndef T_APL
463 +#  define T_APL           42  /* ns_t_apl */
464 +#endif
465 +#ifndef T_DS
466 +#  define T_DS            43  /* ns_t_ds */
467 +#endif
468 +#ifndef T_SSHFP
469 +#  define T_SSHFP         44  /* ns_t_sshfp */
470 +#endif
471 +#ifndef T_RRSIG
472 +#  define T_RRSIG         46  /* ns_t_rrsig */
473 +#endif
474 +#ifndef T_NSEC
475 +#  define T_NSEC          47  /* ns_t_nsec */
476 +#endif
477 +#ifndef T_DNSKEY
478 +#  define T_DNSKEY        48  /* ns_t_dnskey */
479 +#endif
480 +#ifndef T_TKEY
481 +#  define T_TKEY          249 /* ns_t_tkey */
482 +#endif
483 +#ifndef T_TSIG
484 +#  define T_TSIG          250 /* ns_t_tsig */
485 +#endif
486 +#ifndef T_IXFR
487 +#  define T_IXFR          251 /* ns_t_ixfr */
488 +#endif
489 +#ifndef T_AXFR
490 +#  define T_AXFR          252 /* ns_t_axfr */
491 +#endif
492 +#ifndef T_MAILB
493 +#  define T_MAILB         253 /* ns_t_mailb */
494 +#endif
495 +#ifndef T_MAILA
496 +#  define T_MAILA         254 /* ns_t_maila */
497 +#endif
498 +#ifndef T_ANY
499 +#  define T_ANY           255 /* ns_t_any */
500 +#endif
501 +#ifndef T_ZXFR
502 +#  define T_ZXFR          256 /* ns_t_zxfr */
503 +#endif
504 +#ifndef T_CAA
505 +#  define T_CAA           257 /* ns_t_caa */
506 +#endif
507 +#ifndef T_MAX
508 +#  define T_MAX         65536 /* ns_t_max */
509 +#endif
510 +
511 +
512 +#endif /* ARES_NAMESER_H */
513
514 From db4643979ee676b3a3d6cdf2fb597d399cf8013f Mon Sep 17 00:00:00 2001
515 From: Felix Yan <felixonmars@archlinux.org>
516 Date: Fri, 13 Aug 2021 00:01:59 +0800
517 Subject: [PATCH 2/2] build: ignore cpplint for third-party ares_nameser.h
518
519 ---
520  Makefile | 1 +
521  1 file changed, 1 insertion(+)
522
523 diff --git a/Makefile b/Makefile
524 index ec4c774748cd..c418995c53c1 100644
525 --- a/Makefile
526 +++ b/Makefile
527 @@ -1289,6 +1289,7 @@ jslint-ci: lint-js-ci
528  LINT_CPP_ADDON_DOC_FILES_GLOB = test/addons/??_*/*.cc test/addons/??_*/*.h
529  LINT_CPP_ADDON_DOC_FILES = $(wildcard $(LINT_CPP_ADDON_DOC_FILES_GLOB))
530  LINT_CPP_EXCLUDE ?=
531 +LINT_CPP_EXCLUDE += src/ares_nameser.h
532  LINT_CPP_EXCLUDE += src/node_root_certs.h
533  LINT_CPP_EXCLUDE += $(LINT_CPP_ADDON_DOC_FILES)
534  LINT_CPP_EXCLUDE += $(wildcard test/js-native-api/??_*/*.cc test/js-native-api/??_*/*.h test/node-api/??_*/*.cc test/node-api/??_*/*.h)
This page took 0.064664 seconds and 3 git commands to generate.