[Midnightbsd-cvs] src [10565] trunk/lib/libc/resolv: update resolver code
laffer1 at midnightbsd.org
laffer1 at midnightbsd.org
Thu Jun 7 21:08:36 EDT 2018
Revision: 10565
http://svnweb.midnightbsd.org/src/?rev=10565
Author: laffer1
Date: 2018-06-07 21:08:35 -0400 (Thu, 07 Jun 2018)
Log Message:
-----------
update resolver code
Modified Paths:
--------------
trunk/lib/libc/resolv/Makefile.inc
trunk/lib/libc/resolv/Symbol.map
trunk/lib/libc/resolv/h_errno.c
trunk/lib/libc/resolv/herror.c
trunk/lib/libc/resolv/mtctxres.c
trunk/lib/libc/resolv/res_comp.c
trunk/lib/libc/resolv/res_data.c
trunk/lib/libc/resolv/res_debug.c
trunk/lib/libc/resolv/res_debug.h
trunk/lib/libc/resolv/res_findzonecut.c
trunk/lib/libc/resolv/res_init.c
trunk/lib/libc/resolv/res_mkquery.c
trunk/lib/libc/resolv/res_mkupdate.c
trunk/lib/libc/resolv/res_private.h
trunk/lib/libc/resolv/res_query.c
trunk/lib/libc/resolv/res_send.c
trunk/lib/libc/resolv/res_state.c
Property Changed:
----------------
trunk/lib/libc/resolv/Makefile.inc
trunk/lib/libc/resolv/Symbol.map
Modified: trunk/lib/libc/resolv/Makefile.inc
===================================================================
--- trunk/lib/libc/resolv/Makefile.inc 2018-06-08 01:07:09 UTC (rev 10564)
+++ trunk/lib/libc/resolv/Makefile.inc 2018-06-08 01:08:35 UTC (rev 10565)
@@ -1,4 +1,5 @@
# $MidnightBSD$
+# $FreeBSD: stable/10/lib/libc/resolv/Makefile.inc 270838 2014-08-30 10:16:25Z ume $
# resolv sources
.PATH: ${.CURDIR}/resolv
@@ -8,3 +9,5 @@
res_query.c res_send.c res_state.c res_update.c
SYM_MAPS+= ${.CURDIR}/resolv/Symbol.map
+
+CFLAGS+=-I${.CURDIR}/../libmd
Property changes on: trunk/lib/libc/resolv/Makefile.inc
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/lib/libc/resolv/Symbol.map
===================================================================
--- trunk/lib/libc/resolv/Symbol.map 2018-06-08 01:07:09 UTC (rev 10564)
+++ trunk/lib/libc/resolv/Symbol.map 2018-06-08 01:08:35 UTC (rev 10565)
@@ -1,5 +1,5 @@
-/*
- * $MidnightBSD$
+/* $MidnightBSD$
+ * $FreeBSD: stable/10/lib/libc/resolv/Symbol.map 270838 2014-08-30 10:16:25Z ume $
*/
FBSD_1.0 {
@@ -105,3 +105,8 @@
res_send;
__res_update;
};
+
+FBSD_1.4 {
+ __res_rndinit;
+ __res_nrandomid;
+};
Property changes on: trunk/lib/libc/resolv/Symbol.map
___________________________________________________________________
Added: svn:keywords
## -0,0 +1 ##
+MidnightBSD=%H
\ No newline at end of property
Modified: trunk/lib/libc/resolv/h_errno.c
===================================================================
--- trunk/lib/libc/resolv/h_errno.c 2018-06-08 01:07:09 UTC (rev 10564)
+++ trunk/lib/libc/resolv/h_errno.c 2018-06-08 01:08:35 UTC (rev 10565)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 2006 The FreeBSD Project. All rights reserved.
*
@@ -22,7 +23,7 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $MidnightBSD$
+ * $FreeBSD: stable/10/lib/libc/resolv/h_errno.c 158792 2006-05-21 11:29:26Z ume $
*/
#include <sys/types.h>
Modified: trunk/lib/libc/resolv/herror.c
===================================================================
--- trunk/lib/libc/resolv/herror.c 2018-06-08 01:07:09 UTC (rev 10564)
+++ trunk/lib/libc/resolv/herror.c 2018-06-08 01:08:35 UTC (rev 10565)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*
* Copyright (c) 1987, 1993
* The Regents of the University of California. All rights reserved.
@@ -46,10 +47,10 @@
#if defined(LIBC_SCCS) && !defined(lint)
static const char sccsid[] = "@(#)herror.c 8.1 (Berkeley) 6/4/93";
-static const char rcsid[] = "$Id: herror.c,v 1.2 2013-02-18 00:12:22 laffer1 Exp $";
+static const char rcsid[] = "$Id: herror.c,v 1.4 2005/04/27 04:56:41 sra Exp $";
#endif /* LIBC_SCCS and not lint */
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/libc/resolv/herror.c 270838 2014-08-30 10:16:25Z ume $");
#include "port_before.h"
Modified: trunk/lib/libc/resolv/mtctxres.c
===================================================================
--- trunk/lib/libc/resolv/mtctxres.c 2018-06-08 01:07:09 UTC (rev 10564)
+++ trunk/lib/libc/resolv/mtctxres.c 2018-06-08 01:08:35 UTC (rev 10565)
@@ -1,5 +1,6 @@
+/* $MidnightBSD$ */
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/libc/resolv/mtctxres.c 309485 2016-12-03 17:17:42Z ngie $");
#include <port_before.h>
#ifdef DO_PTHREADS
@@ -75,7 +76,7 @@
return (0);
}
- if ((mt = malloc(sizeof (mtctxres_t))) == 0) {
+ if ((mt = malloc(sizeof(mtctxres_t))) == NULL) {
errno = ENOMEM;
return (-1);
}
@@ -94,10 +95,7 @@
static void
__res_destroy_ctx(void *value) {
- mtctxres_t *mt = (mtctxres_t *)value;
-
- if (mt != 0)
- free(mt);
+ free(value);
}
#endif
@@ -130,9 +128,9 @@
* that fails return a global context.
*/
if (mt_key_initialized) {
- if (((mt = pthread_getspecific(key)) != 0) ||
+ if (((mt = pthread_getspecific(key)) != NULL) ||
(__res_init_ctx() == 0 &&
- (mt = pthread_getspecific(key)) != 0)) {
+ (mt = pthread_getspecific(key)) != NULL)) {
return (mt);
}
}
Modified: trunk/lib/libc/resolv/res_comp.c
===================================================================
--- trunk/lib/libc/resolv/res_comp.c 2018-06-08 01:07:09 UTC (rev 10564)
+++ trunk/lib/libc/resolv/res_comp.c 2018-06-08 01:08:35 UTC (rev 10565)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*
* Copyright (c) 1985, 1993
* The Regents of the University of California. All rights reserved.
@@ -66,10 +67,10 @@
#if defined(LIBC_SCCS) && !defined(lint)
static const char sccsid[] = "@(#)res_comp.c 8.1 (Berkeley) 6/4/93";
-static const char rcsid[] = "$Id: res_comp.c,v 1.3 2013-02-18 00:12:22 laffer1 Exp $";
+static const char rcsid[] = "$Id: res_comp.c,v 1.5 2005/07/28 06:51:50 marka Exp $";
#endif /* LIBC_SCCS and not lint */
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/libc/resolv/res_comp.c 284559 2015-06-18 16:39:05Z ume $");
#include "port_before.h"
#include <sys/types.h>
@@ -147,12 +148,12 @@
|| ((c) >= 0x61 && (c) <= 0x7a))
#define digitchar(c) ((c) >= 0x30 && (c) <= 0x39)
+#ifdef RES_ENFORCE_RFC1034
#define borderchar(c) (alphachar(c) || digitchar(c))
-#ifdef RES_ENFORCE_RFC1034
-#define middlechar(c) (borderchar(c) || hyphenchar(c))
#else
-#define middlechar(c) (borderchar(c) || hyphenchar(c) || underscorechar(c))
+#define borderchar(c) (alphachar(c) || digitchar(c) || underscorechar(c))
#endif
+#define middlechar(c) (borderchar(c) || hyphenchar(c))
#define domainchar(c) ((c) > 0x20 && (c) < 0x7f)
int
Modified: trunk/lib/libc/resolv/res_data.c
===================================================================
--- trunk/lib/libc/resolv/res_data.c 2018-06-08 01:07:09 UTC (rev 10564)
+++ trunk/lib/libc/resolv/res_data.c 2018-06-08 01:08:35 UTC (rev 10565)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*
* Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
* Copyright (c) 1995-1999 by Internet Software Consortium.
@@ -16,10 +17,10 @@
*/
#if defined(LIBC_SCCS) && !defined(lint)
-static const char rcsid[] = "$Id: res_data.c,v 1.2 2013-02-18 00:12:22 laffer1 Exp $";
+static const char rcsid[] = "$Id: res_data.c,v 1.7 2008/12/11 09:59:00 marka Exp $";
#endif /* LIBC_SCCS and not lint */
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/libc/resolv/res_data.c 292461 2015-12-19 02:35:32Z vangyzen $");
#include "port_before.h"
@@ -77,9 +78,10 @@
int res_ourserver_p(const res_state, const struct sockaddr_in *);
-int
+__noinline int
res_init(void) {
extern int __res_vinit(res_state, int);
+ res_state statp = &_res;
/*
* These three fields used to be statically initialized. This made
@@ -100,21 +102,14 @@
* set in RES_DEFAULT). Our solution is to declare such applications
* "broken". They could fool us by setting RES_INIT but none do (yet).
*/
- if (!_res.retrans)
- _res.retrans = RES_TIMEOUT;
- if (!_res.retry)
- _res.retry = RES_DFLRETRY;
- if (!(_res.options & RES_INIT))
- _res.options = RES_DEFAULT;
+ if (!statp->retrans)
+ statp->retrans = RES_TIMEOUT;
+ if (!statp->retry)
+ statp->retry = RES_DFLRETRY;
+ if (!(statp->options & RES_INIT))
+ statp->options = RES_DEFAULT;
- /*
- * This one used to initialize implicitly to zero, so unless the app
- * has set it to something in particular, we can randomize it now.
- */
- if (!_res.id)
- _res.id = res_randomid();
-
- return (__res_vinit(&_res, 1));
+ return (__res_vinit(statp, 1));
}
void
@@ -129,10 +124,11 @@
void
fp_nquery(const u_char *msg, int len, FILE *file) {
- if ((_res.options & RES_INIT) == 0U && res_init() == -1)
+ res_state statp = &_res;
+ if ((statp->options & RES_INIT) == 0U && res_init() == -1)
return;
- res_pquery(&_res, msg, len, file);
+ res_pquery(statp, msg, len, file);
}
int
@@ -145,11 +141,12 @@
u_char *buf, /*!< buffer to put query */
int buflen) /*!< size of buffer */
{
- if ((_res.options & RES_INIT) == 0U && res_init() == -1) {
- RES_SET_H_ERRNO(&_res, NETDB_INTERNAL);
+ res_state statp = &_res;
+ if ((statp->options & RES_INIT) == 0U && res_init() == -1) {
+ RES_SET_H_ERRNO(statp, NETDB_INTERNAL);
return (-1);
}
- return (res_nmkquery(&_res, op, dname, class, type,
+ return (res_nmkquery(statp, op, dname, class, type,
data, datalen,
newrr_in, buf, buflen));
}
@@ -156,12 +153,13 @@
int
res_mkupdate(ns_updrec *rrecp_in, u_char *buf, int buflen) {
- if ((_res.options & RES_INIT) == 0U && res_init() == -1) {
- RES_SET_H_ERRNO(&_res, NETDB_INTERNAL);
+ res_state statp = &_res;
+ if ((statp->options & RES_INIT) == 0U && res_init() == -1) {
+ RES_SET_H_ERRNO(statp, NETDB_INTERNAL);
return (-1);
}
- return (res_nmkupdate(&_res, rrecp_in, buf, buflen));
+ return (res_nmkupdate(statp, rrecp_in, buf, buflen));
}
int
@@ -170,11 +168,12 @@
u_char *answer, /*!< buffer to put answer */
int anslen) /*!< size of answer buffer */
{
- if ((_res.options & RES_INIT) == 0U && res_init() == -1) {
- RES_SET_H_ERRNO(&_res, NETDB_INTERNAL);
+ res_state statp = &_res;
+ if ((statp->options & RES_INIT) == 0U && res_init() == -1) {
+ RES_SET_H_ERRNO(statp, NETDB_INTERNAL);
return (-1);
}
- return (res_nquery(&_res, name, class, type, answer, anslen));
+ return (res_nquery(statp, name, class, type, answer, anslen));
}
#ifndef _LIBC
@@ -196,12 +195,13 @@
int
res_send(const u_char *buf, int buflen, u_char *ans, int anssiz) {
- if ((_res.options & RES_INIT) == 0U && res_init() == -1) {
+ res_state statp = &_res;
+ if ((statp->options & RES_INIT) == 0U && res_init() == -1) {
/* errno should have been set by res_init() in this case. */
return (-1);
}
- return (res_nsend(&_res, buf, buflen, ans, anssiz));
+ return (res_nsend(statp, buf, buflen, ans, anssiz));
}
#ifndef _LIBC
@@ -209,12 +209,13 @@
res_sendsigned(const u_char *buf, int buflen, ns_tsig_key *key,
u_char *ans, int anssiz)
{
- if ((_res.options & RES_INIT) == 0U && res_init() == -1) {
+ res_state statp = &_res;
+ if ((statp->options & RES_INIT) == 0U && res_init() == -1) {
/* errno should have been set by res_init() in this case. */
return (-1);
}
- return (res_nsendsigned(&_res, buf, buflen, key, ans, anssiz));
+ return (res_nsendsigned(statp, buf, buflen, key, ans, anssiz));
}
#endif
@@ -225,12 +226,13 @@
int
res_update(ns_updrec *rrecp_in) {
- if ((_res.options & RES_INIT) == 0U && res_init() == -1) {
- RES_SET_H_ERRNO(&_res, NETDB_INTERNAL);
+ res_state statp = &_res;
+ if ((statp->options & RES_INIT) == 0U && res_init() == -1) {
+ RES_SET_H_ERRNO(statp, NETDB_INTERNAL);
return (-1);
}
- return (res_nupdate(&_res, rrecp_in, NULL));
+ return (res_nupdate(statp, rrecp_in, NULL));
}
int
@@ -239,12 +241,13 @@
u_char *answer, /*!< buffer to put answer */
int anslen) /*!< size of answer */
{
- if ((_res.options & RES_INIT) == 0U && res_init() == -1) {
- RES_SET_H_ERRNO(&_res, NETDB_INTERNAL);
+ res_state statp = &_res;
+ if ((statp->options & RES_INIT) == 0U && res_init() == -1) {
+ RES_SET_H_ERRNO(statp, NETDB_INTERNAL);
return (-1);
}
- return (res_nsearch(&_res, name, class, type, answer, anslen));
+ return (res_nsearch(statp, name, class, type, answer, anslen));
}
int
@@ -254,16 +257,28 @@
u_char *answer, /*!< buffer to put answer */
int anslen) /*!< size of answer */
{
- if ((_res.options & RES_INIT) == 0U && res_init() == -1) {
- RES_SET_H_ERRNO(&_res, NETDB_INTERNAL);
+ res_state statp = &_res;
+ if ((statp->options & RES_INIT) == 0U && res_init() == -1) {
+ RES_SET_H_ERRNO(statp, NETDB_INTERNAL);
return (-1);
}
- return (res_nquerydomain(&_res, name, domain,
+ return (res_nquerydomain(statp, name, domain,
class, type,
answer, anslen));
}
+u_int
+res_randomid(void) {
+ res_state statp = &_res;
+ if ((statp->options & RES_INIT) == 0U && res_init() == -1) {
+ RES_SET_H_ERRNO(statp, NETDB_INTERNAL);
+ return (-1);
+ }
+
+ return (res_nrandomid(statp));
+}
+
int
res_opt(int n0, u_char *buf, int buflen, int anslen)
{
@@ -281,13 +296,15 @@
int
local_hostname_length(const char *hostname) {
int len_host, len_domain;
+ res_state statp;
- if (!*_res.defdname)
+ statp = &_res;
+ if (!*statp->defdname)
res_init();
len_host = strlen(hostname);
- len_domain = strlen(_res.defdname);
+ len_domain = strlen(statp->defdname);
if (len_host > len_domain &&
- !strcasecmp(hostname + len_host - len_domain, _res.defdname) &&
+ !strcasecmp(hostname + len_host - len_domain, statp->defdname) &&
hostname[len_host - len_domain - 1] == '.')
return (len_host - len_domain - 1);
return (0);
Modified: trunk/lib/libc/resolv/res_debug.c
===================================================================
--- trunk/lib/libc/resolv/res_debug.c 2018-06-08 01:07:09 UTC (rev 10564)
+++ trunk/lib/libc/resolv/res_debug.c 2018-06-08 01:08:35 UTC (rev 10565)
@@ -1,7 +1,25 @@
+/* $MidnightBSD$ */
/*
+ * Portions Copyright (C) 2004, 2005, 2008, 2009 Internet Systems Consortium, Inc. ("ISC")
+ * Portions Copyright (C) 1996-2003 Internet Software Consortium.
+ *
+ * Permission to use, copy, modify, and/or distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
+ * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
+ * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
+ * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
+ * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+/*
* Copyright (c) 1985
* The Regents of the University of California. All rights reserved.
- *
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
@@ -13,7 +31,7 @@
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@@ -29,7 +47,7 @@
/*
* Portions Copyright (c) 1993 by Digital Equipment Corporation.
- *
+ *
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies, and that
@@ -36,7 +54,7 @@
* the name of Digital Equipment Corporation not be used in advertising or
* publicity pertaining to distribution of the document or software without
* specific, written prior permission.
- *
+ *
* THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL
* WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL DIGITAL EQUIPMENT
@@ -72,29 +90,12 @@
* IF IBM IS APPRISED OF THE POSSIBILITY OF SUCH DAMAGES.
*/
-/*
- * Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
- * Portions Copyright (c) 1996-1999 by Internet Software Consortium.
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
- * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
#if defined(LIBC_SCCS) && !defined(lint)
static const char sccsid[] = "@(#)res_debug.c 8.1 (Berkeley) 6/4/93";
-static const char rcsid[] = "$Id: res_debug.c,v 1.3 2013-02-18 00:12:22 laffer1 Exp $";
+static const char rcsid[] = "$Id: res_debug.c,v 1.19 2009/02/26 11:20:20 tbox Exp $";
#endif /* LIBC_SCCS and not lint */
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/libc/resolv/res_debug.c 270838 2014-08-30 10:16:25Z ume $");
#include "port_before.h"
@@ -327,7 +328,7 @@
fprintf(file, ", %s: %d",
p_section(ns_s_ar, opcode), arcount);
}
- if ((!statp->pfcode) || (statp->pfcode &
+ if ((!statp->pfcode) || (statp->pfcode &
(RES_PRF_HEADX | RES_PRF_HEAD2 | RES_PRF_HEAD1))) {
putc('\n',file);
}
@@ -494,6 +495,24 @@
{ns_t_nimloc, "NIMLOC", "NIMROD locator (unimplemented)"},
{ns_t_srv, "SRV", "server selection"},
{ns_t_atma, "ATMA", "ATM address (unimplemented)"},
+ {ns_t_naptr, "NAPTR", "naptr"},
+ {ns_t_kx, "KX", "key exchange"},
+ {ns_t_cert, "CERT", "certificate"},
+ {ns_t_a6, "A", "IPv6 address (experminental)"},
+ {ns_t_dname, "DNAME", "non-terminal redirection"},
+ {ns_t_opt, "OPT", "opt"},
+ {ns_t_apl, "apl", "apl"},
+ {ns_t_ds, "DS", "delegation signer"},
+ {ns_t_sshfp, "SSFP", "SSH fingerprint"},
+ {ns_t_ipseckey, "IPSECKEY", "IPSEC key"},
+ {ns_t_rrsig, "RRSIG", "rrsig"},
+ {ns_t_nsec, "NSEC", "nsec"},
+ {ns_t_dnskey, "DNSKEY", "DNS key"},
+ {ns_t_dhcid, "DHCID", "dynamic host configuration identifier"},
+ {ns_t_nsec3, "NSEC3", "nsec3"},
+ {ns_t_nsec3param, "NSEC3PARAM", "NSEC3 parameters"},
+ {ns_t_hip, "HIP", "host identity protocol"},
+ {ns_t_spf, "SPF", "sender policy framework"},
{ns_t_tkey, "TKEY", "tkey"},
{ns_t_tsig, "TSIG", "transaction signature"},
{ns_t_ixfr, "IXFR", "incremental zone transfer"},
@@ -509,6 +528,7 @@
{ns_t_sink, "SINK", "Kitchen Sink (experimental)"},
{ns_t_opt, "OPT", "EDNS Options"},
{ns_t_any, "ANY", "\"any\""},
+ {ns_t_dlv, "DLV", "DNSSEC look-aside validation"},
{0, NULL, NULL}
};
@@ -936,7 +956,7 @@
altsign = -1;
cp++;
}
-
+
if (*cp == '+')
cp++;
@@ -965,7 +985,7 @@
goto defaults;
siz = precsize_aton(&cp);
-
+
while (!isspace((unsigned char)*cp) && (cp < maxcp)) /*%< if trailing garbage or m */
cp++;
@@ -998,7 +1018,7 @@
PUTLONG(latit,bcp);
PUTLONG(longit,bcp);
PUTLONG(alt,bcp);
-
+
return (16); /*%< size of RR in octets */
}
@@ -1024,7 +1044,7 @@
int32_t latval, longval, altval;
u_int32_t templ;
u_int8_t sizeval, hpval, vpval, versionval;
-
+
char *sizestr, *hpstr, *vpstr;
versionval = *cp++;
@@ -1138,7 +1158,7 @@
}
/*%
- * Make dates expressed in seconds-since-Jan-1-1970 easy to read.
+ * Make dates expressed in seconds-since-Jan-1-1970 easy to read.
* SIG records are required to be printed like this, by the Secure DNS RFC.
*/
char *
@@ -1148,7 +1168,7 @@
struct tm *time;
#ifdef HAVE_TIME_R
struct tm res;
-
+
time = gmtime_r(&clock, &res);
#else
time = gmtime(&clock);
Modified: trunk/lib/libc/resolv/res_debug.h
===================================================================
--- trunk/lib/libc/resolv/res_debug.h 2018-06-08 01:07:09 UTC (rev 10564)
+++ trunk/lib/libc/resolv/res_debug.h 2018-06-08 01:08:35 UTC (rev 10565)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*
* Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
* Copyright (c) 1999 by Internet Software Consortium.
Modified: trunk/lib/libc/resolv/res_findzonecut.c
===================================================================
--- trunk/lib/libc/resolv/res_findzonecut.c 2018-06-08 01:07:09 UTC (rev 10564)
+++ trunk/lib/libc/resolv/res_findzonecut.c 2018-06-08 01:08:35 UTC (rev 10565)
@@ -1,5 +1,6 @@
+/* $MidnightBSD$ */
#if !defined(lint) && !defined(SABER)
-static const char rcsid[] = "$Id: res_findzonecut.c,v 1.2 2013-02-18 00:12:22 laffer1 Exp $";
+static const char rcsid[] = "$Id: res_findzonecut.c,v 1.10 2005/10/11 00:10:16 marka Exp $";
#endif /* not lint */
/*
@@ -20,7 +21,7 @@
*/
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/libc/resolv/res_findzonecut.c 270838 2014-08-30 10:16:25Z ume $");
/* Import. */
Modified: trunk/lib/libc/resolv/res_init.c
===================================================================
--- trunk/lib/libc/resolv/res_init.c 2018-06-08 01:07:09 UTC (rev 10564)
+++ trunk/lib/libc/resolv/res_init.c 2018-06-08 01:08:35 UTC (rev 10565)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*
* Copyright (c) 1985, 1989, 1993
* The Regents of the University of California. All rights reserved.
@@ -66,10 +67,10 @@
#if defined(LIBC_SCCS) && !defined(lint)
static const char sccsid[] = "@(#)res_init.c 8.1 (Berkeley) 6/7/93";
-static const char rcsid[] = "$Id: res_init.c,v 1.2 2013-02-18 00:12:22 laffer1 Exp $";
+static const char rcsid[] = "$Id: res_init.c,v 1.26 2008/12/11 09:59:00 marka Exp $";
#endif /* LIBC_SCCS and not lint */
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/libc/resolv/res_init.c 309485 2016-12-03 17:17:42Z ngie $");
#include "port_before.h"
@@ -78,6 +79,7 @@
#include <sys/types.h>
#include <sys/param.h>
#include <sys/socket.h>
+#include <sys/stat.h>
#include <sys/time.h>
#include <netinet/in.h>
@@ -91,6 +93,19 @@
#include <unistd.h>
#include <netdb.h>
+#ifndef HAVE_MD5
+# include "../dst/md5.h"
+#else
+# ifdef SOLARIS2
+# include <sys/md5.h>
+# elif _LIBC
+# include <md5.h>
+# endif
+#endif
+#ifndef _MD5_H_
+# define _MD5_H_ 1 /*%< make sure we do not include rsaref md5.h file */
+#endif
+
#include "un-namespace.h"
#include "port_after.h"
@@ -102,7 +117,9 @@
/*% Options. Should all be left alone. */
#define RESOLVSORT
-#define DEBUG
+#ifndef DEBUG
+#define DEBUG
+#endif
#ifdef SOLARIS2
#include <sys/systeminfo.h>
@@ -178,9 +195,12 @@
statp->retrans = RES_TIMEOUT;
statp->retry = RES_DFLRETRY;
statp->options = RES_DEFAULT;
- statp->id = res_randomid();
}
+ statp->_rnd = malloc(16);
+ res_rndinit(statp);
+ statp->id = res_nrandomid(statp);
+
memset(u, 0, sizeof(u));
#ifdef USELOOPBACK
u[nserv].sin.sin_addr = inet_makeaddr(IN_LOOPBACKNET, 1);
@@ -220,6 +240,7 @@
statp->_u._ext.ext->nsaddrs[0].sin = statp->nsaddr;
strcpy(statp->_u._ext.ext->nsuffix, "ip6.arpa");
strcpy(statp->_u._ext.ext->nsuffix2, "ip6.int");
+ statp->_u._ext.ext->reload_period = 2;
} else {
/*
* Historically res_init() rarely, if at all, failed.
@@ -295,7 +316,7 @@
while (*cp != '\0' && *cp != ' ' && *cp != '\t' && *cp != '\n')
cp++;
*cp = '\0';
- *pp++ = 0;
+ *pp++ = NULL;
}
#define MATCH(line, name) \
@@ -304,7 +325,19 @@
line[sizeof(name) - 1] == '\t'))
nserv = 0;
- if ((fp = fopen(_PATH_RESCONF, "r")) != NULL) {
+ if ((fp = fopen(_PATH_RESCONF, "re")) != NULL) {
+ struct stat sb;
+ struct timespec now;
+
+ if (statp->_u._ext.ext != NULL) {
+ if (_fstat(fileno(fp), &sb) == 0) {
+ statp->_u._ext.ext->conf_mtim = sb.st_mtim;
+ if (clock_gettime(CLOCK_MONOTONIC_FAST, &now) == 0) {
+ statp->_u._ext.ext->conf_stat = now.tv_sec;
+ }
+ }
+ }
+
/* read the config file */
while (fgets(buf, sizeof(buf), fp) != NULL) {
/* skip comments */
@@ -359,7 +392,7 @@
while (*cp != '\0' && *cp != ' ' && *cp != '\t')
cp++;
*cp = '\0';
- *pp++ = 0;
+ *pp++ = NULL;
havesearch = 1;
continue;
}
@@ -380,20 +413,21 @@
hints.ai_socktype = SOCK_DGRAM; /*dummy*/
hints.ai_flags = AI_NUMERICHOST;
sprintf(sbuf, "%u", NAMESERVER_PORT);
- if (getaddrinfo(cp, sbuf, &hints, &ai) == 0 &&
- ai->ai_addrlen <= minsiz) {
- if (statp->_u._ext.ext != NULL) {
- memcpy(&statp->_u._ext.ext->nsaddrs[nserv],
- ai->ai_addr, ai->ai_addrlen);
+ if (getaddrinfo(cp, sbuf, &hints, &ai) == 0) {
+ if (ai->ai_addrlen <= minsiz) {
+ if (statp->_u._ext.ext != NULL) {
+ memcpy(&statp->_u._ext.ext->nsaddrs[nserv],
+ ai->ai_addr, ai->ai_addrlen);
+ }
+ if (ai->ai_addrlen <=
+ sizeof(statp->nsaddr_list[nserv])) {
+ memcpy(&statp->nsaddr_list[nserv],
+ ai->ai_addr, ai->ai_addrlen);
+ } else
+ statp->nsaddr_list[nserv].sin_family = 0;
+ nserv++;
}
- if (ai->ai_addrlen <=
- sizeof(statp->nsaddr_list[nserv])) {
- memcpy(&statp->nsaddr_list[nserv],
- ai->ai_addr, ai->ai_addrlen);
- } else
- statp->nsaddr_list[nserv].sin_family = 0;
freeaddrinfo(ai);
- nserv++;
}
}
continue;
@@ -565,9 +599,7 @@
{
const char *cp = options;
int i;
-#ifndef _LIBC
struct __res_state_ext *ext = statp->_u._ext.ext;
-#endif
#ifdef DEBUG
if (statp->options & RES_DEBUG)
@@ -650,6 +682,12 @@
} else if (!strncmp(cp, "no-check-names",
sizeof("no-check-names") - 1)) {
statp->options |= RES_NOCHECKNAME;
+ } else if (!strncmp(cp, "reload-period:",
+ sizeof("reload-period:") - 1)) {
+ if (ext != NULL) {
+ ext->reload_period = (u_short)
+ atoi(cp + sizeof("reload-period:") - 1);
+ }
}
#ifdef RES_USE_EDNS0
else if (!strncmp(cp, "edns0", sizeof("edns0") - 1)) {
@@ -715,12 +753,48 @@
}
#endif
+static u_char srnd[16];
+
+void
+res_rndinit(res_state statp)
+{
+ struct timeval now;
+ u_int32_t u32;
+ u_int16_t u16;
+ u_char *rnd = statp->_rnd == NULL ? srnd : statp->_rnd;
+
+ gettimeofday(&now, NULL);
+ u32 = now.tv_sec;
+ memcpy(rnd, &u32, 4);
+ u32 = now.tv_usec;
+ memcpy(rnd + 4, &u32, 4);
+ u32 += now.tv_sec;
+ memcpy(rnd + 8, &u32, 4);
+ u16 = getpid();
+ memcpy(rnd + 12, &u16, 2);
+}
+
u_int
-res_randomid(void) {
+res_nrandomid(res_state statp) {
struct timeval now;
+ u_int16_t u16;
+ MD5_CTX ctx;
+ u_char *rnd = statp->_rnd == NULL ? srnd : statp->_rnd;
gettimeofday(&now, NULL);
- return (0xffff & (now.tv_sec ^ now.tv_usec ^ getpid()));
+ u16 = (u_int16_t) (now.tv_sec ^ now.tv_usec);
+ memcpy(rnd + 14, &u16, 2);
+#ifndef HAVE_MD5
+ MD5_Init(&ctx);
+ MD5_Update(&ctx, rnd, 16);
+ MD5_Final(rnd, &ctx);
+#else
+ MD5Init(&ctx);
+ MD5Update(&ctx, rnd, 16);
+ MD5Final(rnd, &ctx);
+#endif
+ memcpy(&u16, rnd + 14, 2);
+ return ((u_int) u16);
}
/*%
@@ -750,10 +824,15 @@
void
res_ndestroy(res_state statp) {
res_nclose(statp);
- if (statp->_u._ext.ext != NULL)
+ if (statp->_u._ext.ext != NULL) {
free(statp->_u._ext.ext);
+ statp->_u._ext.ext = NULL;
+ }
+ if (statp->_rnd != NULL) {
+ free(statp->_rnd);
+ statp->_rnd = NULL;
+ }
statp->options &= ~RES_INIT;
- statp->_u._ext.ext = NULL;
}
#ifndef _LIBC
Modified: trunk/lib/libc/resolv/res_mkquery.c
===================================================================
--- trunk/lib/libc/resolv/res_mkquery.c 2018-06-08 01:07:09 UTC (rev 10564)
+++ trunk/lib/libc/resolv/res_mkquery.c 2018-06-08 01:08:35 UTC (rev 10565)
@@ -1,7 +1,25 @@
+/* $MidnightBSD$ */
/*
+ * Portions Copyright (C) 2004, 2005, 2008 Internet Systems Consortium, Inc. ("ISC")
+ * Portions Copyright (C) 1996, 1997, 1988, 1999, 2001, 2003 Internet Software Consortium.
+ *
+ * Permission to use, copy, modify, and/or distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
+ * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
+ * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
+ * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
+ * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+/*
* Copyright (c) 1985, 1993
* The Regents of the University of California. All rights reserved.
- *
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
@@ -13,7 +31,7 @@
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@@ -29,7 +47,7 @@
/*
* Portions Copyright (c) 1993 by Digital Equipment Corporation.
- *
+ *
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies, and that
@@ -36,7 +54,7 @@
* the name of Digital Equipment Corporation not be used in advertising or
* publicity pertaining to distribution of the document or software without
* specific, written prior permission.
- *
+ *
* THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL
* WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL DIGITAL EQUIPMENT
@@ -47,29 +65,12 @@
* SOFTWARE.
*/
-/*
- * Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
- * Portions Copyright (c) 1996-1999 by Internet Software Consortium.
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
- * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
#if defined(LIBC_SCCS) && !defined(lint)
static const char sccsid[] = "@(#)res_mkquery.c 8.1 (Berkeley) 6/4/93";
-static const char rcsid[] = "$Id: res_mkquery.c,v 1.3 2013-02-18 00:12:22 laffer1 Exp $";
+static const char rcsid[] = "$Id: res_mkquery.c,v 1.10 2008/12/11 09:59:00 marka Exp $";
#endif /* LIBC_SCCS and not lint */
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/libc/resolv/res_mkquery.c 292430 2015-12-18 06:58:44Z ngie $");
#include "port_before.h"
#include <sys/types.h>
@@ -83,7 +84,9 @@
#include "port_after.h"
/* Options. Leave them on. */
-#define DEBUG
+#ifndef DEBUG
+#define DEBUG
+#endif
extern const char *_res_opcodes[];
@@ -121,7 +124,8 @@
return (-1);
memset(buf, 0, HFIXEDSZ);
hp = (HEADER *) buf;
- hp->id = htons(++statp->id);
+ statp->id = res_nrandomid(statp);
+ hp->id = htons(statp->id);
hp->opcode = op;
hp->rd = (statp->options & RES_RECURSE) != 0U;
hp->rcode = NOERROR;
Modified: trunk/lib/libc/resolv/res_mkupdate.c
===================================================================
--- trunk/lib/libc/resolv/res_mkupdate.c 2018-06-08 01:07:09 UTC (rev 10564)
+++ trunk/lib/libc/resolv/res_mkupdate.c 2018-06-08 01:08:35 UTC (rev 10565)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*
* Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
* Copyright (c) 1996-1999 by Internet Software Consortium.
@@ -22,10 +23,10 @@
*/
#if !defined(lint) && !defined(SABER)
-static const char rcsid[] = "$Id: res_mkupdate.c,v 1.2 2013-02-18 00:12:22 laffer1 Exp $";
+static const char rcsid[] = "$Id: res_mkupdate.c,v 1.10 2008/12/11 09:59:00 marka Exp $";
#endif /* not lint */
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/libc/resolv/res_mkupdate.c 309485 2016-12-03 17:17:42Z ngie $");
#include "port_before.h"
@@ -54,7 +55,9 @@
#include "port_after.h"
/* Options. Leave them on. */
-#define DEBUG
+#ifndef DEBUG
+#define DEBUG
+#endif
#define MAXPORT 1024
static int getnum_str(u_char **, u_char *);
@@ -116,7 +119,8 @@
return (-1);
memset(buf, 0, HFIXEDSZ);
hp = (HEADER *) buf;
- hp->id = htons(++statp->id);
+ statp->id = res_nrandomid(statp);
+ hp->id = htons(statp->id);
hp->opcode = ns_o_update;
hp->rcode = NOERROR;
cp = buf + HFIXEDSZ;
@@ -1172,7 +1176,7 @@
if (protolist == (struct valuelist *)0)
res_buildprotolist();
pp = cgetprotobynumber(num);
- if (pp == 0) {
+ if (pp == NULL) {
(void) sprintf(number, "%d", num);
return (number);
}
@@ -1187,7 +1191,7 @@
if (servicelist == (struct valuelist *)0)
res_buildservicelist();
ss = cgetservbyport(htons(port), proto);
- if (ss == 0) {
+ if (ss == NULL) {
(void) sprintf(number, "%d", port);
return (number);
}
Modified: trunk/lib/libc/resolv/res_private.h
===================================================================
--- trunk/lib/libc/resolv/res_private.h 2018-06-08 01:07:09 UTC (rev 10564)
+++ trunk/lib/libc/resolv/res_private.h 2018-06-08 01:08:35 UTC (rev 10565)
@@ -1,3 +1,6 @@
+/* $MidnightBSD$ */
+/* $FreeBSD: stable/10/lib/libc/resolv/res_private.h 292462 2015-12-19 02:41:31Z vangyzen $ */
+
#ifndef res_private_h
#define res_private_h
@@ -12,6 +15,9 @@
} sort_list[MAXRESOLVSORT];
char nsuffix[64];
char nsuffix2[64];
+ struct timespec conf_mtim; /* mod time of loaded resolv.conf */
+ time_t conf_stat; /* time of last stat(resolv.conf) */
+ u_short reload_period; /* seconds between stat(resolv.conf) */
};
extern int
Modified: trunk/lib/libc/resolv/res_query.c
===================================================================
--- trunk/lib/libc/resolv/res_query.c 2018-06-08 01:07:09 UTC (rev 10564)
+++ trunk/lib/libc/resolv/res_query.c 2018-06-08 01:08:35 UTC (rev 10565)
@@ -1,7 +1,25 @@
+/* $MidnightBSD$ */
/*
+ * Portions Copyright (C) 2004, 2005, 2008 Internet Systems Consortium, Inc. ("ISC")
+ * Portions Copyright (C) 1996-2001, 2003 Internet Software Consortium.
+ *
+ * Permission to use, copy, modify, and/or distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
+ * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
+ * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
+ * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
+ * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+/*
* Copyright (c) 1988, 1993
* The Regents of the University of California. All rights reserved.
- *
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
@@ -13,7 +31,7 @@
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@@ -29,7 +47,7 @@
/*
* Portions Copyright (c) 1993 by Digital Equipment Corporation.
- *
+ *
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies, and that
@@ -36,7 +54,7 @@
* the name of Digital Equipment Corporation not be used in advertising or
* publicity pertaining to distribution of the document or software without
* specific, written prior permission.
- *
+ *
* THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL
* WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL DIGITAL EQUIPMENT
@@ -47,29 +65,12 @@
* SOFTWARE.
*/
-/*
- * Copyright (c) 2004 by Internet Systems Consortium, Inc. ("ISC")
- * Portions Copyright (c) 1996-1999 by Internet Software Consortium.
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
- * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
#if defined(LIBC_SCCS) && !defined(lint)
static const char sccsid[] = "@(#)res_query.c 8.1 (Berkeley) 6/4/93";
-static const char rcsid[] = "$Id: res_query.c,v 1.3 2013-02-18 00:12:22 laffer1 Exp $";
+static const char rcsid[] = "$Id: res_query.c,v 1.11 2008/11/14 02:36:51 marka Exp $";
#endif /* LIBC_SCCS and not lint */
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/libc/resolv/res_query.c 300286 2016-05-20 07:18:33Z truckman $");
#include "port_before.h"
#include <sys/types.h>
@@ -88,7 +89,9 @@
#include "port_after.h"
/* Options. Leave them on. */
-#define DEBUG
+#ifndef DEBUG
+#define DEBUG
+#endif
#if PACKETSZ > 1024
#define MAXPACKET PACKETSZ
@@ -134,8 +137,8 @@
if (n > 0 && (statp->_flags & RES_F_EDNS0ERR) == 0 &&
(statp->options & (RES_USE_EDNS0|RES_USE_DNSSEC|RES_NSID))) {
n = res_nopt(statp, n, buf, sizeof(buf), anslen);
- rdata = &buf[n];
if (n > 0 && (statp->options & RES_NSID) != 0U) {
+ rdata = &buf[n];
n = res_nopt_rdata(statp, n, buf, sizeof(buf), rdata,
NS_OPT_NSID, 0, NULL);
}
@@ -457,7 +460,7 @@
if (issetugid())
return (NULL);
file = getenv("HOSTALIASES");
- if (file == NULL || (fp = fopen(file, "r")) == NULL)
+ if (file == NULL || (fp = fopen(file, "re")) == NULL)
return (NULL);
setbuf(fp, NULL);
buf[sizeof(buf) - 1] = '\0';
Modified: trunk/lib/libc/resolv/res_send.c
===================================================================
--- trunk/lib/libc/resolv/res_send.c 2018-06-08 01:07:09 UTC (rev 10564)
+++ trunk/lib/libc/resolv/res_send.c 2018-06-08 01:08:35 UTC (rev 10565)
@@ -1,7 +1,25 @@
+/* $MidnightBSD$ */
/*
+ * Portions Copyright (C) 2004-2009 Internet Systems Consortium, Inc. ("ISC")
+ * Portions Copyright (C) 1996-2003 Internet Software Consortium.
+ *
+ * Permission to use, copy, modify, and/or distribute this software for any
+ * purpose with or without fee is hereby granted, provided that the above
+ * copyright notice and this permission notice appear in all copies.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
+ * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
+ * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
+ * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
+ * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
+ * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
+ * PERFORMANCE OF THIS SOFTWARE.
+ */
+
+/*
* Copyright (c) 1985, 1989, 1993
* The Regents of the University of California. All rights reserved.
- *
+ *
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
@@ -13,7 +31,7 @@
* 4. Neither the name of the University nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
- *
+ *
* THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
@@ -29,7 +47,7 @@
/*
* Portions Copyright (c) 1993 by Digital Equipment Corporation.
- *
+ *
* Permission to use, copy, modify, and distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies, and that
@@ -36,7 +54,7 @@
* the name of Digital Equipment Corporation not be used in advertising or
* publicity pertaining to distribution of the document or software without
* specific, written prior permission.
- *
+ *
* THE SOFTWARE IS PROVIDED "AS IS" AND DIGITAL EQUIPMENT CORP. DISCLAIMS ALL
* WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ALL IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL DIGITAL EQUIPMENT
@@ -47,29 +65,12 @@
* SOFTWARE.
*/
-/*
- * Copyright (c) 2005 by Internet Systems Consortium, Inc. ("ISC")
- * Portions Copyright (c) 1996-1999 by Internet Software Consortium.
- *
- * Permission to use, copy, modify, and distribute this software for any
- * purpose with or without fee is hereby granted, provided that the above
- * copyright notice and this permission notice appear in all copies.
- *
- * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES
- * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
- * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR
- * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
- * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
- * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
- * OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
- */
-
#if defined(LIBC_SCCS) && !defined(lint)
static const char sccsid[] = "@(#)res_send.c 8.1 (Berkeley) 6/4/93";
-static const char rcsid[] = "$Id: res_send.c,v 1.4 2013-02-18 00:12:22 laffer1 Exp $";
+static const char rcsid[] = "$Id: res_send.c,v 1.22 2009/01/22 23:49:23 tbox Exp $";
#endif /* LIBC_SCCS and not lint */
#include <sys/cdefs.h>
-__MBSDID("$MidnightBSD$");
+__FBSDID("$FreeBSD: stable/10/lib/libc/resolv/res_send.c 292430 2015-12-18 06:58:44Z ngie $");
/*! \file
* \brief
@@ -119,7 +120,9 @@
#include "un-namespace.h"
/* Options. Leave them on. */
-#define DEBUG
+#ifndef DEBUG
+#define DEBUG
+#endif
#include "res_debug.h"
#include "res_private.h"
@@ -353,7 +356,7 @@
if (EXT(statp).nssocks[ns] == -1)
continue;
peerlen = sizeof(peer);
- if (_getsockname(EXT(statp).nssocks[ns],
+ if (_getpeername(EXT(statp).nssocks[ns],
(struct sockaddr *)&peer, &peerlen) < 0) {
needclose++;
break;
@@ -404,7 +407,7 @@
nstime = EXT(statp).nstimes[0];
for (ns = 0; ns < lastns; ns++) {
if (EXT(statp).ext != NULL)
- EXT(statp).ext->nsaddrs[ns] =
+ EXT(statp).ext->nsaddrs[ns] =
EXT(statp).ext->nsaddrs[ns + 1];
statp->nsaddr_list[ns] = statp->nsaddr_list[ns + 1];
EXT(statp).nssocks[ns] = EXT(statp).nssocks[ns + 1];
@@ -660,7 +663,8 @@
if (statp->_vcsock >= 0)
res_nclose(statp);
- statp->_vcsock = _socket(nsap->sa_family, SOCK_STREAM, 0);
+ statp->_vcsock = _socket(nsap->sa_family, SOCK_STREAM |
+ SOCK_CLOEXEC, 0);
#if !defined(USE_POLL) && !defined(USE_KQUEUE)
if (statp->_vcsock > highestFD) {
res_nclose(statp);
@@ -686,12 +690,12 @@
/*
* Disable generation of SIGPIPE when writing to a closed
* socket. Write should return -1 and set errno to EPIPE
- * instead.
+ * instead.
*
* Push on even if setsockopt(SO_NOSIGPIPE) fails.
*/
(void)_setsockopt(statp->_vcsock, SOL_SOCKET, SO_NOSIGPIPE, &on,
- sizeof(on));
+ sizeof(on));
#endif
errno = 0;
if (_connect(statp->_vcsock, nsap, nsaplen) < 0) {
@@ -851,7 +855,7 @@
nsaplen = get_salen(nsap);
if (EXT(statp).nssocks[ns] == -1) {
EXT(statp).nssocks[ns] = _socket(nsap->sa_family,
- SOCK_DGRAM, 0);
+ SOCK_DGRAM | SOCK_CLOEXEC, 0);
#if !defined(USE_POLL) && !defined(USE_KQUEUE)
if (EXT(statp).nssocks[ns] > highestFD) {
res_nclose(statp);
Modified: trunk/lib/libc/resolv/res_state.c
===================================================================
--- trunk/lib/libc/resolv/res_state.c 2018-06-08 01:07:09 UTC (rev 10564)
+++ trunk/lib/libc/resolv/res_state.c 2018-06-08 01:08:35 UTC (rev 10565)
@@ -1,3 +1,4 @@
+/* $MidnightBSD$ */
/*-
* Copyright (c) 2006 The FreeBSD Project. All rights reserved.
*
@@ -22,10 +23,12 @@
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $MidnightBSD$
+ * $FreeBSD: stable/10/lib/libc/resolv/res_state.c 292462 2015-12-19 02:41:31Z vangyzen $
*/
#include <sys/types.h>
+#include <sys/stat.h>
+#include <sys/time.h>
#include <netinet/in.h>
#include <arpa/nameser.h>
#include <resolv.h>
@@ -35,6 +38,8 @@
#include "reentrant.h"
#include "un-namespace.h"
+#include "res_private.h"
+
#undef _res
struct __res_state _res;
@@ -59,6 +64,37 @@
res_thr_keycreated = thr_keycreate(&res_key, free_res) == 0;
}
+static res_state
+res_check_reload(res_state statp)
+{
+ struct timespec now;
+ struct stat sb;
+ struct __res_state_ext *ext;
+
+ if ((statp->options & RES_INIT) == 0) {
+ return (statp);
+ }
+
+ ext = statp->_u._ext.ext;
+ if (ext == NULL || ext->reload_period == 0) {
+ return (statp);
+ }
+
+ if (clock_gettime(CLOCK_MONOTONIC_FAST, &now) != 0 ||
+ (now.tv_sec - ext->conf_stat) < ext->reload_period) {
+ return (statp);
+ }
+
+ ext->conf_stat = now.tv_sec;
+ if (stat(_PATH_RESCONF, &sb) == 0 &&
+ (sb.st_mtim.tv_sec != ext->conf_mtim.tv_sec ||
+ sb.st_mtim.tv_nsec != ext->conf_mtim.tv_nsec)) {
+ statp->options &= ~RES_INIT;
+ }
+
+ return (statp);
+}
+
res_state
__res_state(void)
{
@@ -65,7 +101,7 @@
res_state statp;
if (thr_main() != 0)
- return (&_res);
+ return res_check_reload(&_res);
if (thr_once(&res_init_once, res_keycreate) != 0 ||
!res_thr_keycreated)
@@ -73,7 +109,7 @@
statp = thr_getspecific(res_key);
if (statp != NULL)
- return (statp);
+ return res_check_reload(statp);
statp = calloc(1, sizeof(*statp));
if (statp == NULL)
return (&_res);
More information about the Midnightbsd-cvs
mailing list