summaryrefslogtreecommitdiffstats
path: root/contrib
diff options
context:
space:
mode:
authorRenato Botelho <renato@netgate.com>2016-06-14 14:40:19 -0500
committerRenato Botelho <renato@netgate.com>2016-06-14 14:40:19 -0500
commit20a32898b6944f9ebcdbb846253d812943036066 (patch)
tree2d3bb1c4acf6d65a66c132d4c59643a3e99dfe34 /contrib
parent4fdb7654ef71cc3e4f0353cc46f28f652cd35605 (diff)
parenta048478c507785f68e86db1a32431aa36773ee06 (diff)
downloadFreeBSD-src-20a32898b6944f9ebcdbb846253d812943036066.zip
FreeBSD-src-20a32898b6944f9ebcdbb846253d812943036066.tar.gz
Merge remote-tracking branch 'origin/master' into devel-11
Diffstat (limited to 'contrib')
-rw-r--r--contrib/atf/config.h4
-rw-r--r--contrib/blacklist/bin/blacklistctl.88
-rw-r--r--contrib/blacklist/bin/blacklistctl.c2
-rw-r--r--contrib/blacklist/bin/blacklistd.88
-rw-r--r--contrib/blacklist/bin/blacklistd.conf.58
-rw-r--r--contrib/blacklist/libexec/blacklistd-helper52
-rw-r--r--contrib/bmake/ChangeLog6
-rw-r--r--contrib/bmake/Makefile4
-rw-r--r--contrib/bmake/README51
-rw-r--r--contrib/bmake/config.h.in3
-rwxr-xr-xcontrib/bmake/configure29
-rw-r--r--contrib/bmake/configure.in5
-rw-r--r--contrib/bmake/dir.c115
-rw-r--r--contrib/bmake/hash.h13
-rw-r--r--contrib/bmake/main.c18
-rw-r--r--contrib/bmake/make.h4
-rw-r--r--contrib/bmake/meta.c10
-rw-r--r--contrib/ipfilter/man/ipf.85
-rw-r--r--contrib/jemalloc/ChangeLog11
-rw-r--r--contrib/jemalloc/FREEBSD-diffs4
-rw-r--r--contrib/jemalloc/VERSION2
-rw-r--r--contrib/jemalloc/doc/jemalloc.38
-rw-r--r--contrib/jemalloc/include/jemalloc/internal/jemalloc_internal.h4
-rw-r--r--contrib/jemalloc/include/jemalloc/internal/prof.h1
-rw-r--r--contrib/jemalloc/include/jemalloc/jemalloc.h8
-rw-r--r--contrib/jemalloc/src/arena.c2
-rw-r--r--contrib/jemalloc/src/chunk.c88
-rw-r--r--contrib/jemalloc/src/chunk_mmap.c2
-rw-r--r--contrib/jemalloc/src/huge.c10
-rw-r--r--contrib/jemalloc/src/jemalloc.c8
-rw-r--r--contrib/jemalloc/src/nstime.c8
-rw-r--r--contrib/ldns-host/Makefile4
-rw-r--r--contrib/ldns-host/ldns-host.13
-rw-r--r--contrib/ldns-host/ldns-host.c247
-rw-r--r--contrib/libc-vis/unvis.c10
-rw-r--r--contrib/libc-vis/vis.349
-rw-r--r--contrib/libc-vis/vis.c145
-rw-r--r--contrib/libc-vis/vis.h6
-rwxr-xr-xcontrib/netbsd-tests/lib/libc/db/t_db.sh32
-rw-r--r--contrib/netbsd-tests/lib/libc/string/t_memcpy.c7
-rw-r--r--contrib/tcpdump/addrtoname.c10
-rw-r--r--contrib/tcpdump/config.h.in2
-rwxr-xr-xcontrib/tcpdump/configure2
-rw-r--r--contrib/tcpdump/tcpdump.c54
44 files changed, 774 insertions, 298 deletions
diff --git a/contrib/atf/config.h b/contrib/atf/config.h
index befc2e3..a7094fc 100644
--- a/contrib/atf/config.h
+++ b/contrib/atf/config.h
@@ -2,10 +2,10 @@
/* config.h.in. Generated from configure.ac by autoheader. */
/* Define to 1 if basename takes a constant pointer */
-#define HAVE_CONST_BASENAME 1
+/* #undef HAVE_CONST_BASENAME */
/* Define to 1 if dirname takes a constant pointer */
-#define HAVE_CONST_DIRNAME 1
+/* #undef HAVE_CONST_DIRNAME */
/* Define to 1 if you have the <dlfcn.h> header file. */
#define HAVE_DLFCN_H 1
diff --git a/contrib/blacklist/bin/blacklistctl.8 b/contrib/blacklist/bin/blacklistctl.8
index d8ed1f0..f28ab28 100644
--- a/contrib/blacklist/bin/blacklistctl.8
+++ b/contrib/blacklist/bin/blacklistctl.8
@@ -27,7 +27,7 @@
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
.\" POSSIBILITY OF SUCH DAMAGE.
.\"
-.Dd April 29, 2015
+.Dd June 7, 2016
.Dt BLACKLISTCTL 8
.Os
.Sh NAME
@@ -75,7 +75,11 @@ will first attempt to remove the existing rule, and then it will re-add
it to make sure that there is only one rule active.
.Sh HISTORY
.Nm
-appeared in
+first appeared in
.Nx 7 .
+.Fx support for
+.Nm
+was implemented in
+.Fx 11 .
.Sh AUTHORS
.An Christos Zoulas
diff --git a/contrib/blacklist/bin/blacklistctl.c b/contrib/blacklist/bin/blacklistctl.c
index d202fb1..3ac65a5 100644
--- a/contrib/blacklist/bin/blacklistctl.c
+++ b/contrib/blacklist/bin/blacklistctl.c
@@ -96,10 +96,10 @@ main(int argc, char *argv[])
break;
case 'b':
blocked = 1;
+ break;
case 'D':
dbname = optarg;
break;
- break;
case 'd':
debug++;
break;
diff --git a/contrib/blacklist/bin/blacklistd.8 b/contrib/blacklist/bin/blacklistd.8
index 80a53da..0d34d1e 100644
--- a/contrib/blacklist/bin/blacklistd.8
+++ b/contrib/blacklist/bin/blacklistd.8
@@ -27,7 +27,7 @@
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
.\" POSSIBILITY OF SUCH DAMAGE.
.\"
-.Dd June 4, 2015
+.Dd June 7, 2016
.Dt BLACKLISTD 8
.Os
.Sh NAME
@@ -216,7 +216,11 @@ Socket to receive connection notifications.
.Xr syslogd 8
.Sh HISTORY
.Nm
-appeared in
+first appeared in
.Nx 7 .
+.Fx support for
+.Nm
+was implemented in
+.Fx 11 .
.Sh AUTHORS
.An Christos Zoulas
diff --git a/contrib/blacklist/bin/blacklistd.conf.5 b/contrib/blacklist/bin/blacklistd.conf.5
index 40d507b..aa10e34 100644
--- a/contrib/blacklist/bin/blacklistd.conf.5
+++ b/contrib/blacklist/bin/blacklistd.conf.5
@@ -27,7 +27,7 @@
.\" ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
.\" POSSIBILITY OF SUCH DAMAGE.
.\"
-.Dd April 29, 2015
+.Dd June 7, 2016
.Dt BLACKLISTD.CONF 5
.Os
.Sh NAME
@@ -216,7 +216,11 @@ bnx0:ssh * * * * 3 6h
.Xr blacklistd 8
.Sh HISTORY
.Nm
-appeared in
+first appeared in
.Nx 7 .
+.Fx support for
+.Nm
+was implemented in
+.Fx 11 .
.Sh AUTHORS
.An Christos Zoulas
diff --git a/contrib/blacklist/libexec/blacklistd-helper b/contrib/blacklist/libexec/blacklistd-helper
index 743ccf5..be63a9c 100644
--- a/contrib/blacklist/libexec/blacklistd-helper
+++ b/contrib/blacklist/libexec/blacklistd-helper
@@ -10,12 +10,20 @@
# $7 id
pf=
-for f in npf pf; do
- if [ -f "/etc/$f.conf" ]; then
- pf="$f"
- break
- fi
-done
+if [ -f "/etc/ipfw-blacklist.rc" ]; then
+ pf="ipfw"
+ . /etc/ipfw-blacklist.rc
+ ipfw_offset=${ipfw_offset:-2000}
+fi
+
+if [ -z "$pf" ]; then
+ for f in npf pf ipf; do
+ if [ -f "/etc/$f.conf" ]; then
+ pf="$f"
+ break
+ fi
+ done
+fi
if [ -z "$pf" ]; then
echo "$0: Unsupported packet filter" 1>&2
@@ -43,6 +51,21 @@ esac
case "$1" in
add)
case "$pf" in
+ ipf)
+ /sbin/ipfstat -io | /sbin/ipf -I -f - >/dev/null 2>&1
+ echo block in quick $proto from $addr/$mask to \
+ any port=$6 head port$6 | \
+ /sbin/ipf -I -f - -s >/dev/null 2>&1
+ ;;
+ ipfw)
+ # use $ipfw_offset+$port for rule number
+ rule=$(($ipfw_offset + $6))
+ tname="port$6"
+ /sbin/ipfw table $tname create type addr 2>/dev/null
+ /sbin/ipfw -q table $tname add "$addr/$mask"
+ /sbin/ipfw -q add $rule drop $3 from "table("$tname")" to \
+ any dst-port $6
+ ;;
npf)
/sbin/npfctl rule "$2" add block in final $proto from \
"$addr/$mask" to any $port
@@ -57,6 +80,15 @@ add)
;;
rem)
case "$pf" in
+ ipf)
+ /sbin/ipfstat -io | /sbin/ipf -I -f - >/dev/null 2>&1
+ echo block in quick $proto from $addr/$mask to \
+ any port=$6 head port$6 | \
+ /sbin/ipf -I -r -f - -s >/dev/null 2>&1
+ ;;
+ ipfw)
+ /sbin/ipfw table "port$6" delete "$addr/$mask" 2>/dev/null
+ ;;
npf)
/sbin/npfctl rule "$2" rem-id "$7"
;;
@@ -66,7 +98,13 @@ rem)
esac
;;
flush)
- case "$pf" in
+ case "$pf" in
+ ipf)
+ /sbin/ipf -Z -I -Fi -s > /dev/null
+ ;;
+ ipfw)
+ /sbin/ipfw table "port$6" flush 2>/dev/null
+ ;;
npf)
/sbin/npfctl rule "$2" flush
;;
diff --git a/contrib/bmake/ChangeLog b/contrib/bmake/ChangeLog
index 96b8930..deee9bf 100644
--- a/contrib/bmake/ChangeLog
+++ b/contrib/bmake/ChangeLog
@@ -1,3 +1,9 @@
+2016-06-06 Simon J. Gerraty <sjg@bad.crufty.net>
+
+ * Makefile (_MAKE_VERSION): 20160606
+ Merge with NetBSD make, pick up
+ o dir.c: extend mtimes cache to others via cached_stat()
+
2016-06-04 Simon J. Gerraty <sjg@bad.crufty.net>
* Makefile (_MAKE_VERSION): 20160604
diff --git a/contrib/bmake/Makefile b/contrib/bmake/Makefile
index deba694..9c63e4f 100644
--- a/contrib/bmake/Makefile
+++ b/contrib/bmake/Makefile
@@ -1,7 +1,7 @@
-# $Id: Makefile,v 1.66 2016/06/04 22:21:15 sjg Exp $
+# $Id: Makefile,v 1.67 2016/06/07 00:46:12 sjg Exp $
# Base version on src date
-_MAKE_VERSION= 20160604
+_MAKE_VERSION= 20160606
PROG= bmake
diff --git a/contrib/bmake/README b/contrib/bmake/README
index d09e977..a782f6d 100644
--- a/contrib/bmake/README
+++ b/contrib/bmake/README
@@ -1,47 +1,52 @@
bmake
+ *****
-This directory contains a port of the BSD make tool (from NetBSD)
-I have run it on SunOS,Solaris,HP-UX,AIX,IRIX,FreeBSD and Linux.
+This directory contains a port of the BSD make tool (from NetBSD).
+Since 1993 I have run it on AIX, BSDi, Darwin, FreeBSD, HP-UX, IRIX,
+Linux, Minix, OSF, Solaris, SunOS and even UTS.
+Others have run it on many more systems.
-Version 3 was re-worked from scratch to better facilitate
-importing newer make(1) versions from NetBSD. The original code base
-was NetBSD-1.0, so version 3 was built by doing a fresh import of the
-NetBSD-1.0 usr.bin/make, adding the autoconf and other portability
-patches to sync it with bmake v2, and then NetBSD's make
-of Feb 20, 2000 was imported and conflicts dealt with.
-NetBSD's make was again imported on June 6 and December 15, 2000.
+Currently each release is tested on NetBSD, FreeBSD, Solaris and Linux.
-In 2003 bmake switched to a date based version (first was 20030714)
+Since 2003 bmake switched to a date based version (first was 20030714)
which generally represents the date it was last merged with NetBSD's
make. Since then, NetBSD's make is imported within a week of any
interesting changes, so that bmake tracks it very closely.
-Building:
+Building
+========
-The preferred way to bootstrap bmake is:
+The preferred way to bootstrap bmake is::
-./bmake/boot-strap
+ ./bmake/boot-strap
there are a number of args - most of which get passed to configure,
eg.
+::
-./bmake/boot-strap --prefix=/opt
+ ./bmake/boot-strap --prefix=/opt
see the boot-strap script for details.
+For folk that hate to read anything, since 20121212 you can also use
+the GNU standard process of::
+
+ ./configure; make; make install
+
To make much use of bmake you will need the bsd.*.mk macros or my
-portable *.mk macros. See
+portable *.mk macros which are included with bmake since 20121212
+and separately available from
http://www.crufty.net/ftp/pub/sjg/mk.tar.gz
which will be links to the latest versions.
-On a non-BSD system, you would want to unpack mk[-YYYYmmdd].tar.gz in
-the same directory as bmake (so ./mk and ./bmake exist), and
-./bmake/boot-strap will do the rest.
+Porting
+=======
+
+If you encounter a system that bmake does not build or work on *out of
+the box*, I welcome patches.
+If you can provide access to a suitable machine - even better.
-If you want to do it all by hand then read boot-strap first to get the
-idea.
+More info can be found at http://www.crufty.net/help/sjg/bmake.htm
-Even if you have an earlier version of bmake installed, use boot-strap
-to ensure that all goes well.
+--sjg <sjg@crufty.net>
---sjg
diff --git a/contrib/bmake/config.h.in b/contrib/bmake/config.h.in
index ce1700d..82e7e99 100644
--- a/contrib/bmake/config.h.in
+++ b/contrib/bmake/config.h.in
@@ -324,6 +324,9 @@
/* Define to empty if `const' does not conform to ANSI C. */
#undef const
+/* Define to `int' if <sys/types.h> does not define. */
+#undef mode_t
+
/* Define to `long int' if <sys/types.h> does not define. */
#undef off_t
diff --git a/contrib/bmake/configure b/contrib/bmake/configure
index 946b8da..1a70f3d 100755
--- a/contrib/bmake/configure
+++ b/contrib/bmake/configure
@@ -1,6 +1,6 @@
#! /bin/sh
# Guess values for system-dependent variables and create Makefiles.
-# Generated by GNU Autoconf 2.64 for bmake 20151022.
+# Generated by GNU Autoconf 2.64 for bmake 20160606.
#
# Report bugs to <sjg@NetBSD.org>.
#
@@ -549,8 +549,8 @@ MAKEFLAGS=
# Identity of this package.
PACKAGE_NAME='bmake'
PACKAGE_TARNAME='bmake'
-PACKAGE_VERSION='20151022'
-PACKAGE_STRING='bmake 20151022'
+PACKAGE_VERSION='20160606'
+PACKAGE_STRING='bmake 20160606'
PACKAGE_BUGREPORT='sjg@NetBSD.org'
PACKAGE_URL=''
@@ -1221,7 +1221,7 @@ if test "$ac_init_help" = "long"; then
# Omit some internal or obsolete options to make the list less imposing.
# This message is too long to be a string in the A/UX 3.1 sh.
cat <<_ACEOF
-\`configure' configures bmake 20151022 to adapt to many kinds of systems.
+\`configure' configures bmake 20160606 to adapt to many kinds of systems.
Usage: $0 [OPTION]... [VAR=VALUE]...
@@ -1282,7 +1282,7 @@ fi
if test -n "$ac_init_help"; then
case $ac_init_help in
- short | recursive ) echo "Configuration of bmake 20151022:";;
+ short | recursive ) echo "Configuration of bmake 20160606:";;
esac
cat <<\_ACEOF
@@ -1387,7 +1387,7 @@ fi
test -n "$ac_init_help" && exit $ac_status
if $ac_init_version; then
cat <<\_ACEOF
-bmake configure 20151022
+bmake configure 20160606
generated by GNU Autoconf 2.64
Copyright (C) 2009 Free Software Foundation, Inc.
@@ -1960,7 +1960,7 @@ cat >config.log <<_ACEOF
This file contains any messages produced by compilers while
running configure, to aid debugging if configure makes a mistake.
-It was created by bmake $as_me 20151022, which was
+It was created by bmake $as_me 20160606, which was
generated by GNU Autoconf 2.64. Invocation command line was
$ $0 $@
@@ -5055,6 +5055,17 @@ $as_echo "#define const /**/" >>confdefs.h
fi
+ac_fn_c_check_type "$LINENO" "mode_t" "ac_cv_type_mode_t" "$ac_includes_default"
+if test "x$ac_cv_type_mode_t" = x""yes; then :
+
+else
+
+cat >>confdefs.h <<_ACEOF
+#define mode_t int
+_ACEOF
+
+fi
+
ac_fn_c_check_type "$LINENO" "off_t" "ac_cv_type_off_t" "$ac_includes_default"
if test "x$ac_cv_type_off_t" = x""yes; then :
@@ -6502,7 +6513,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1
# report actual input values of CONFIG_FILES etc. instead of their
# values after options handling.
ac_log="
-This file was extended by bmake $as_me 20151022, which was
+This file was extended by bmake $as_me 20160606, which was
generated by GNU Autoconf 2.64. Invocation command line was
CONFIG_FILES = $CONFIG_FILES
@@ -6562,7 +6573,7 @@ Report bugs to <sjg@NetBSD.org>."
_ACEOF
cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1
ac_cs_version="\\
-bmake config.status 20151022
+bmake config.status 20160606
configured by $0, generated by GNU Autoconf 2.64,
with options \\"`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`\\"
diff --git a/contrib/bmake/configure.in b/contrib/bmake/configure.in
index c4b6808..29d368b 100644
--- a/contrib/bmake/configure.in
+++ b/contrib/bmake/configure.in
@@ -1,11 +1,11 @@
dnl
dnl RCSid:
-dnl $Id: configure.in,v 1.56 2015/10/25 05:20:48 sjg Exp $
+dnl $Id: configure.in,v 1.57 2016/06/07 00:49:44 sjg Exp $
dnl
dnl Process this file with autoconf to produce a configure script
dnl
AC_PREREQ(2.50)
-AC_INIT([bmake], [20151022], [sjg@NetBSD.org])
+AC_INIT([bmake], [20160606], [sjg@NetBSD.org])
AC_CONFIG_HEADERS(config.h)
dnl make srcdir absolute
@@ -148,6 +148,7 @@ dnl Checks for typedefs, structures, and compiler characteristics.
AC_C___ATTRIBUTE__
AC_C_BIGENDIAN
AC_C_CONST
+AC_TYPE_MODE_T
AC_TYPE_OFF_T
AC_TYPE_PID_T
AC_TYPE_SIZE_T
diff --git a/contrib/bmake/dir.c b/contrib/bmake/dir.c
index 7b12769..4667e3c 100644
--- a/contrib/bmake/dir.c
+++ b/contrib/bmake/dir.c
@@ -1,4 +1,4 @@
-/* $NetBSD: dir.c,v 1.67 2013/03/05 22:01:43 christos Exp $ */
+/* $NetBSD: dir.c,v 1.68 2016/06/07 00:40:00 sjg Exp $ */
/*
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -70,14 +70,14 @@
*/
#ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: dir.c,v 1.67 2013/03/05 22:01:43 christos Exp $";
+static char rcsid[] = "$NetBSD: dir.c,v 1.68 2016/06/07 00:40:00 sjg Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
#if 0
static char sccsid[] = "@(#)dir.c 8.2 (Berkeley) 1/2/94";
#else
-__RCSID("$NetBSD: dir.c,v 1.67 2013/03/05 22:01:43 christos Exp $");
+__RCSID("$NetBSD: dir.c,v 1.68 2016/06/07 00:40:00 sjg Exp $");
#endif
#endif /* not lint */
#endif
@@ -244,6 +244,7 @@ static Hash_Table mtimes; /* Results of doing a last-resort stat in
* be two rules to update a single file, so this
* should be ok, but... */
+static Hash_Table lmtimes; /* same as mtimes but for lstat */
static int DirFindName(const void *, const void *);
static int DirMatchFiles(const char *, Path *, Lst);
@@ -256,6 +257,80 @@ static char *DirLookupSubdir(Path *, const char *);
static char *DirFindDot(Boolean, const char *, const char *);
static char *DirLookupAbs(Path *, const char *, const char *);
+
+/*
+ * We use stat(2) a lot, cache the results
+ * mtime and mode are all we care about.
+ */
+struct cache_st {
+ time_t mtime;
+ mode_t mode;
+};
+
+/* minimize changes below */
+static time_t
+Hash_GetTimeValue(Hash_Entry *entry)
+{
+ struct cache_st *cst;
+
+ cst = entry->clientPtr;
+ return cst->mtime;
+}
+
+#define CST_LSTAT 1
+#define CST_UPDATE 2
+
+static int
+cached_stats(Hash_Table *htp, const char *pathname, struct stat *st, int flags)
+{
+ Hash_Entry *entry;
+ struct cache_st *cst;
+ int rc;
+
+ if (!pathname || !pathname[0])
+ return -1;
+
+ entry = Hash_FindEntry(htp, pathname);
+
+ if (entry && (flags & CST_UPDATE) == 0) {
+ cst = entry->clientPtr;
+
+ memset(st, 0, sizeof(*st));
+ st->st_mtime = cst->mtime;
+ st->st_mode = cst->mode;
+ return 0;
+ }
+
+ rc = (flags & CST_LSTAT) ? lstat(pathname, st) : stat(pathname, st);
+ if (rc == -1)
+ return -1;
+
+ if (st->st_mtime == 0)
+ st->st_mtime = 1; /* avoid confusion with missing file */
+
+ if (!entry)
+ entry = Hash_CreateEntry(htp, pathname, NULL);
+ if (!entry->clientPtr)
+ entry->clientPtr = bmake_malloc(sizeof(*cst));
+ cst = entry->clientPtr;
+ cst->mtime = st->st_mtime;
+ cst->mode = st->st_mode;
+
+ return 0;
+}
+
+int
+cached_stat(const char *pathname, void *st)
+{
+ return cached_stats(&mtimes, pathname, st, 0);
+}
+
+int
+cached_lstat(const char *pathname, void *st)
+{
+ return cached_stats(&lmtimes, pathname, st, CST_LSTAT);
+}
+
/*-
*-----------------------------------------------------------------------
* Dir_Init --
@@ -274,6 +349,7 @@ Dir_Init(const char *cdname)
dirSearchPath = Lst_Init(FALSE);
openDirectories = Lst_Init(FALSE);
Hash_InitTable(&mtimes, 0);
+ Hash_InitTable(&lmtimes, 0);
Dir_InitCur(cdname);
@@ -901,7 +977,6 @@ static char *
DirLookupSubdir(Path *p, const char *name)
{
struct stat stb; /* Buffer for stat, if necessary */
- Hash_Entry *entry; /* Entry for mtimes table */
char *file; /* the current filename to check */
if (p != dot) {
@@ -917,9 +992,7 @@ DirLookupSubdir(Path *p, const char *name)
fprintf(debug_file, "checking %s ...\n", file);
}
- if (stat(file, &stb) == 0) {
- if (stb.st_mtime == 0)
- stb.st_mtime = 1;
+ if (cached_stat(file, &stb) == 0) {
/*
* Save the modification time so if it's needed, we don't have
* to fetch it again.
@@ -928,8 +1001,6 @@ DirLookupSubdir(Path *p, const char *name)
fprintf(debug_file, " Caching %s for %s\n", Targ_FmtTime(stb.st_mtime),
file);
}
- entry = Hash_CreateEntry(&mtimes, file, NULL);
- Hash_SetTimeValue(entry, stb.st_mtime);
nearmisses += 1;
return (file);
}
@@ -1312,15 +1383,11 @@ Dir_FindFile(const char *name, Lst path)
fprintf(debug_file, " got it (in mtime cache)\n");
}
return(bmake_strdup(name));
- } else if (stat(name, &stb) == 0) {
- if (stb.st_mtime == 0)
- stb.st_mtime = 1;
- entry = Hash_CreateEntry(&mtimes, name, NULL);
+ } else if (cached_stat(name, &stb) == 0) {
if (DEBUG(DIR)) {
fprintf(debug_file, " Caching %s for %s\n", Targ_FmtTime(stb.st_mtime),
name);
}
- Hash_SetTimeValue(entry, stb.st_mtime);
return (bmake_strdup(name));
} else {
if (DEBUG(DIR)) {
@@ -1368,7 +1435,7 @@ Dir_FindHereOrAbove(char *here, char *search_path, char *result, int rlen) {
/* try and stat(2) it ... */
snprintf(try, sizeof(try), "%s/%s", dirbase, search_path);
- if (stat(try, &st) != -1) {
+ if (cached_stat(try, &st) != -1) {
/*
* success! if we found a file, chop off
* the filename so we return a directory.
@@ -1489,12 +1556,12 @@ Dir_MTime(GNode *gn, Boolean recheck)
else
entry = NULL;
if (entry != NULL) {
+ stb.st_mtime = Hash_GetTimeValue(entry);
if (DEBUG(DIR)) {
fprintf(debug_file, "Using cached time %s for %s\n",
- Targ_FmtTime(Hash_GetTimeValue(entry)), fullName);
+ Targ_FmtTime(stb.st_mtime), fullName);
}
- stb.st_mtime = Hash_GetTimeValue(entry);
- } else if (stat(fullName, &stb) < 0) {
+ } else if (cached_stats(&mtimes, fullName, &stb, recheck ? CST_UPDATE : 0) < 0) {
if (gn->type & OP_MEMBER) {
if (fullName != gn->path)
free(fullName);
@@ -1502,18 +1569,8 @@ Dir_MTime(GNode *gn, Boolean recheck)
} else {
stb.st_mtime = 0;
}
- } else {
- if (stb.st_mtime == 0) {
- /*
- * 0 handled specially by the code, if the time is really 0,
- * return something else instead
- */
- stb.st_mtime = 1;
- }
- entry = Hash_CreateEntry(&mtimes, fullName, NULL);
- Hash_SetTimeValue(entry, stb.st_mtime);
}
-
+
if (fullName && gn->path == NULL) {
gn->path = fullName;
}
diff --git a/contrib/bmake/hash.h b/contrib/bmake/hash.h
index 31d2ff1..0e3d22d 100644
--- a/contrib/bmake/hash.h
+++ b/contrib/bmake/hash.h
@@ -1,4 +1,4 @@
-/* $NetBSD: hash.h,v 1.10 2009/01/24 10:59:09 dsl Exp $ */
+/* $NetBSD: hash.h,v 1.11 2016/06/07 00:40:00 sjg Exp $ */
/*
* Copyright (c) 1988, 1989, 1990 The Regents of the University of California.
@@ -89,10 +89,7 @@ typedef struct Hash_Entry {
struct Hash_Entry *next; /* Used to link together all the
* entries associated with the same
* bucket. */
- union {
- void *clientPtr; /* Arbitrary pointer */
- time_t clientTime; /* Arbitrary Time */
- } clientInfo;
+ void *clientPtr; /* Arbitrary pointer */
unsigned namehash; /* hash value of key */
char name[1]; /* key string */
} Hash_Entry;
@@ -125,8 +122,7 @@ typedef struct Hash_Search {
* Hash_Entry *h;
*/
-#define Hash_GetValue(h) ((h)->clientInfo.clientPtr)
-#define Hash_GetTimeValue(h) ((h)->clientInfo.clientTime)
+#define Hash_GetValue(h) ((h)->clientPtr)
/*
* Hash_SetValue(h, val);
@@ -134,8 +130,7 @@ typedef struct Hash_Search {
* char *val;
*/
-#define Hash_SetValue(h, val) ((h)->clientInfo.clientPtr = (val))
-#define Hash_SetTimeValue(h, val) ((h)->clientInfo.clientTime = (val))
+#define Hash_SetValue(h, val) ((h)->clientPtr = (val))
/*
* Hash_Size(n) returns the number of words in an object of n bytes
diff --git a/contrib/bmake/main.c b/contrib/bmake/main.c
index 57a59cb..20aa9c9 100644
--- a/contrib/bmake/main.c
+++ b/contrib/bmake/main.c
@@ -1,4 +1,4 @@
-/* $NetBSD: main.c,v 1.245 2016/06/03 01:21:59 sjg Exp $ */
+/* $NetBSD: main.c,v 1.247 2016/06/05 01:39:17 christos Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -69,7 +69,7 @@
*/
#ifndef MAKE_NATIVE
-static char rcsid[] = "$NetBSD: main.c,v 1.245 2016/06/03 01:21:59 sjg Exp $";
+static char rcsid[] = "$NetBSD: main.c,v 1.247 2016/06/05 01:39:17 christos Exp $";
#else
#include <sys/cdefs.h>
#ifndef lint
@@ -81,7 +81,7 @@ __COPYRIGHT("@(#) Copyright (c) 1988, 1989, 1990, 1993\
#if 0
static char sccsid[] = "@(#)main.c 8.3 (Berkeley) 3/19/94";
#else
-__RCSID("$NetBSD: main.c,v 1.245 2016/06/03 01:21:59 sjg Exp $");
+__RCSID("$NetBSD: main.c,v 1.247 2016/06/05 01:39:17 christos Exp $");
#endif
#endif /* not lint */
#endif
@@ -1906,15 +1906,11 @@ cached_realpath(const char *pathname, char *resolved)
rp = Var_Value(pathname, cache, &cp);
if (rp) {
/* a hit */
- if (resolved)
- strlcpy(resolved, rp, MAXPATHLEN);
- else
- resolved = bmake_strdup(rp);
- } else {
- if ((rp = realpath(pathname, resolved))) {
- Var_Set(pathname, rp, cache, 0);
- }
+ strlcpy(resolved, rp, MAXPATHLEN);
+ } else if ((rp = realpath(pathname, resolved))) {
+ Var_Set(pathname, rp, cache, 0);
}
+ free(cp);
return rp ? resolved : NULL;
}
diff --git a/contrib/bmake/make.h b/contrib/bmake/make.h
index b3962f0..0fe12ab 100644
--- a/contrib/bmake/make.h
+++ b/contrib/bmake/make.h
@@ -1,4 +1,4 @@
-/* $NetBSD: make.h,v 1.99 2016/06/03 01:21:59 sjg Exp $ */
+/* $NetBSD: make.h,v 1.100 2016/06/07 00:40:00 sjg Exp $ */
/*
* Copyright (c) 1988, 1989, 1990, 1993
@@ -506,6 +506,8 @@ void Main_ExportMAKEFLAGS(Boolean);
Boolean Main_SetObjdir(const char *);
int mkTempFile(const char *, char **);
int str2Lst_Append(Lst, char *, const char *);
+int cached_lstat(const char *, void *);
+int cached_stat(const char *, void *);
#define VARF_UNDEFERR 1
#define VARF_WANTRES 2
diff --git a/contrib/bmake/meta.c b/contrib/bmake/meta.c
index 4f54a00..dcd396d 100644
--- a/contrib/bmake/meta.c
+++ b/contrib/bmake/meta.c
@@ -1,4 +1,4 @@
-/* $NetBSD: meta.c,v 1.60 2016/06/04 22:17:14 sjg Exp $ */
+/* $NetBSD: meta.c,v 1.61 2016/06/07 00:40:00 sjg Exp $ */
/*
* Implement 'meta' mode.
@@ -429,7 +429,7 @@ meta_needed(GNode *gn, const char *dname, const char *tname,
}
/* The object directory may not exist. Check it.. */
- if (stat(dname, &fs) != 0) {
+ if (cached_stat(dname, &fs) != 0) {
if (verbose)
fprintf(debug_file, "Skipping meta for %s: no .OBJDIR\n",
gn->name);
@@ -1238,8 +1238,8 @@ meta_oodate(GNode *gn, Boolean oodate)
if ((strstr("tmp", p)))
break;
- if ((link_src != NULL && lstat(p, &fs) < 0) ||
- (link_src == NULL && stat(p, &fs) < 0)) {
+ if ((link_src != NULL && cached_lstat(p, &fs) < 0) ||
+ (link_src == NULL && cached_stat(p, &fs) < 0)) {
if (Lst_Find(missingFiles, p, string_match) == NULL)
Lst_AtEnd(missingFiles, bmake_strdup(p));
}
@@ -1328,7 +1328,7 @@ meta_oodate(GNode *gn, Boolean oodate)
if (DEBUG(META))
fprintf(debug_file, "%s: %d: looking for: %s\n", fname, lineno, *sdp);
#endif
- if (stat(*sdp, &fs) == 0) {
+ if (cached_stat(*sdp, &fs) == 0) {
found = 1;
p = *sdp;
}
diff --git a/contrib/ipfilter/man/ipf.8 b/contrib/ipfilter/man/ipf.8
index 6e88a9d..afd3c61 100644
--- a/contrib/ipfilter/man/ipf.8
+++ b/contrib/ipfilter/man/ipf.8
@@ -35,7 +35,10 @@ which they appear when given to \fBipf\fP.
.SH OPTIONS
.TP
.B \-6
-This option is required to parse IPv6 rules and to have them loaded.
+IPv4 and IPv6 rules are stored in a single table and can be read from a
+single file. This option is no longer required to load IPv6 rules. This
+option is ignored when specified with the -F option and the -F option
+will flush IPv4 rules even if this option is specified.
.TP
.B \-A
Set the list to make changes to the active list (default).
diff --git a/contrib/jemalloc/ChangeLog b/contrib/jemalloc/ChangeLog
index c9ce7c4..532255d 100644
--- a/contrib/jemalloc/ChangeLog
+++ b/contrib/jemalloc/ChangeLog
@@ -4,6 +4,17 @@ brevity. Much more detail can be found in the git revision history:
https://github.com/jemalloc/jemalloc
+* 4.2.1 (June 8, 2016)
+
+ Bug fixes:
+ - Fix bootstrapping issues for configurations that require allocation during
+ tsd initialization (e.g. --disable-tls). (@cferris1000, @jasone)
+ - Fix gettimeofday() version of nstime_update(). (@ronawho)
+ - Fix Valgrind regressions in calloc() and chunk_alloc_wrapper(). (@ronawho)
+ - Fix potential VM map fragmentation regression. (@jasone)
+ - Fix opt_zero-triggered in-place huge reallocation zeroing. (@jasone)
+ - Fix heap profiling context leaks in reallocation edge cases. (@jasone)
+
* 4.2.0 (May 12, 2016)
New features:
diff --git a/contrib/jemalloc/FREEBSD-diffs b/contrib/jemalloc/FREEBSD-diffs
index 6b5e52b..df0a538 100644
--- a/contrib/jemalloc/FREEBSD-diffs
+++ b/contrib/jemalloc/FREEBSD-diffs
@@ -79,7 +79,7 @@ index b1de2b6..da6b6d2 100644
JEMALLOC_ALWAYS_INLINE size_t
diff --git a/include/jemalloc/internal/jemalloc_internal.h.in b/include/jemalloc/internal/jemalloc_internal.h.in
-index 51bf897..7de22ea 100644
+index 8f82edd..78e2df2 100644
--- a/include/jemalloc/internal/jemalloc_internal.h.in
+++ b/include/jemalloc/internal/jemalloc_internal.h.in
@@ -8,6 +8,9 @@
@@ -335,7 +335,7 @@ index f943891..47d032c 100755
+#include "jemalloc_FreeBSD.h"
EOF
diff --git a/src/jemalloc.c b/src/jemalloc.c
-index 40eb2ea..666c49d 100644
+index 5d1f493..46dd1d1 100644
--- a/src/jemalloc.c
+++ b/src/jemalloc.c
@@ -4,6 +4,10 @@
diff --git a/contrib/jemalloc/VERSION b/contrib/jemalloc/VERSION
index b4ecbbf..b17fa1d 100644
--- a/contrib/jemalloc/VERSION
+++ b/contrib/jemalloc/VERSION
@@ -1 +1 @@
-4.2.0-1-gdc7ff6306d7a15b53479e2fb8e5546404b82e6fc
+4.2.1-0-g3de035335255d553bdb344c32ffdb603816195d8
diff --git a/contrib/jemalloc/doc/jemalloc.3 b/contrib/jemalloc/doc/jemalloc.3
index 21d40c1..26fb02a 100644
--- a/contrib/jemalloc/doc/jemalloc.3
+++ b/contrib/jemalloc/doc/jemalloc.3
@@ -2,12 +2,12 @@
.\" Title: JEMALLOC
.\" Author: Jason Evans
.\" Generator: DocBook XSL Stylesheets v1.76.1 <http://docbook.sf.net/>
-.\" Date: 05/12/2016
+.\" Date: 06/08/2016
.\" Manual: User Manual
-.\" Source: jemalloc 4.2.0-1-gdc7ff6306d7a15b53479e2fb8e5546404b82e6fc
+.\" Source: jemalloc 4.2.1-0-g3de035335255d553bdb344c32ffdb603816195d8
.\" Language: English
.\"
-.TH "JEMALLOC" "3" "05/12/2016" "jemalloc 4.2.0-1-gdc7ff6306d7a" "User Manual"
+.TH "JEMALLOC" "3" "06/08/2016" "jemalloc 4.2.1-0-g3de035335255" "User Manual"
.\" -----------------------------------------------------------------
.\" * Define some portability stuff
.\" -----------------------------------------------------------------
@@ -31,7 +31,7 @@
jemalloc \- general purpose memory allocation functions
.SH "LIBRARY"
.PP
-This manual describes jemalloc 4\&.2\&.0\-1\-gdc7ff6306d7a15b53479e2fb8e5546404b82e6fc\&. More information can be found at the
+This manual describes jemalloc 4\&.2\&.1\-0\-g3de035335255d553bdb344c32ffdb603816195d8\&. More information can be found at the
\m[blue]\fBjemalloc website\fR\m[]\&\s-2\u[1]\d\s+2\&.
.PP
The following configuration options are enabled in libc\*(Aqs built\-in jemalloc:
diff --git a/contrib/jemalloc/include/jemalloc/internal/jemalloc_internal.h b/contrib/jemalloc/include/jemalloc/internal/jemalloc_internal.h
index a694869..49f14a5 100644
--- a/contrib/jemalloc/include/jemalloc/internal/jemalloc_internal.h
+++ b/contrib/jemalloc/include/jemalloc/internal/jemalloc_internal.h
@@ -751,7 +751,7 @@ sa2u(size_t size, size_t alignment)
* Calculate the size of the over-size run that arena_palloc()
* would need to allocate in order to guarantee the alignment.
*/
- if (usize + large_pad + alignment <= arena_maxrun)
+ if (usize + large_pad + alignment - PAGE <= arena_maxrun)
return (usize);
}
@@ -781,7 +781,7 @@ sa2u(size_t size, size_t alignment)
* Calculate the multi-chunk mapping that huge_palloc() would need in
* order to guarantee the alignment.
*/
- if (usize + alignment < usize) {
+ if (usize + alignment - PAGE < usize) {
/* size_t overflow. */
return (0);
}
diff --git a/contrib/jemalloc/include/jemalloc/internal/prof.h b/contrib/jemalloc/include/jemalloc/internal/prof.h
index 691e153..21dff5f 100644
--- a/contrib/jemalloc/include/jemalloc/internal/prof.h
+++ b/contrib/jemalloc/include/jemalloc/internal/prof.h
@@ -513,6 +513,7 @@ prof_realloc(tsd_t *tsd, const void *ptr, size_t usize, prof_tctx_t *tctx,
* though its actual usize was insufficient to cross the
* sample threshold.
*/
+ prof_alloc_rollback(tsd, tctx, true);
tctx = (prof_tctx_t *)(uintptr_t)1U;
}
}
diff --git a/contrib/jemalloc/include/jemalloc/jemalloc.h b/contrib/jemalloc/include/jemalloc/jemalloc.h
index 394699f..d2c876e 100644
--- a/contrib/jemalloc/include/jemalloc/jemalloc.h
+++ b/contrib/jemalloc/include/jemalloc/jemalloc.h
@@ -87,12 +87,12 @@ extern "C" {
#include <limits.h>
#include <strings.h>
-#define JEMALLOC_VERSION "4.2.0-1-gdc7ff6306d7a15b53479e2fb8e5546404b82e6fc"
+#define JEMALLOC_VERSION "4.2.1-0-g3de035335255d553bdb344c32ffdb603816195d8"
#define JEMALLOC_VERSION_MAJOR 4
#define JEMALLOC_VERSION_MINOR 2
-#define JEMALLOC_VERSION_BUGFIX 0
-#define JEMALLOC_VERSION_NREV 1
-#define JEMALLOC_VERSION_GID "dc7ff6306d7a15b53479e2fb8e5546404b82e6fc"
+#define JEMALLOC_VERSION_BUGFIX 1
+#define JEMALLOC_VERSION_NREV 0
+#define JEMALLOC_VERSION_GID "3de035335255d553bdb344c32ffdb603816195d8"
# define MALLOCX_LG_ALIGN(la) ((int)(la))
# if LG_SIZEOF_PTR == 2
diff --git a/contrib/jemalloc/src/arena.c b/contrib/jemalloc/src/arena.c
index c605bcd..ce62590 100644
--- a/contrib/jemalloc/src/arena.c
+++ b/contrib/jemalloc/src/arena.c
@@ -2687,7 +2687,7 @@ arena_palloc_large(tsdn_t *tsdn, arena_t *arena, size_t usize, size_t alignment,
return (NULL);
alignment = PAGE_CEILING(alignment);
- alloc_size = usize + large_pad + alignment;
+ alloc_size = usize + large_pad + alignment - PAGE;
malloc_mutex_lock(tsdn, &arena->lock);
run = arena_run_alloc_large(tsdn, arena, alloc_size, false);
diff --git a/contrib/jemalloc/src/chunk.c b/contrib/jemalloc/src/chunk.c
index adc666f..f292c980 100644
--- a/contrib/jemalloc/src/chunk.c
+++ b/contrib/jemalloc/src/chunk.c
@@ -421,15 +421,11 @@ chunk_arena_get(tsdn_t *tsdn, unsigned arena_ind)
}
static void *
-chunk_alloc_default(void *new_addr, size_t size, size_t alignment, bool *zero,
- bool *commit, unsigned arena_ind)
+chunk_alloc_default_impl(tsdn_t *tsdn, arena_t *arena, void *new_addr,
+ size_t size, size_t alignment, bool *zero, bool *commit)
{
void *ret;
- tsdn_t *tsdn;
- arena_t *arena;
- tsdn = tsdn_fetch();
- arena = chunk_arena_get(tsdn, arena_ind);
ret = chunk_alloc_core(tsdn, arena, new_addr, size, alignment, zero,
commit, arena->dss_prec);
if (ret == NULL)
@@ -441,6 +437,20 @@ chunk_alloc_default(void *new_addr, size_t size, size_t alignment, bool *zero,
}
static void *
+chunk_alloc_default(void *new_addr, size_t size, size_t alignment, bool *zero,
+ bool *commit, unsigned arena_ind)
+{
+ tsdn_t *tsdn;
+ arena_t *arena;
+
+ tsdn = tsdn_fetch();
+ arena = chunk_arena_get(tsdn, arena_ind);
+
+ return (chunk_alloc_default_impl(tsdn, arena, new_addr, size, alignment,
+ zero, commit));
+}
+
+static void *
chunk_alloc_retained(tsdn_t *tsdn, arena_t *arena, chunk_hooks_t *chunk_hooks,
void *new_addr, size_t size, size_t alignment, bool *zero, bool *commit)
{
@@ -472,14 +482,23 @@ chunk_alloc_wrapper(tsdn_t *tsdn, arena_t *arena, chunk_hooks_t *chunk_hooks,
ret = chunk_alloc_retained(tsdn, arena, chunk_hooks, new_addr, size,
alignment, zero, commit);
if (ret == NULL) {
- ret = chunk_hooks->alloc(new_addr, size, alignment, zero,
- commit, arena->ind);
+ if (chunk_hooks->alloc == chunk_alloc_default) {
+ /* Call directly to propagate tsdn. */
+ ret = chunk_alloc_default_impl(tsdn, arena, new_addr,
+ size, alignment, zero, commit);
+ } else {
+ ret = chunk_hooks->alloc(new_addr, size, alignment,
+ zero, commit, arena->ind);
+ }
+
if (ret == NULL)
return (NULL);
+
+ if (config_valgrind && chunk_hooks->alloc !=
+ chunk_alloc_default)
+ JEMALLOC_VALGRIND_MAKE_MEM_UNDEFINED(ret, chunksize);
}
- if (config_valgrind && chunk_hooks->alloc != chunk_alloc_default)
- JEMALLOC_VALGRIND_MAKE_MEM_UNDEFINED(ret, chunksize);
return (ret);
}
@@ -591,19 +610,30 @@ chunk_dalloc_cache(tsdn_t *tsdn, arena_t *arena, chunk_hooks_t *chunk_hooks,
}
static bool
-chunk_dalloc_default(void *chunk, size_t size, bool committed,
- unsigned arena_ind)
+chunk_dalloc_default_impl(tsdn_t *tsdn, void *chunk, size_t size)
{
- if (!have_dss || !chunk_in_dss(tsdn_fetch(), chunk))
+ if (!have_dss || !chunk_in_dss(tsdn, chunk))
return (chunk_dalloc_mmap(chunk, size));
return (true);
}
+static bool
+chunk_dalloc_default(void *chunk, size_t size, bool committed,
+ unsigned arena_ind)
+{
+ tsdn_t *tsdn;
+
+ tsdn = tsdn_fetch();
+
+ return (chunk_dalloc_default_impl(tsdn, chunk, size));
+}
+
void
chunk_dalloc_wrapper(tsdn_t *tsdn, arena_t *arena, chunk_hooks_t *chunk_hooks,
void *chunk, size_t size, bool zeroed, bool committed)
{
+ bool err;
assert(chunk != NULL);
assert(CHUNK_ADDR2BASE(chunk) == chunk);
@@ -612,7 +642,13 @@ chunk_dalloc_wrapper(tsdn_t *tsdn, arena_t *arena, chunk_hooks_t *chunk_hooks,
chunk_hooks_assure_initialized(tsdn, arena, chunk_hooks);
/* Try to deallocate. */
- if (!chunk_hooks->dalloc(chunk, size, committed, arena->ind))
+ if (chunk_hooks->dalloc == chunk_dalloc_default) {
+ /* Call directly to propagate tsdn. */
+ err = chunk_dalloc_default_impl(tsdn, chunk, size);
+ } else
+ err = chunk_hooks->dalloc(chunk, size, committed, arena->ind);
+
+ if (!err)
return;
/* Try to decommit; purge if that fails. */
if (committed) {
@@ -681,26 +717,34 @@ chunk_split_default(void *chunk, size_t size, size_t size_a, size_t size_b,
}
static bool
-chunk_merge_default(void *chunk_a, size_t size_a, void *chunk_b, size_t size_b,
- bool committed, unsigned arena_ind)
+chunk_merge_default_impl(tsdn_t *tsdn, void *chunk_a, void *chunk_b)
{
if (!maps_coalesce)
return (true);
- if (have_dss) {
- tsdn_t *tsdn = tsdn_fetch();
- if (chunk_in_dss(tsdn, chunk_a) != chunk_in_dss(tsdn, chunk_b))
- return (true);
- }
+ if (have_dss && chunk_in_dss(tsdn, chunk_a) != chunk_in_dss(tsdn,
+ chunk_b))
+ return (true);
return (false);
}
+static bool
+chunk_merge_default(void *chunk_a, size_t size_a, void *chunk_b, size_t size_b,
+ bool committed, unsigned arena_ind)
+{
+ tsdn_t *tsdn;
+
+ tsdn = tsdn_fetch();
+
+ return (chunk_merge_default_impl(tsdn, chunk_a, chunk_b));
+}
+
static rtree_node_elm_t *
chunks_rtree_node_alloc(size_t nelms)
{
- return ((rtree_node_elm_t *)base_alloc(tsdn_fetch(), nelms *
+ return ((rtree_node_elm_t *)base_alloc(TSDN_NULL, nelms *
sizeof(rtree_node_elm_t)));
}
diff --git a/contrib/jemalloc/src/chunk_mmap.c b/contrib/jemalloc/src/chunk_mmap.c
index f95ae75..73fc497 100644
--- a/contrib/jemalloc/src/chunk_mmap.c
+++ b/contrib/jemalloc/src/chunk_mmap.c
@@ -9,7 +9,7 @@ chunk_alloc_mmap_slow(size_t size, size_t alignment, bool *zero, bool *commit)
void *ret;
size_t alloc_size;
- alloc_size = size + alignment;
+ alloc_size = size + alignment - PAGE;
/* Beware size_t wrap-around. */
if (alloc_size < size)
return (NULL);
diff --git a/contrib/jemalloc/src/huge.c b/contrib/jemalloc/src/huge.c
index 1aa02a0..3a2877c 100644
--- a/contrib/jemalloc/src/huge.c
+++ b/contrib/jemalloc/src/huge.c
@@ -262,19 +262,19 @@ huge_ralloc_no_move_expand(tsdn_t *tsdn, void *ptr, size_t oldsize,
malloc_mutex_unlock(tsdn, &arena->huge_mtx);
/*
- * Copy zero into is_zeroed_chunk and pass the copy to chunk_alloc(), so
- * that it is possible to make correct junk/zero fill decisions below.
+ * Use is_zeroed_chunk to detect whether the trailing memory is zeroed,
+ * update extent's zeroed field, and zero as necessary.
*/
- is_zeroed_chunk = zero;
-
+ is_zeroed_chunk = false;
if (arena_chunk_ralloc_huge_expand(tsdn, arena, ptr, oldsize, usize,
&is_zeroed_chunk))
return (true);
malloc_mutex_lock(tsdn, &arena->huge_mtx);
- /* Update the size of the huge allocation. */
huge_node_unset(ptr, node);
extent_node_size_set(node, usize);
+ extent_node_zeroed_set(node, extent_node_zeroed_get(node) &&
+ is_zeroed_chunk);
huge_node_reset(tsdn, ptr, node);
malloc_mutex_unlock(tsdn, &arena->huge_mtx);
diff --git a/contrib/jemalloc/src/jemalloc.c b/contrib/jemalloc/src/jemalloc.c
index 666c49d..46dd1d1 100644
--- a/contrib/jemalloc/src/jemalloc.c
+++ b/contrib/jemalloc/src/jemalloc.c
@@ -1743,7 +1743,7 @@ je_calloc(size_t num, size_t size)
ret = ialloc_body(num_size, true, &tsdn, &usize, true);
ialloc_post_check(ret, tsdn, usize, "calloc", true, true);
UTRACE(0, num_size, ret);
- JEMALLOC_VALGRIND_MALLOC(ret != NULL, tsdn, ret, usize, false);
+ JEMALLOC_VALGRIND_MALLOC(ret != NULL, tsdn, ret, usize, true);
}
return (ret);
@@ -2226,7 +2226,7 @@ irallocx_prof(tsd_t *tsd, void *old_ptr, size_t old_usize, size_t size,
prof_active = prof_active_get_unlocked();
old_tctx = prof_tctx_get(tsd_tsdn(tsd), old_ptr);
- tctx = prof_alloc_prep(tsd, *usize, prof_active, true);
+ tctx = prof_alloc_prep(tsd, *usize, prof_active, false);
if (unlikely((uintptr_t)tctx != (uintptr_t)1U)) {
p = irallocx_prof_sample(tsd, old_ptr, old_usize, *usize,
alignment, zero, tcache, arena, tctx);
@@ -2235,7 +2235,7 @@ irallocx_prof(tsd_t *tsd, void *old_ptr, size_t old_usize, size_t size,
tcache, arena);
}
if (unlikely(p == NULL)) {
- prof_alloc_rollback(tsd, tctx, true);
+ prof_alloc_rollback(tsd, tctx, false);
return (NULL);
}
@@ -2250,7 +2250,7 @@ irallocx_prof(tsd_t *tsd, void *old_ptr, size_t old_usize, size_t size,
*/
*usize = isalloc(tsd_tsdn(tsd), p, config_prof);
}
- prof_realloc(tsd, p, *usize, tctx, prof_active, true, old_ptr,
+ prof_realloc(tsd, p, *usize, tctx, prof_active, false, old_ptr,
old_usize, old_tctx);
return (p);
diff --git a/contrib/jemalloc/src/nstime.c b/contrib/jemalloc/src/nstime.c
index 26e49dc..aad2c26 100644
--- a/contrib/jemalloc/src/nstime.c
+++ b/contrib/jemalloc/src/nstime.c
@@ -128,9 +128,11 @@ nstime_update(nstime_t *time)
time->ns = ts.tv_sec * BILLION + ts.tv_nsec;
}
#else
- struct timeval tv;
- gettimeofday(&tv, NULL);
- time->ns = tv.tv_sec * BILLION + tv.tv_usec * 1000;
+ {
+ struct timeval tv;
+ gettimeofday(&tv, NULL);
+ time->ns = tv.tv_sec * BILLION + tv.tv_usec * 1000;
+ }
#endif
/* Handle non-monotonic clocks. */
diff --git a/contrib/ldns-host/Makefile b/contrib/ldns-host/Makefile
index 9d07a58..ba79ea8 100644
--- a/contrib/ldns-host/Makefile
+++ b/contrib/ldns-host/Makefile
@@ -6,11 +6,11 @@ LOCALBASE?=/usr/local
PREFIX?=${LOCALBASE}
MANDIR?=${PREFIX}/man
-XCFLAGS=${CFLAGS} -I${LOCALBASE}/include
+XCFLAGS=${CFLAGS} -I${LOCALBASE}/include -std=c99 -Wall -Wextra -pedantic
XLDFLAGS=${LDFLAGS} -L${LOCALBASE}/lib -lldns
${PROG}: ${SRC}
- ${CC} -o $@ ${XCFLAGS} ${XLDFLAGS} ${SRC}
+ ${CC} -o $@ ${XCFLAGS} ${SRC} ${XLDFLAGS}
clean:
rm -f ${PROG}
diff --git a/contrib/ldns-host/ldns-host.1 b/contrib/ldns-host/ldns-host.1
index 3a85ac4..38cffa6 100644
--- a/contrib/ldns-host/ldns-host.1
+++ b/contrib/ldns-host/ldns-host.1
@@ -236,9 +236,6 @@ commands, while
.Sq host
from BIND9 uses whatever command was specified last.
.It
-Multi-packet zone transfers are not supported; only the first
-response packet is printed.
-.It
.Sq Pseudosection TSIG
is missing from verbose packet output.
.El
diff --git a/contrib/ldns-host/ldns-host.c b/contrib/ldns-host/ldns-host.c
index 85c7dcb..3184f68 100644
--- a/contrib/ldns-host/ldns-host.c
+++ b/contrib/ldns-host/ldns-host.c
@@ -7,16 +7,14 @@
* without any warranty.
*/
-#include <netinet/in.h>
-
+#include <ldns/ldns.h>
#include <limits.h>
#include <netdb.h>
+#include <netinet/in.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
-#include <ldns/ldns.h>
-
/* General utilities.
*/
@@ -159,11 +157,108 @@ memerr:
}
static ldns_status
+ldns_tcp_start(ldns_resolver *res, ldns_pkt *qpkt, int nameserver) {
+ /* This routine is based on ldns_axfr_start, with the major
+ * difference in that it takes a query packet explicitly.
+ */
+ struct sockaddr_storage *ns = NULL;
+ size_t ns_len = 0;
+ ldns_buffer *qbuf = NULL;
+ ldns_status status;
+
+ ns = ldns_rdf2native_sockaddr_storage(
+ res->_nameservers[nameserver], ldns_resolver_port(res), &ns_len);
+ if (ns == NULL) {
+ status = LDNS_STATUS_MEM_ERR;
+ goto error;
+ }
+
+ res->_socket = ldns_tcp_connect(
+ ns, (socklen_t)ns_len, ldns_resolver_timeout(res));
+ if (res->_socket <= 0) {
+ status = LDNS_STATUS_ADDRESS_ERR;
+ goto error;
+ }
+
+ qbuf = ldns_buffer_new(LDNS_MAX_PACKETLEN);
+ if (qbuf == NULL) {
+ status = LDNS_STATUS_MEM_ERR;
+ goto error;
+ }
+
+ status = ldns_pkt2buffer_wire(qbuf, qpkt);
+ if (status != LDNS_STATUS_OK)
+ goto error;
+
+ if (ldns_tcp_send_query(qbuf, res->_socket, ns, (socklen_t)ns_len) == 0) {
+ status = LDNS_STATUS_NETWORK_ERR;
+ goto error;
+ }
+
+ ldns_buffer_free(qbuf);
+ free(ns);
+ return LDNS_STATUS_OK;
+
+error:
+ ldns_buffer_free(qbuf);
+ free(ns);
+ if (res->_socket > 0) {
+ close(res->_socket);
+ res->_socket = 0;
+ }
+ return status;
+}
+
+static ldns_status
+ldns_tcp_read(ldns_pkt **answer, ldns_resolver *res) {
+ ldns_status status;
+ struct timeval t1, t2;
+ uint8_t *data;
+ size_t size;
+
+ if (res->_socket <= 0)
+ return LDNS_STATUS_ERR;
+
+ gettimeofday(&t1, NULL);
+ data = ldns_tcp_read_wire_timeout(
+ res->_socket, &size, ldns_resolver_timeout(res));
+ if (data == NULL)
+ goto error;
+
+ status = ldns_wire2pkt(answer, data, size);
+ free(data);
+ if (status != LDNS_STATUS_OK)
+ goto error;
+
+ gettimeofday(&t2, NULL);
+ ldns_pkt_set_querytime(*answer,
+ (uint32_t)((t2.tv_sec - t1.tv_sec)*1000) +
+ (t2.tv_usec - t1.tv_usec)/1000);
+ ldns_pkt_set_timestamp(*answer, t2);
+ return status;
+
+error:
+ close(res->_socket);
+ res->_socket = 0;
+ return LDNS_STATUS_ERR;
+}
+
+static void
+ldns_tcp_close(ldns_resolver *res) {
+ if (res->_socket > 0) {
+ close(res->_socket);
+ res->_socket = 0;
+ }
+}
+
+static ldns_status
ldns_resolver_send_to(ldns_pkt **answer, ldns_resolver *res,
const ldns_rdf *name, ldns_rr_type t, ldns_rr_class c,
- uint16_t flags, uint32_t ixfr_serial, int nameserver) {
- ldns_status status;
+ uint16_t flags, uint32_t ixfr_serial, int nameserver,
+ bool close_tcp) {
+ ldns_status status = LDNS_STATUS_OK;
ldns_pkt *qpkt;
+ struct timeval now;
int nscnt = ldns_resolver_nameserver_count(res);
ldns_rdf **ns = ldns_resolver_nameservers(res);
@@ -173,12 +268,38 @@ ldns_resolver_send_to(ldns_pkt **answer, ldns_resolver *res,
ldns_resolver_set_rtt(res, &rtt[nameserver]);
ldns_resolver_set_nameserver_count(res, 1);
- status = ldns_resolver_prepare_query_pkt(&qpkt, res, name, t, c, flags);
- if (status == LDNS_STATUS_OK && t == LDNS_RR_TYPE_IXFR)
+ /* The next fragment should have been a call to
+ * ldns_resolver_prepare_query_pkt(), but starting with ldns
+ * version 1.6.17 that function tries to add it's own SOA
+ * records when rr_type is LDNS_RR_TYPE_IXFR, and we don't
+ * want that.
+ */
+ qpkt = ldns_pkt_query_new(ldns_rdf_clone(name), t, c, flags);
+ if (qpkt == NULL) {
+ status = LDNS_STATUS_ERR;
+ goto done;
+ }
+ now.tv_sec = time(NULL);
+ now.tv_usec = 0;
+ ldns_pkt_set_timestamp(qpkt, now);
+ ldns_pkt_set_random_id(qpkt);
+
+ if (t == LDNS_RR_TYPE_IXFR) {
status = ldns_pkt_push_rr_soa(qpkt,
LDNS_SECTION_AUTHORITY, name, c, ixfr_serial);
- if (status == LDNS_STATUS_OK)
+ if (status != LDNS_STATUS_OK) goto done;
+ }
+ if (close_tcp) {
status = ldns_resolver_send_pkt(answer, res, qpkt);
+ } else {
+ status = ldns_tcp_start(res, qpkt, 0);
+ if (status != LDNS_STATUS_OK) goto done;
+ status = ldns_tcp_read(answer, res);
+ if (status != LDNS_STATUS_OK) goto done;
+ ldns_pkt_set_answerfrom(*answer, ldns_rdf_clone(ns[0]));
+ }
+
+done:
ldns_pkt_free(qpkt);
ldns_resolver_set_nameservers(res, ns);
@@ -203,9 +324,9 @@ ldns_pkt_filter_answer(ldns_pkt *pkt, ldns_rr_type type) {
type == rrtype ||
(type == LDNS_RR_TYPE_AXFR &&
(rrtype == LDNS_RR_TYPE_A ||
- rrtype == LDNS_RR_TYPE_AAAA ||
- rrtype == LDNS_RR_TYPE_NS ||
- rrtype == LDNS_RR_TYPE_PTR)))
+ rrtype == LDNS_RR_TYPE_AAAA ||
+ rrtype == LDNS_RR_TYPE_NS ||
+ rrtype == LDNS_RR_TYPE_PTR)))
ldns_rr_list_set_rr(rrlist, rr, j++);
}
ldns_rr_list_set_rr_count(rrlist, j);
@@ -438,7 +559,7 @@ print_received_line(ldns_resolver *res, ldns_pkt *pkt) {
#define DEFAULT_TCP_TIMEOUT 10
#define DEFAULT_UDP_TIMEOUT 5
-enum operation_mode { M_AXFR, M_DEFAULT_Q, M_SINGLE_Q, M_SOA };
+enum operation_mode { M_AXFR, M_IXFR, M_DEFAULT_Q, M_SINGLE_Q, M_SOA };
static enum operation_mode o_mode = M_DEFAULT_Q;
static bool o_ignore_servfail = true;
@@ -454,15 +575,15 @@ static int o_ipversion = LDNS_RESOLV_INETANY;
static int o_ndots = 1;
static int o_retries = 1;
static ldns_rr_class o_rrclass = LDNS_RR_CLASS_IN;
-static ldns_rr_type o_rrtype = LDNS_RR_TYPE_A;
+static ldns_rr_type o_rrtype = (ldns_rr_type)-1;
static time_t o_timeout = 0;
static uint32_t o_ixfr_serial = 0;
static void
usage(void) {
- fputs(
- "Usage: host [-aCdilrsTvw46] [-c class] [-N ndots] [-R number]\n"
- " [-t type] [-W wait] name [server]\n"
+ fprintf(stderr,
+ "Usage: %s [-aCdilrsTvw46] [-c class] [-N ndots] [-R number]\n"
+ " %*c [-t type] [-W wait] name [server]\n"
"\t-a same as -v -t ANY\n"
"\t-C query SOA records from all authoritative name servers\n"
"\t-c use this query class (IN, CH, HS, etc)\n"
@@ -480,7 +601,7 @@ usage(void) {
"\t-W wait this many seconds for a reply\n"
"\t-4 use IPv4 only\n"
"\t-6 use IPv6 only\n",
- stderr);
+ progname, (int)strlen(progname), ' ');
exit(1);
}
@@ -513,7 +634,8 @@ parse_args(int argc, char *argv[]) {
case 'i': o_ip6_int = true; break;
case 'l':
o_mode = M_AXFR;
- o_rrtype = LDNS_RR_TYPE_AXFR;
+ if (o_rrtype == (ldns_rr_type)-1)
+ o_rrtype = LDNS_RR_TYPE_AXFR;
o_tcp = true;
break;
case 'N':
@@ -542,13 +664,15 @@ parse_args(int argc, char *argv[]) {
if (o_rrtype <= 0)
die(2, "invalid type: %s\n", optarg);
}
- if (o_rrtype == LDNS_RR_TYPE_AXFR || o_rrtype == LDNS_RR_TYPE_IXFR)
- o_tcp = true;
if (o_rrtype == LDNS_RR_TYPE_AXFR) {
o_mode = M_AXFR;
o_rrtype = LDNS_RR_TYPE_ANY;
o_verbose = true;
}
+ if (o_rrtype == LDNS_RR_TYPE_IXFR) {
+ o_mode = M_IXFR;
+ o_rrtype = LDNS_RR_TYPE_ANY;
+ }
break;
case 'v': o_verbose = true; break;
case 'w':
@@ -574,6 +698,8 @@ parse_args(int argc, char *argv[]) {
o_server = argv[1];
o_print_pkt_server = true;
}
+ if (o_rrtype == (ldns_rr_type)-1)
+ o_rrtype = LDNS_RR_TYPE_A;
}
static ldns_rdf*
@@ -602,7 +728,7 @@ safe_dname_cat_clone(const ldns_rdf *rd1, const ldns_rdf *rd2) {
}
static bool
-query(ldns_resolver *res, ldns_rdf *domain, ldns_pkt **pkt) {
+query(ldns_resolver *res, ldns_rdf *domain, ldns_pkt **pkt, bool close_tcp) {
ldns_status status;
ldns_pkt_rcode rcode;
int i, cnt;
@@ -614,7 +740,8 @@ query(ldns_resolver *res, ldns_rdf *domain, ldns_pkt **pkt) {
}
for (cnt = ldns_resolver_nameserver_count(res), i = 0; i < cnt; i++) {
status = ldns_resolver_send_to(pkt, res, domain, o_rrtype,
- o_rrclass, o_recursive ? LDNS_RD : 0, o_ixfr_serial, i);
+ o_rrclass, o_recursive ? LDNS_RD : 0, o_ixfr_serial, i,
+ close_tcp);
if (status != LDNS_STATUS_OK) {
*pkt = NULL;
continue;
@@ -624,7 +751,8 @@ query(ldns_resolver *res, ldns_rdf *domain, ldns_pkt **pkt) {
printf(";; Truncated, retrying in TCP mode.\n");
ldns_resolver_set_usevc(res, true);
status = ldns_resolver_send_to(pkt, res, domain, o_rrtype,
- o_rrclass, o_recursive ? LDNS_RD : 0, o_ixfr_serial, i);
+ o_rrclass, o_recursive ? LDNS_RD : 0, o_ixfr_serial, i,
+ close_tcp);
ldns_resolver_set_usevc(res, false);
if (status != LDNS_STATUS_OK)
continue;
@@ -642,16 +770,17 @@ query(ldns_resolver *res, ldns_rdf *domain, ldns_pkt **pkt) {
}
static ldns_rdf *
-search(ldns_resolver *res, ldns_rdf *domain, ldns_pkt **pkt, bool absolute) {
+search(ldns_resolver *res, ldns_rdf *domain, ldns_pkt **pkt,
+ bool absolute, bool close_tcp) {
ldns_rdf *dname, **searchlist;
int i, n;
- if (absolute && query(res, domain, pkt))
+ if (absolute && query(res, domain, pkt, close_tcp))
return domain;
if ((dname = ldns_resolver_domain(res)) != NULL) {
dname = safe_dname_cat_clone(domain, dname);
- if (query(res, dname, pkt))
+ if (query(res, dname, pkt, close_tcp))
return dname;
}
@@ -659,11 +788,11 @@ search(ldns_resolver *res, ldns_rdf *domain, ldns_pkt **pkt, bool absolute) {
n = ldns_resolver_searchlist_count(res);
for (i = 0; i < n; i++) {
dname = safe_dname_cat_clone(domain, searchlist[i]);
- if (query(res, dname, pkt))
+ if (query(res, dname, pkt, close_tcp))
return dname;
}
- if (!absolute && query(res, domain, pkt))
+ if (!absolute && query(res, domain, pkt, close_tcp))
return domain;
return NULL;
@@ -691,7 +820,7 @@ report(ldns_resolver *res, ldns_rdf *domain, ldns_pkt *pkt) {
print_pkt_verbose(pkt);
} else {
print_pkt_short(pkt, o_print_rr_server);
- if (o_mode != M_DEFAULT_Q &&
+ if (o_mode == M_SINGLE_Q &&
ldns_rr_list_rr_count(ldns_pkt_answer(pkt)) == 0) {
print_rdf_nodot(domain);
printf(" has no ");
@@ -709,7 +838,7 @@ doquery(ldns_resolver *res, ldns_rdf *domain) {
ldns_pkt *pkt;
bool q;
- q = query(res, domain, &pkt);
+ q = query(res, domain, &pkt, true);
report(res, domain, pkt);
return q;
}
@@ -719,7 +848,7 @@ doquery_filtered(ldns_resolver *res, ldns_rdf *domain) {
ldns_pkt *pkt;
bool q;
- q = query(res, domain, &pkt);
+ q = query(res, domain, &pkt, true);
ldns_pkt_filter_answer(pkt, o_rrtype);
report(res, domain, pkt);
return q;
@@ -730,7 +859,7 @@ dosearch(ldns_resolver *res, ldns_rdf *domain, bool absolute) {
ldns_pkt *pkt;
ldns_rdf *dname;
- dname = search(res, domain, &pkt, absolute);
+ dname = search(res, domain, &pkt, absolute, true);
report(res, dname != NULL ? dname : domain, pkt);
return o_mode != M_DEFAULT_Q ? (dname != NULL) :
(dname != NULL) &&
@@ -739,17 +868,44 @@ dosearch(ldns_resolver *res, ldns_rdf *domain, bool absolute) {
}
static bool
-doaxfr(ldns_resolver *res, ldns_rdf *domain, bool absolute) {
- ldns_pkt *pkt;
+dozonetransfer(ldns_resolver *res, ldns_rdf *domain, bool absolute) {
+ ldns_pkt *pkt, *nextpkt;
ldns_rdf *dname;
ldns_rr_type rrtype;
+ ldns_rr_list *rrl;
+ int i, nsoa = 0;
rrtype = o_rrtype;
- o_rrtype = LDNS_RR_TYPE_AXFR;
- dname = search(res, domain, &pkt, absolute);
- ldns_pkt_filter_answer(pkt, rrtype);
- report(res, dname != NULL ? dname : domain, pkt);
- return dname != NULL;
+ o_rrtype = (o_mode == M_AXFR) ? LDNS_RR_TYPE_AXFR : LDNS_RR_TYPE_IXFR;
+ dname = search(res, domain, &pkt, absolute, false);
+
+ for (;;) {
+ rrl = ldns_pkt_answer(pkt);
+ for (i = ldns_rr_list_rr_count(rrl) - 1; i >= 0; i--) {
+ if (ldns_rr_get_type(ldns_rr_list_rr(rrl, i)) == LDNS_RR_TYPE_SOA)
+ nsoa++;
+ }
+ ldns_pkt_filter_answer(pkt, rrtype);
+ report(res, dname != NULL ? dname : domain, pkt);
+ if ((dname == NULL) ||
+ (ldns_pkt_get_rcode(pkt) != LDNS_RCODE_NOERROR)) {
+ printf("; Transfer failed.\n");
+ ldns_tcp_close(res);
+ return false;
+ }
+ if (nsoa >= 2) {
+ ldns_tcp_close(res);
+ return true;
+ }
+ if (ldns_tcp_read(&nextpkt, res) != LDNS_STATUS_OK) {
+ printf("; Transfer failed.\n");
+ return false;
+ }
+ ldns_pkt_set_answerfrom(nextpkt,
+ ldns_rdf_clone(ldns_pkt_answerfrom(pkt)));
+ ldns_pkt_free(pkt);
+ pkt = nextpkt;
+ }
}
static bool
@@ -760,7 +916,7 @@ dosoa(ldns_resolver *res, ldns_rdf *domain, bool absolute) {
ldns_rr *rr;
size_t i, j, n, cnt;
- if ((dname = search(res, domain, &pkt, absolute)) == NULL)
+ if ((dname = search(res, domain, &pkt, absolute, true)) == NULL)
return false;
answer = ldns_pkt_answer(pkt);
@@ -780,9 +936,9 @@ dosoa(ldns_resolver *res, ldns_rdf *domain, bool absolute) {
ldns_resolver_remove_nameservers(res);
rr = ldns_rr_list_rr(nsaddrs[i], j);
if ((ldns_resolver_ip6(res) == LDNS_RESOLV_INET &&
- ldns_rr_get_type(rr) == LDNS_RR_TYPE_AAAA) ||
+ ldns_rr_get_type(rr) == LDNS_RR_TYPE_AAAA) ||
(ldns_resolver_ip6(res) == LDNS_RESOLV_INET6 &&
- ldns_rr_get_type(rr) == LDNS_RR_TYPE_A))
+ ldns_rr_get_type(rr) == LDNS_RR_TYPE_A))
continue;
if (ldns_resolver_push_nameserver_rr(res, rr) == LDNS_STATUS_OK)
/* bind9-host queries for domain, not dname here */
@@ -879,6 +1035,9 @@ main(int argc, char *argv[]) {
o_rrtype = LDNS_RR_TYPE_PTR;
return !doquery(res, dname);
}
- return !(o_mode == M_SOA ? dosoa : o_mode == M_AXFR ? doaxfr : dosearch)
+ return !(o_mode == M_SOA ? dosoa :
+ o_mode == M_AXFR ? dozonetransfer :
+ o_mode == M_IXFR ? dozonetransfer :
+ dosearch)
(res, safe_str2rdf_dname(o_name), ndots(o_name) >= o_ndots);
}
diff --git a/contrib/libc-vis/unvis.c b/contrib/libc-vis/unvis.c
index 9cf112c..d96d231 100644
--- a/contrib/libc-vis/unvis.c
+++ b/contrib/libc-vis/unvis.c
@@ -1,4 +1,4 @@
-/* $NetBSD: unvis.c,v 1.41 2012/12/15 04:29:53 matt Exp $ */
+/* $NetBSD: unvis.c,v 1.44 2014/09/26 15:43:36 roy Exp $ */
/*-
* Copyright (c) 1989, 1993
@@ -34,7 +34,7 @@
#if 0
static char sccsid[] = "@(#)unvis.c 8.1 (Berkeley) 6/4/93";
#else
-__RCSID("$NetBSD: unvis.c,v 1.41 2012/12/15 04:29:53 matt Exp $");
+__RCSID("$NetBSD: unvis.c,v 1.44 2014/09/26 15:43:36 roy Exp $");
#endif
#endif /* LIBC_SCCS and not lint */
__FBSDID("$FreeBSD$");
@@ -322,6 +322,12 @@ unvis(char *cp, int c, int *astate, int flag)
*/
*astate = SS(0, S_GROUND);
return UNVIS_NOCHAR;
+ default:
+ if (isgraph(c)) {
+ *cp = c;
+ *astate = SS(0, S_GROUND);
+ return UNVIS_VALID;
+ }
}
goto bad;
diff --git a/contrib/libc-vis/vis.3 b/contrib/libc-vis/vis.3
index 4bff663..71daad6 100644
--- a/contrib/libc-vis/vis.3
+++ b/contrib/libc-vis/vis.3
@@ -1,4 +1,4 @@
-.\" $NetBSD: vis.3,v 1.39 2013/02/20 20:05:26 christos Exp $
+.\" $NetBSD: vis.3,v 1.45 2016/06/08 15:00:04 wiz Exp $
.\" $FreeBSD$
.\"
.\" Copyright (c) 1989, 1991, 1993
@@ -30,13 +30,14 @@
.\"
.\" @(#)vis.3 8.1 (Berkeley) 6/9/93
.\"
-.Dd February 19, 2013
+.Dd January 14, 2015
.Dt VIS 3
.Os
.Sh NAME
.Nm vis ,
.Nm nvis ,
.Nm strvis ,
+.Nm stravis ,
.Nm strnvis ,
.Nm strvisx ,
.Nm strnvisx ,
@@ -60,6 +61,8 @@
.Ft int
.Fn strvis "char *dst" "const char *src" "int flag"
.Ft int
+.Fn stravis "char **dst" "const char *src" "int flag"
+.Ft int
.Fn strnvis "char *dst" "size_t dlen" "const char *src" "int flag"
.Ft int
.Fn strvisx "char *dst" "const char *src" "size_t len" "int flag"
@@ -112,6 +115,7 @@ encoding format (explained below).
.Pp
The
.Fn strvis ,
+.Fn stravis ,
.Fn strnvis ,
.Fn strvisx ,
and
@@ -158,6 +162,9 @@ forms return the number of characters in
(not including the trailing
.Dv NUL ) .
The
+.Fn stravis
+function allocates space dynamically to hold the string.
+The
.Dq Nm n
versions of the functions also take an additional argument
.Fa dlen
@@ -240,11 +247,31 @@ alter this:
Also encode the magic characters
.Ql ( * ,
.Ql \&? ,
-.Ql \&[
+.Ql \&[ ,
and
.Ql # )
recognized by
.Xr glob 3 .
+.It Dv VIS_SHELL
+Also encode the meta characters used by shells (in addition to the glob
+characters):
+.Ql ( ' ,
+.Ql ` ,
+.Ql \&" ,
+.Ql \&; ,
+.Ql & ,
+.Ql < ,
+.Ql > ,
+.Ql \&( ,
+.Ql \&) ,
+.Ql \&| ,
+.Ql \&] ,
+.Ql \e ,
+.Ql $ ,
+.Ql \&! ,
+.Ql \&^ ,
+and
+.Ql ~ ) .
.It Dv VIS_SP
Also encode space.
.It Dv VIS_TAB
@@ -253,11 +280,10 @@ Also encode tab.
Also encode newline.
.It Dv VIS_WHITE
Synonym for
-.Dv VIS_SP
-\&|
-.Dv VIS_TAB
-\&|
-.Dv VIS_NL .
+.Dv VIS_SP | VIS_TAB | VIS_NL .
+.It Dv VIS_META
+Synonym for
+.Dv VIS_WHITE | VIS_GLOB | VIS_SHELL .
.It Dv VIS_SAFE
Only encode
.Dq unsafe
@@ -418,6 +444,11 @@ The encoding conversion is influenced by the setting of the
environment variable which defines the set of characters
that can be copied without encoding.
.Pp
+If
+.Dv VIS_NOLOCALE
+is set, processing is done assuming the C locale and overriding
+any other environment settings.
+.Pp
When 8-bit data is present in the input,
.Ev LC_CTYPE
must be set to the correct locale or to the C locale.
@@ -513,7 +544,7 @@ appeared in
.Nx 6.0
and
.Fx 9.2 .
-Myltibyte character support was added in
+Multibyte character support was added in
.Nx 7.0
and
.Fx 9.2 .
diff --git a/contrib/libc-vis/vis.c b/contrib/libc-vis/vis.c
index 4863bbe..b4a5f32 100644
--- a/contrib/libc-vis/vis.c
+++ b/contrib/libc-vis/vis.c
@@ -1,4 +1,4 @@
-/* $NetBSD: vis.c,v 1.62 2014/09/08 17:35:01 christos Exp $ */
+/* $NetBSD: vis.c,v 1.71 2016/01/14 20:41:23 christos Exp $ */
/*-
* Copyright (c) 1989, 1993
@@ -57,7 +57,7 @@
#include <sys/cdefs.h>
#if defined(LIBC_SCCS) && !defined(lint)
-__RCSID("$NetBSD: vis.c,v 1.62 2014/09/08 17:35:01 christos Exp $");
+__RCSID("$NetBSD: vis.c,v 1.71 2016/01/14 20:41:23 christos Exp $");
#endif /* LIBC_SCCS and not lint */
#ifdef __FBSDID
__FBSDID("$FreeBSD$");
@@ -97,6 +97,30 @@ static wchar_t *do_svis(wchar_t *, wint_t, int, wint_t, const wchar_t *);
#undef BELL
#define BELL L'\a'
+
+#if defined(LC_C_LOCALE)
+#define iscgraph(c) isgraph_l(c, LC_C_LOCALE)
+#else
+/* Keep it simple for now, no locale stuff */
+#define iscgraph(c) isgraph(c)
+#ifdef notyet
+#include <locale.h>
+static int
+iscgraph(int c) {
+ int rv;
+ char *ol;
+
+ ol = setlocale(LC_CTYPE, "C");
+ rv = isgraph(c);
+ if (ol)
+ setlocale(LC_CTYPE, ol);
+ return rv;
+}
+#endif
+#endif
+
+#define ISGRAPH(flags, c) \
+ (((flags) & VIS_NOLOCALE) ? iscgraph(c) : iswgraph(c))
#define iswoctal(c) (((u_char)(c)) >= L'0' && ((u_char)(c)) <= L'7')
#define iswwhite(c) (c == L' ' || c == L'\t' || c == L'\n')
@@ -104,7 +128,10 @@ static wchar_t *do_svis(wchar_t *, wint_t, int, wint_t, const wchar_t *);
#define xtoa(c) L"0123456789abcdef"[c]
#define XTOA(c) L"0123456789ABCDEF"[c]
-#define MAXEXTRAS 10
+#define MAXEXTRAS 30
+
+static const wchar_t char_shell[] = L"'`\";&<>()|{}]\\$!^~";
+static const wchar_t char_glob[] = L"*?[#";
#if !HAVE_NBTOOL_CONFIG_H
#ifndef __NetBSD__
@@ -213,8 +240,23 @@ do_mbyte(wchar_t *dst, wint_t c, int flags, wint_t nextc, int iswextra)
*dst++ = L'0';
}
return dst;
+ /* We cannot encode these characters in VIS_CSTYLE
+ * because they special meaning */
+ case L'n':
+ case L'r':
+ case L'b':
+ case L'a':
+ case L'v':
+ case L't':
+ case L'f':
+ case L's':
+ case L'0':
+ case L'M':
+ case L'^':
+ case L'$': /* vis(1) -l */
+ break;
default:
- if (iswgraph(c)) {
+ if (ISGRAPH(flags, c) && !iswoctal(c)) {
*dst++ = L'\\';
*dst++ = c;
return dst;
@@ -266,7 +308,7 @@ do_svis(wchar_t *dst, wint_t c, int flags, wint_t nextc, const wchar_t *extra)
uint64_t bmsk, wmsk;
iswextra = wcschr(extra, c) != NULL;
- if (!iswextra && (iswgraph(c) || iswwhite(c) ||
+ if (!iswextra && (ISGRAPH(flags, c) || iswwhite(c) ||
((flags & VIS_SAFE) && iswsafe(c)))) {
*dst++ = c;
return dst;
@@ -310,25 +352,27 @@ makeextralist(int flags, const char *src)
{
wchar_t *dst, *d;
size_t len;
+ const wchar_t *s;
len = strlen(src);
if ((dst = calloc(len + MAXEXTRAS, sizeof(*dst))) == NULL)
return NULL;
- if (mbstowcs(dst, src, len) == (size_t)-1) {
+ if ((flags & VIS_NOLOCALE) || mbstowcs(dst, src, len) == (size_t)-1) {
size_t i;
for (i = 0; i < len; i++)
- dst[i] = (wint_t)(u_char)src[i];
+ dst[i] = (wchar_t)(u_char)src[i];
d = dst + len;
} else
d = dst + wcslen(dst);
- if (flags & VIS_GLOB) {
- *d++ = L'*';
- *d++ = L'?';
- *d++ = L'[';
- *d++ = L'#';
- }
+ if (flags & VIS_GLOB)
+ for (s = char_glob; *s; *d++ = *s++)
+ continue;
+
+ if (flags & VIS_SHELL)
+ for (s = char_shell; *s; *d++ = *s++)
+ continue;
if (flags & VIS_SP) *d++ = L' ';
if (flags & VIS_TAB) *d++ = L'\t';
@@ -345,7 +389,7 @@ makeextralist(int flags, const char *src)
* All user-visible functions call this one.
*/
static int
-istrsenvisx(char *mbdst, size_t *dlen, const char *mbsrc, size_t mblength,
+istrsenvisx(char **mbdstp, size_t *dlen, const char *mbsrc, size_t mblength,
int flags, const char *mbextra, int *cerr_ptr)
{
wchar_t *dst, *src, *pdst, *psrc, *start, *extra;
@@ -353,10 +397,11 @@ istrsenvisx(char *mbdst, size_t *dlen, const char *mbsrc, size_t mblength,
uint64_t bmsk, wmsk;
wint_t c;
visfun_t f;
- int clen = 0, cerr = 0, error = -1, i, shft;
+ int clen = 0, cerr, error = -1, i, shft;
+ char *mbdst, *mdst;
ssize_t mbslength, maxolen;
- _DIAGASSERT(mbdst != NULL);
+ _DIAGASSERT(mbdstp != NULL);
_DIAGASSERT(mbsrc != NULL || mblength == 0);
_DIAGASSERT(mbextra != NULL);
@@ -375,16 +420,28 @@ istrsenvisx(char *mbdst, size_t *dlen, const char *mbsrc, size_t mblength,
/* Allocate space for the wide char strings */
psrc = pdst = extra = NULL;
+ mdst = NULL;
if ((psrc = calloc(mblength + 1, sizeof(*psrc))) == NULL)
return -1;
if ((pdst = calloc((4 * mblength) + 1, sizeof(*pdst))) == NULL)
goto out;
+ if (*mbdstp == NULL) {
+ if ((mdst = calloc((4 * mblength) + 1, sizeof(*mdst))) == NULL)
+ goto out;
+ *mbdstp = mdst;
+ }
+
+ mbdst = *mbdstp;
dst = pdst;
src = psrc;
- /* Use caller's multibyte conversion error flag. */
- if (cerr_ptr)
- cerr = *cerr_ptr;
+ if (flags & VIS_NOLOCALE) {
+ /* Do one byte at a time conversion */
+ cerr = 1;
+ } else {
+ /* Use caller's multibyte conversion error flag. */
+ cerr = cerr_ptr ? *cerr_ptr : 0;
+ }
/*
* Input loop.
@@ -439,7 +496,7 @@ istrsenvisx(char *mbdst, size_t *dlen, const char *mbsrc, size_t mblength,
errno = ENOSPC;
goto out;
}
- *mbdst = '\0'; /* can't create extra, return "" */
+ *mbdst = '\0'; /* can't create extra, return "" */
error = 0;
goto out;
}
@@ -511,9 +568,11 @@ istrsenvisx(char *mbdst, size_t *dlen, const char *mbsrc, size_t mblength,
/* Terminate the output string. */
*mbdst = '\0';
- /* Pass conversion error flag out. */
- if (cerr_ptr)
- *cerr_ptr = cerr;
+ if (flags & VIS_NOLOCALE) {
+ /* Pass conversion error flag out. */
+ if (cerr_ptr)
+ *cerr_ptr = cerr;
+ }
free(extra);
free(pdst);
@@ -524,14 +583,15 @@ out:
free(extra);
free(pdst);
free(psrc);
+ free(mdst);
return error;
}
static int
-istrsenvisxl(char *mbdst, size_t *dlen, const char *mbsrc,
+istrsenvisxl(char **mbdstp, size_t *dlen, const char *mbsrc,
int flags, const char *mbextra, int *cerr_ptr)
{
- return istrsenvisx(mbdst, dlen, mbsrc,
+ return istrsenvisx(mbdstp, dlen, mbsrc,
mbsrc != NULL ? strlen(mbsrc) : 0, flags, mbextra, cerr_ptr);
}
@@ -554,7 +614,7 @@ svis(char *mbdst, int c, int flags, int nextc, const char *mbextra)
cc[0] = c;
cc[1] = nextc;
- ret = istrsenvisx(mbdst, NULL, cc, 1, flags, mbextra, NULL);
+ ret = istrsenvisx(&mbdst, NULL, cc, 1, flags, mbextra, NULL);
if (ret < 0)
return NULL;
return mbdst + ret;
@@ -569,7 +629,7 @@ snvis(char *mbdst, size_t dlen, int c, int flags, int nextc, const char *mbextra
cc[0] = c;
cc[1] = nextc;
- ret = istrsenvisx(mbdst, &dlen, cc, 1, flags, mbextra, NULL);
+ ret = istrsenvisx(&mbdst, &dlen, cc, 1, flags, mbextra, NULL);
if (ret < 0)
return NULL;
return mbdst + ret;
@@ -578,33 +638,33 @@ snvis(char *mbdst, size_t dlen, int c, int flags, int nextc, const char *mbextra
int
strsvis(char *mbdst, const char *mbsrc, int flags, const char *mbextra)
{
- return istrsenvisxl(mbdst, NULL, mbsrc, flags, mbextra, NULL);
+ return istrsenvisxl(&mbdst, NULL, mbsrc, flags, mbextra, NULL);
}
int
strsnvis(char *mbdst, size_t dlen, const char *mbsrc, int flags, const char *mbextra)
{
- return istrsenvisxl(mbdst, &dlen, mbsrc, flags, mbextra, NULL);
+ return istrsenvisxl(&mbdst, &dlen, mbsrc, flags, mbextra, NULL);
}
int
strsvisx(char *mbdst, const char *mbsrc, size_t len, int flags, const char *mbextra)
{
- return istrsenvisx(mbdst, NULL, mbsrc, len, flags, mbextra, NULL);
+ return istrsenvisx(&mbdst, NULL, mbsrc, len, flags, mbextra, NULL);
}
int
strsnvisx(char *mbdst, size_t dlen, const char *mbsrc, size_t len, int flags,
const char *mbextra)
{
- return istrsenvisx(mbdst, &dlen, mbsrc, len, flags, mbextra, NULL);
+ return istrsenvisx(&mbdst, &dlen, mbsrc, len, flags, mbextra, NULL);
}
int
strsenvisx(char *mbdst, size_t dlen, const char *mbsrc, size_t len, int flags,
const char *mbextra, int *cerr_ptr)
{
- return istrsenvisx(mbdst, &dlen, mbsrc, len, flags, mbextra, cerr_ptr);
+ return istrsenvisx(&mbdst, &dlen, mbsrc, len, flags, mbextra, cerr_ptr);
}
#endif
@@ -621,7 +681,7 @@ vis(char *mbdst, int c, int flags, int nextc)
cc[0] = c;
cc[1] = nextc;
- ret = istrsenvisx(mbdst, NULL, cc, 1, flags, "", NULL);
+ ret = istrsenvisx(&mbdst, NULL, cc, 1, flags, "", NULL);
if (ret < 0)
return NULL;
return mbdst + ret;
@@ -636,7 +696,7 @@ nvis(char *mbdst, size_t dlen, int c, int flags, int nextc)
cc[0] = c;
cc[1] = nextc;
- ret = istrsenvisx(mbdst, &dlen, cc, 1, flags, "", NULL);
+ ret = istrsenvisx(&mbdst, &dlen, cc, 1, flags, "", NULL);
if (ret < 0)
return NULL;
return mbdst + ret;
@@ -653,13 +713,20 @@ nvis(char *mbdst, size_t dlen, int c, int flags, int nextc)
int
strvis(char *mbdst, const char *mbsrc, int flags)
{
- return istrsenvisxl(mbdst, NULL, mbsrc, flags, "", NULL);
+ return istrsenvisxl(&mbdst, NULL, mbsrc, flags, "", NULL);
}
int
strnvis(char *mbdst, size_t dlen, const char *mbsrc, int flags)
{
- return istrsenvisxl(mbdst, &dlen, mbsrc, flags, "", NULL);
+ return istrsenvisxl(&mbdst, &dlen, mbsrc, flags, "", NULL);
+}
+
+int
+stravis(char **mbdstp, const char *mbsrc, int flags)
+{
+ *mbdstp = NULL;
+ return istrsenvisxl(mbdstp, NULL, mbsrc, flags, "", NULL);
}
/*
@@ -676,19 +743,19 @@ strnvis(char *mbdst, size_t dlen, const char *mbsrc, int flags)
int
strvisx(char *mbdst, const char *mbsrc, size_t len, int flags)
{
- return istrsenvisx(mbdst, NULL, mbsrc, len, flags, "", NULL);
+ return istrsenvisx(&mbdst, NULL, mbsrc, len, flags, "", NULL);
}
int
strnvisx(char *mbdst, size_t dlen, const char *mbsrc, size_t len, int flags)
{
- return istrsenvisx(mbdst, &dlen, mbsrc, len, flags, "", NULL);
+ return istrsenvisx(&mbdst, &dlen, mbsrc, len, flags, "", NULL);
}
int
strenvisx(char *mbdst, size_t dlen, const char *mbsrc, size_t len, int flags,
int *cerr_ptr)
{
- return istrsenvisx(mbdst, &dlen, mbsrc, len, flags, "", cerr_ptr);
+ return istrsenvisx(&mbdst, &dlen, mbsrc, len, flags, "", cerr_ptr);
}
#endif
diff --git a/contrib/libc-vis/vis.h b/contrib/libc-vis/vis.h
index beb029c..e307a39 100644
--- a/contrib/libc-vis/vis.h
+++ b/contrib/libc-vis/vis.h
@@ -1,4 +1,4 @@
-/* $NetBSD: vis.h,v 1.21 2013/02/20 17:01:15 christos Exp $ */
+/* $NetBSD: vis.h,v 1.24 2016/01/14 20:42:14 christos Exp $ */
/* $FreeBSD$ */
/*-
@@ -64,6 +64,9 @@
#define VIS_HTTP1866 0x0400 /* http-style &#num; or &string; */
#define VIS_NOESCAPE 0x0800 /* don't decode `\' */
#define _VIS_END 0x1000 /* for unvis */
+#define VIS_SHELL 0x2000 /* encode shell special characters [not glob] */
+#define VIS_META (VIS_WHITE | VIS_GLOB | VIS_SHELL)
+#define VIS_NOLOCALE 0x4000 /* encode using the C locale */
/*
* unvis return codes
@@ -89,6 +92,7 @@ char *svis(char *, int, int, int, const char *);
char *snvis(char *, size_t, int, int, int, const char *);
int strvis(char *, const char *, int);
+int stravis(char **, const char *, int);
int strnvis(char *, size_t, const char *, int);
int strsvis(char *, const char *, int, const char *);
diff --git a/contrib/netbsd-tests/lib/libc/db/t_db.sh b/contrib/netbsd-tests/lib/libc/db/t_db.sh
index d256508..4f45ec1 100755
--- a/contrib/netbsd-tests/lib/libc/db/t_db.sh
+++ b/contrib/netbsd-tests/lib/libc/db/t_db.sh
@@ -37,6 +37,7 @@ dict()
elif [ -f /usr/dict/words ]; then
echo /usr/dict/words
else
+ echo ""
atf_fail "no dictionary found"
fi
}
@@ -44,12 +45,7 @@ dict()
# Begin FreeBSD
dict()
{
- if [ -f /usr/share/dict/words ]; then
- echo /usr/share/dict/words
- else
- echo /nonexistent
- atf_skip "Test requires dict/words"
- fi
+ echo /usr/share/dict/words
}
# End FreeBSD
@@ -62,6 +58,9 @@ small_btree_head()
"Checks btree database using small keys and small data" \
"pairs: takes the first hundred entries in the dictionary," \
"and makes them be key/data pairs."
+ # Begin FreeBSD
+ atf_set "require.files" /usr/share/dict/words
+ # End FreeBSD
}
small_btree_body()
{
@@ -88,6 +87,9 @@ small_hash_head()
"Checks hash database using small keys and small data" \
"pairs: takes the first hundred entries in the dictionary," \
"and makes them be key/data pairs."
+ # Begin FreeBSD
+ atf_set "require.files" /usr/share/dict/words
+ # End FreeBSD
}
small_hash_body()
{
@@ -114,6 +116,9 @@ small_recno_head()
"Checks recno database using small keys and small data" \
"pairs: takes the first hundred entries in the dictionary," \
"and makes them be key/data pairs."
+ # Begin FreeBSD
+ atf_set "require.files" /usr/share/dict/words
+ # End FreeBSD
}
small_recno_body()
{
@@ -138,6 +143,9 @@ medium_btree_head()
"Checks btree database using small keys and medium" \
"data pairs: takes the first 200 entries in the" \
"dictionary, and gives them each a medium size data entry."
+ # Begin FreeBSD
+ atf_set "require.files" /usr/share/dict/words
+ # End FreeBSD
}
medium_btree_body()
{
@@ -166,6 +174,9 @@ medium_hash_head()
"Checks hash database using small keys and medium" \
"data pairs: takes the first 200 entries in the" \
"dictionary, and gives them each a medium size data entry."
+ # Begin FreeBSD
+ atf_set "require.files" /usr/share/dict/words
+ # End FreeBSD
}
medium_hash_body()
{
@@ -731,6 +742,9 @@ small_page_btree_head()
"reverses them, and gives them each a small size data" \
"entry. Uses a small page size to make sure the btree" \
"split code gets hammered."
+ # Begin FreeBSD
+ atf_set "require.files" /usr/share/dict/words
+ # End FreeBSD
}
small_page_btree_body()
{
@@ -784,6 +798,9 @@ atf_test_case byte_orders_btree
byte_orders_btree_head()
{
atf_set "descr" "Checks btree database using differing byte orders"
+ # Begin FreeBSD
+ atf_set "require.files" /usr/share/dict/words
+ # End FreeBSD
}
byte_orders_btree_body()
{
@@ -816,6 +833,9 @@ bsize_ffactor_head()
atf_set "timeout" "480"
atf_set "descr" "Checks hash database with various" \
"bucketsizes and fill factors"
+ # Begin FreeBSD
+ atf_set "require.files" /usr/share/dict/words
+ # End FreeBSD
}
bsize_ffactor_body()
{
diff --git a/contrib/netbsd-tests/lib/libc/string/t_memcpy.c b/contrib/netbsd-tests/lib/libc/string/t_memcpy.c
index 192a4e8..5bbd924 100644
--- a/contrib/netbsd-tests/lib/libc/string/t_memcpy.c
+++ b/contrib/netbsd-tests/lib/libc/string/t_memcpy.c
@@ -54,7 +54,7 @@ char result[100];
#ifdef __NetBSD__
const char goodResult[] = "7b405d24bc03195474c70ddae9e1f8fb";
#else
-const char goodResult[] = "217b4fbe456916bf62a2f85df752e4ab";
+const char goodResult[] = "5ab4443f0e3e058d94087d9f2a11ef5e";
#endif
static void
@@ -108,7 +108,12 @@ ATF_TC_BODY(memcpy_basic, tc)
if (i != j)
runTest(start[i], start[j]);
MD5End(mc, result);
+#ifdef __NetBSD__
ATF_REQUIRE_EQ(strcmp(result, goodResult), 0);
+#else
+ ATF_REQUIRE_EQ_MSG(strcmp(result, goodResult), 0, "%s != %s",
+ result, goodResult);
+#endif
}
ATF_TC(memccpy_simple);
diff --git a/contrib/tcpdump/addrtoname.c b/contrib/tcpdump/addrtoname.c
index e224606..2befeae 100644
--- a/contrib/tcpdump/addrtoname.c
+++ b/contrib/tcpdump/addrtoname.c
@@ -29,10 +29,10 @@
#include "config.h"
#endif
-#ifdef HAVE_CAPSPER
+#ifdef HAVE_CASPER
#include <libcasper.h>
#include <casper/cap_dns.h>
-#endif /* HAVE_CAPSPER */
+#endif /* HAVE_CASPER */
#include <tcpdump-stdinc.h>
#ifdef USE_ETHER_NTOHOST
@@ -204,7 +204,7 @@ intoa(uint32_t addr)
static uint32_t f_netmask;
static uint32_t f_localnet;
-#ifdef HAVE_CAPSPER
+#ifdef HAVE_CASPER
extern cap_channel_t *capdns;
#endif
@@ -252,7 +252,7 @@ getname(netdissect_options *ndo, const u_char *ap)
*/
if (!ndo->ndo_nflag &&
(addr & f_netmask) == f_localnet) {
-#ifdef HAVE_CAPSPER
+#ifdef HAVE_CASPER
if (capdns != NULL) {
hp = cap_gethostbyaddr(capdns, (char *)&addr, 4,
AF_INET);
@@ -309,7 +309,7 @@ getname6(netdissect_options *ndo, const u_char *ap)
* Do not print names if -n was given.
*/
if (!ndo->ndo_nflag) {
-#ifdef HAVE_CAPSPER
+#ifdef HAVE_CASPER
if (capdns != NULL) {
hp = cap_gethostbyaddr(capdns, (char *)&addr,
sizeof(addr), AF_INET6);
diff --git a/contrib/tcpdump/config.h.in b/contrib/tcpdump/config.h.in
index f233245..c289f00 100644
--- a/contrib/tcpdump/config.h.in
+++ b/contrib/tcpdump/config.h.in
@@ -10,7 +10,7 @@
#undef HAVE_BPF_DUMP
/* capsicum support available */
-#undef HAVE_CAPSPER
+#undef HAVE_CASPER
/* Define to 1 if you have the `cap_enter' function. */
#undef HAVE_CAP_ENTER
diff --git a/contrib/tcpdump/configure b/contrib/tcpdump/configure
index 390af31..d10f2ac 100755
--- a/contrib/tcpdump/configure
+++ b/contrib/tcpdump/configure
@@ -4566,7 +4566,7 @@ fi
$as_echo_n "checking whether to sandbox using capsicum... " >&6; }
if test "x$ac_lbl_capsicum_function_seen" = "xyes" -a "x$ac_lbl_capsicum_function_not_seen" != "xyes"; then
-$as_echo "#define HAVE_CAPSPER 1" >>confdefs.h
+$as_echo "#define HAVE_CASPER 1" >>confdefs.h
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
$as_echo "yes" >&6; }
diff --git a/contrib/tcpdump/tcpdump.c b/contrib/tcpdump/tcpdump.c
index ce88d59..0939896 100644
--- a/contrib/tcpdump/tcpdump.c
+++ b/contrib/tcpdump/tcpdump.c
@@ -86,8 +86,9 @@ extern int SIZE_BUF;
#ifdef __FreeBSD__
#include <sys/capsicum.h>
#include <sys/sysctl.h>
+#include <libgen.h>
#endif /* __FreeBSD__ */
-#ifdef HAVE_CAPSPER
+#ifdef HAVE_CASPER
#include <libcasper.h>
#include <casper/cap_dns.h>
#include <sys/nv.h>
@@ -95,8 +96,7 @@ extern int SIZE_BUF;
#include <sys/ioccom.h>
#include <net/bpf.h>
#include <fcntl.h>
-#include <libgen.h>
-#endif /* HAVE_CAPSPER */
+#endif /* HAVE_CASPER */
#include <pcap.h>
#include <signal.h>
#include <stdio.h>
@@ -160,7 +160,7 @@ static int infoprint;
char *program_name;
-#ifdef HAVE_CAPSPER
+#ifdef HAVE_CASPER
cap_channel_t *capdns;
#endif
@@ -487,7 +487,7 @@ struct dump_info {
char *CurrentFileName;
pcap_t *pd;
pcap_dumper_t *p;
-#ifdef HAVE_CAPSPER
+#ifdef __FreeBSD__
int dirfd;
#endif
};
@@ -911,7 +911,7 @@ get_next_file(FILE *VFile, char *ptr)
return ret;
}
-#ifdef HAVE_CAPSPER
+#ifdef HAVE_CASPER
static cap_channel_t *
capdns_setup(void)
{
@@ -938,7 +938,7 @@ capdns_setup(void)
return (capdnsloc);
}
-#endif /* HAVE_CAPSPER */
+#endif /* HAVE_CASPER */
#ifdef HAVE_PCAP_SET_TSTAMP_PRECISION
static int
@@ -970,7 +970,7 @@ tstamp_precision_to_string(int precision)
}
#endif
-#ifdef HAVE_CAPSPER
+#ifdef __FreeBSD__
/*
* Ensure that, on a dump file's descriptor, we have all the rights
* necessary to make the standard I/O library work with an fdopen()ed
@@ -1070,9 +1070,9 @@ main(int argc, char **argv)
#endif
int status;
FILE *VFile;
-#ifdef HAVE_CAPSPER
+#ifdef __FreeBSD__
cap_rights_t rights;
-#endif /* HAVE_CAPSPER */
+#endif /* !__FreeBSD__ */
int cansandbox;
#ifdef WIN32
@@ -1613,7 +1613,7 @@ main(int argc, char **argv)
if (pd == NULL)
error("%s", ebuf);
-#ifdef HAVE_CAPSPER
+#ifdef HAVE_CASPER
cap_rights_init(&rights, CAP_READ);
if (cap_rights_limit(fileno(pcap_file(pd)), &rights) < 0 &&
errno != ENOSYS) {
@@ -1850,10 +1850,10 @@ main(int argc, char **argv)
exit(0);
}
-#ifdef HAVE_CAPSPER
+#ifdef HAVE_CASPER
if (!nflag)
capdns = capdns_setup();
-#endif /* HAVE_CAPSPER */
+#endif /* HAVE_CASPER */
init_addrtoname(gndo, localnet, netmask);
init_checksum();
@@ -1921,7 +1921,7 @@ main(int argc, char **argv)
if (pcap_setfilter(pd, &fcode) < 0)
error("%s", pcap_geterr(pd));
-#ifdef HAVE_CAPSPER
+#ifdef HAVE_CASPER
if (RFileName == NULL && VFileName == NULL) {
static const unsigned long cmds[] = { BIOCGSTATS };
@@ -1971,11 +1971,11 @@ main(int argc, char **argv)
#endif /* HAVE_LIBCAP_NG */
if (p == NULL)
error("%s", pcap_geterr(pd));
-#ifdef HAVE_CAPSPER
+#ifdef __FreeBSD__
set_dumper_capsicum_rights(p);
#endif
if (Cflag != 0 || Gflag != 0) {
-#ifdef HAVE_CAPSPER
+#ifdef __FreeBSD__
dumpinfo.WFileName = strdup(basename(WFileName));
dumpinfo.dirfd = open(dirname(WFileName),
O_DIRECTORY | O_RDONLY);
@@ -1993,7 +1993,7 @@ main(int argc, char **argv)
errno != ENOSYS) {
error("unable to limit dump descriptor fcntls");
}
-#else /* !HAVE_CAPSPER */
+#else /* !__FreeBSD__ */
dumpinfo.WFileName = WFileName;
#endif
callback = dump_packet_and_trunc;
@@ -2069,7 +2069,7 @@ main(int argc, char **argv)
#ifdef __FreeBSD__
cansandbox = (VFileName == NULL && zflag == NULL);
-#ifdef HAVE_CAPSPER
+#ifdef HAVE_CASPER
cansandbox = (cansandbox && (nflag || capdns != NULL));
#else
cansandbox = (cansandbox && nflag);
@@ -2125,7 +2125,7 @@ main(int argc, char **argv)
pd = pcap_open_offline(RFileName, ebuf);
if (pd == NULL)
error("%s", ebuf);
-#ifdef HAVE_CAPSPER
+#ifdef HAVE_CASPER
cap_rights_init(&rights, CAP_READ);
if (cap_rights_limit(fileno(pcap_file(pd)),
&rights) < 0 && errno != ENOSYS) {
@@ -2328,7 +2328,7 @@ dump_packet_and_trunc(u_char *user, const struct pcap_pkthdr *h, const u_char *s
/* If the time is greater than the specified window, rotate */
if (t - Gflag_time >= Gflag) {
-#ifdef HAVE_CAPSPER
+#ifdef __FreeBSD__
FILE *fp;
int fd;
#endif
@@ -2386,7 +2386,7 @@ dump_packet_and_trunc(u_char *user, const struct pcap_pkthdr *h, const u_char *s
capng_update(CAPNG_ADD, CAPNG_EFFECTIVE, CAP_DAC_OVERRIDE);
capng_apply(CAPNG_SELECT_BOTH);
#endif /* HAVE_LIBCAP_NG */
-#ifdef HAVE_CAPSPER
+#ifdef __FreeBSD__
fd = openat(dump_info->dirfd,
dump_info->CurrentFileName,
O_CREAT | O_WRONLY | O_TRUNC, 0644);
@@ -2400,7 +2400,7 @@ dump_packet_and_trunc(u_char *user, const struct pcap_pkthdr *h, const u_char *s
dump_info->CurrentFileName);
}
dump_info->p = pcap_dump_fopen(dump_info->pd, fp);
-#else /* !HAVE_CAPSPER */
+#else /* !__FreeBSD__ */
dump_info->p = pcap_dump_open(dump_info->pd, dump_info->CurrentFileName);
#endif
#ifdef HAVE_LIBCAP_NG
@@ -2409,7 +2409,7 @@ dump_packet_and_trunc(u_char *user, const struct pcap_pkthdr *h, const u_char *s
#endif /* HAVE_LIBCAP_NG */
if (dump_info->p == NULL)
error("%s", pcap_geterr(pd));
-#ifdef HAVE_CAPSPER
+#ifdef __FreeBSD__
set_dumper_capsicum_rights(dump_info->p);
#endif
}
@@ -2426,7 +2426,7 @@ dump_packet_and_trunc(u_char *user, const struct pcap_pkthdr *h, const u_char *s
if (size == -1)
error("ftell fails on output file");
if (size > Cflag) {
-#ifdef HAVE_CAPSPER
+#ifdef __FreeBSD__
FILE *fp;
int fd;
#endif
@@ -2458,7 +2458,7 @@ dump_packet_and_trunc(u_char *user, const struct pcap_pkthdr *h, const u_char *s
capng_update(CAPNG_ADD, CAPNG_EFFECTIVE, CAP_DAC_OVERRIDE);
capng_apply(CAPNG_SELECT_BOTH);
#endif /* HAVE_LIBCAP_NG */
-#ifdef HAVE_CAPSPER
+#ifdef __FreeBSD__
fd = openat(dump_info->dirfd, dump_info->CurrentFileName,
O_CREAT | O_WRONLY | O_TRUNC, 0644);
if (fd < 0) {
@@ -2471,7 +2471,7 @@ dump_packet_and_trunc(u_char *user, const struct pcap_pkthdr *h, const u_char *s
dump_info->CurrentFileName);
}
dump_info->p = pcap_dump_fopen(dump_info->pd, fp);
-#else /* !HAVE_CAPSPER */
+#else /* !__FreeBSD__ */
dump_info->p = pcap_dump_open(dump_info->pd, dump_info->CurrentFileName);
#endif
#ifdef HAVE_LIBCAP_NG
@@ -2480,7 +2480,7 @@ dump_packet_and_trunc(u_char *user, const struct pcap_pkthdr *h, const u_char *s
#endif /* HAVE_LIBCAP_NG */
if (dump_info->p == NULL)
error("%s", pcap_geterr(pd));
-#ifdef HAVE_CAPSPER
+#ifdef __FreeBSD__
set_dumper_capsicum_rights(dump_info->p);
#endif
}
OpenPOWER on IntegriCloud