Imported Upstream version 4.9.3 05/215305/1 upstream upstream/4.9.3
authorSeonah Moon <seonah1.moon@samsung.com>
Mon, 7 Oct 2019 01:58:05 +0000 (10:58 +0900)
committerSeonah Moon <seonah1.moon@samsung.com>
Mon, 7 Oct 2019 01:58:18 +0000 (10:58 +0900)
Change-Id: I3cc0d412048588389bb26e10136fe244bd6b09ed

207 files changed:
CHANGES
CONTRIBUTING
INSTALL.txt
Makefile-devel-adds
Makefile.in
Readme.Win32
VERSION
addrtoname.c
config.guess [changed mode: 0644->0755]
config.h.in
config.sub [changed mode: 0644->0755]
configure
configure.ac [moved from configure.in with 97% similarity]
netdissect.h
print-802_11.c
print-aoe.c
print-babel.c
print-bfd.c
print-bgp.c
print-bootp.c
print-dccp.c
print-decnet.c
print-domain.c
print-dvmrp.c
print-eigrp.c
print-esp.c
print-fr.c
print-hncp.c
print-icmp.c
print-icmp6.c
print-ipnet.c
print-isakmp.c
print-juniper.c
print-l2tp.c
print-ldp.c
print-lmp.c
print-nfs.c
print-openflow.c
print-ospf.c
print-ospf6.c
print-ppi.c
print-rsvp.c
print-rx.c
print-sflow.c
print-sl.c
print-sll.c
print-smb.c
print-tcp.c
print-vrrp.c
print-vtp.c
print-wb.c
signature.c
smbutil.c
tcpdump.1.in
tcpdump.c
tests/SMBLIST [new file with mode: 0644]
tests/TESTLIST
tests/TESTonce
tests/TESTrun.sh
tests/aoe-oobr-1.out [new file with mode: 0644]
tests/aoe-oobr-1.pcap [new file with mode: 0644]
tests/arp-too-long-tha.pcap
tests/babel_update_oobr.out [new file with mode: 0644]
tests/babel_update_oobr.pcap [new file with mode: 0644]
tests/bgp-bgp_capabilities_print-oobr-1.out [new file with mode: 0644]
tests/bgp-bgp_capabilities_print-oobr-1.pcap [new file with mode: 0644]
tests/bgp-bgp_capabilities_print-oobr-2.out [new file with mode: 0644]
tests/bgp-bgp_capabilities_print-oobr-2.pcap [new file with mode: 0644]
tests/bgp_mp_reach_nlri-oobr.out [new file with mode: 0644]
tests/bgp_mp_reach_nlri-oobr.pcap [new file with mode: 0644]
tests/crypto.sh
tests/cve-2018-10105-segv-sflowprint.out [new file with mode: 0644]
tests/cve-2018-10105-segv-sflowprint.pcapng [new file with mode: 0644]
tests/cve-2018-10105_smbprint-readofsize1.out [new file with mode: 0644]
tests/cve-2018-10105_smbprint-readofsize1.pcap [new file with mode: 0644]
tests/cve-2018-10105_smbutil_withoutasan.out [new file with mode: 0644]
tests/cve-2018-10105_smbutil_withoutasan.pcap [new file with mode: 0644]
tests/cve2015-0261-ipv6.out
tests/cve2015-0261-ipv6.out.stderr [new file with mode: 0644]
tests/dccp_options-oobr.out [new file with mode: 0644]
tests/dccp_options-oobr.pcap [new file with mode: 0644]
tests/dns-zlip-1.out
tests/dns-zlip-2.out
tests/dns-zlip-3.out
tests/eapon2.out [new file with mode: 0644]
tests/eapon2.pcap [new file with mode: 0644]
tests/esp4.out [new file with mode: 0644]
tests/frf16_magic_ie-oobr.out [new file with mode: 0644]
tests/frf16_magic_ie-oobr.pcap [new file with mode: 0644]
tests/hncp_prefix-oobr.out [new file with mode: 0644]
tests/hncp_prefix-oobr.pcapng [new file with mode: 0644]
tests/icmp-icmp_print-oobr-1.out [new file with mode: 0644]
tests/icmp-icmp_print-oobr-1.pcap [new file with mode: 0644]
tests/icmp-icmp_print-oobr-2.out [new file with mode: 0644]
tests/icmp-icmp_print-oobr-2.pcap [new file with mode: 0644]
tests/icmp6_mobileprefix_asan.out
tests/icmp6_nodeinfo_oobr.out
tests/icmpv6.out
tests/icmpv6_opt24-v.out
tests/ieee802.11_meshhdr-oobr.out [new file with mode: 0644]
tests/ieee802.11_meshhdr-oobr.pcap [new file with mode: 0644]
tests/isakmp-ikev1_n_print-oobr.out [new file with mode: 0644]
tests/isakmp-ikev1_n_print-oobr.pcap [new file with mode: 0644]
tests/isis-seg-fault-1-v.sh
tests/juniper_header-heapoverflow.pcap
tests/kday1.out
tests/kday1.out.stderr [new file with mode: 0644]
tests/kday2.out
tests/kday2.out.stderr [new file with mode: 0644]
tests/kday3.out
tests/kday3.out.stderr [new file with mode: 0644]
tests/kday4.out
tests/kday4.out.stderr [new file with mode: 0644]
tests/kday5.out
tests/kday5.out.stderr [new file with mode: 0644]
tests/kday6.out
tests/kday6.out.stderr [new file with mode: 0644]
tests/kday7.out
tests/kday7.out.stderr [new file with mode: 0644]
tests/kday8.out
tests/kday8.out.stderr [new file with mode: 0644]
tests/kh-addrfail-001.out [new file with mode: 0644]
tests/kh-addrfail-001.out.stderr [new file with mode: 0644]
tests/kh-addrfail-001.pcap [new file with mode: 0644]
tests/kh-addrfail-002.out [new file with mode: 0644]
tests/kh-addrfail-002.out.stderr [new file with mode: 0644]
tests/kh-addrfail-002.pcap [new file with mode: 0644]
tests/kh-addrfail-003.out [new file with mode: 0644]
tests/kh-addrfail-003.out.stderr [new file with mode: 0644]
tests/kh-addrfail-003.pcap [new file with mode: 0644]
tests/kh-addrfail-004.out [new file with mode: 0644]
tests/kh-addrfail-004.out.stderr [new file with mode: 0644]
tests/kh-addrfail-004.pcap [new file with mode: 0644]
tests/kh-addrfail-005.out [new file with mode: 0644]
tests/kh-addrfail-005.out.stderr [new file with mode: 0644]
tests/kh-addrfail-005.pcap [new file with mode: 0644]
tests/kh-addrfail-006.out [new file with mode: 0644]
tests/kh-addrfail-006.out.stderr [new file with mode: 0644]
tests/kh-addrfail-006.pcap [new file with mode: 0644]
tests/kh-addrfail-007.out [new file with mode: 0644]
tests/kh-addrfail-007.out.stderr [new file with mode: 0644]
tests/kh-addrfail-007.pcap [new file with mode: 0644]
tests/kh-addrfail-008.out [new file with mode: 0644]
tests/kh-addrfail-008.out.stderr [new file with mode: 0644]
tests/kh-addrfail-008.pcap [new file with mode: 0644]
tests/kh-addrfail-009.out [new file with mode: 0644]
tests/kh-addrfail-009.out.stderr [new file with mode: 0644]
tests/kh-addrfail-009.pcap [new file with mode: 0644]
tests/kh-addrfail-010.out [new file with mode: 0644]
tests/kh-addrfail-010.out.stderr [new file with mode: 0644]
tests/kh-addrfail-010.pcap [new file with mode: 0644]
tests/kh-addrfail-011.out [new file with mode: 0644]
tests/kh-addrfail-011.out.stderr [new file with mode: 0644]
tests/kh-addrfail-011.pcap [new file with mode: 0644]
tests/kh-tcpdump-001.out [new file with mode: 0644]
tests/kh-tcpdump-001.pcap [new file with mode: 0644]
tests/kh-tcpdump-002.out [new file with mode: 0644]
tests/kh-tcpdump-002.pcap [new file with mode: 0644]
tests/kh-tcpdump-004.pcap [new file with mode: 0644]
tests/l2tp-avp-overflow.out
tests/l2tp-avp-overflow.out.stderr [new file with mode: 0644]
tests/ldp-ldp_tlv_print-oobr.out [new file with mode: 0644]
tests/ldp-ldp_tlv_print-oobr.pcap [new file with mode: 0644]
tests/lmp-lmp_print_data_link_subobjs-oobr.out [new file with mode: 0644]
tests/lmp-lmp_print_data_link_subobjs-oobr.pcap [new file with mode: 0644]
tests/lmp-v.sh
tests/lmpv1_busyloop.out
tests/nflog-e.sh
tests/of10_7050sx_bsn-oobr.out [new file with mode: 0644]
tests/of10_7050sx_bsn-oobr.pcap [new file with mode: 0644]
tests/ospf6_print_lshdr-oobr.out [new file with mode: 0644]
tests/ospf6_print_lshdr-oobr.pcapng [new file with mode: 0644]
tests/pcap-invalid-version-1.out
tests/pcap-invalid-version-1.out.stderr [new file with mode: 0644]
tests/pcap-invalid-version-2.out
tests/pcap-invalid-version-2.out.stderr [new file with mode: 0644]
tests/pcap-ng-invalid-vers-1.out [deleted file]
tests/pcap-ng-invalid-vers-2.out [deleted file]
tests/pcapng-invalid-vers-1.out [new file with mode: 0644]
tests/pcapng-invalid-vers-1.out.stderr [new file with mode: 0644]
tests/pcapng-invalid-vers-1.pcapng [moved from tests/pcap-ng-invalid-vers-1.pcap with 100% similarity]
tests/pcapng-invalid-vers-2.out [new file with mode: 0644]
tests/pcapng-invalid-vers-2.out.stderr [new file with mode: 0644]
tests/pcapng-invalid-vers-2.pcapng [moved from tests/pcap-ng-invalid-vers-2.pcap with 100% similarity]
tests/pktap-heap-overflow.out
tests/pktap-heap-overflow.out.stderr [new file with mode: 0644]
tests/relts-0x80000000.pcap
tests/rpl-19-pickdag.out
tests/rpl-19-pickdagvvv.out
tests/rpl-dao-oobr.out [new file with mode: 0644]
tests/rpl-dao-oobr.pcapng [new file with mode: 0644]
tests/rsvp-rsvp_obj_print-oobr.out [new file with mode: 0644]
tests/rsvp-rsvp_obj_print-oobr.pcap [new file with mode: 0644]
tests/rx_serviceid_oobr.out [new file with mode: 0644]
tests/rx_serviceid_oobr.pcap [new file with mode: 0644]
tests/smb.sh [new file with mode: 0644]
tests/smb_print_trans-oobr1.out [new file with mode: 0644]
tests/smb_print_trans-oobr1.pcapng [new file with mode: 0644]
tests/smb_print_trans-oobr2.out [new file with mode: 0644]
tests/smb_print_trans-oobr2.pcap [new file with mode: 0644]
tests/stp-v4-length-sigsegv.pcap
tests/tftp-heapoverflow.pcap
tests/vrrp-vrrp_print-oobr-2.out [new file with mode: 0644]
tests/vrrp-vrrp_print-oobr-2.pcap [new file with mode: 0644]
tests/vrrp-vrrp_print-oobr.out [new file with mode: 0644]
tests/vrrp-vrrp_print-oobr.pcap [new file with mode: 0644]
util-print.c

diff --git a/CHANGES b/CHANGES
index 09acbb2..f09be34 100644 (file)
--- a/CHANGES
+++ b/CHANGES
@@ -1,3 +1,36 @@
+Friday, September 20, 2019, by mcr@sandelman.ca
+  A huge thank you to Denis, Francois-Xavier and Guy who did much of the heavy lifting.
+  Summary for 4.9.3 tcpdump release
+    Fix buffer overflow/overread vulnerabilities:
+      CVE-2017-16808 (AoE)
+      CVE-2018-14468 (FrameRelay)
+      CVE-2018-14469 (IKEv1)
+      CVE-2018-14470 (BABEL)
+      CVE-2018-14466 (AFS/RX)
+      CVE-2018-14461 (LDP)
+      CVE-2018-14462 (ICMP)
+      CVE-2018-14465 (RSVP)
+      CVE-2018-14881 (BGP)
+      CVE-2018-14464 (LMP)
+      CVE-2018-14463 (VRRP)
+      CVE-2018-14467 (BGP)
+      CVE-2018-10103 (SMB - partially fixed, but SMB printing disabled)
+      CVE-2018-10105 (SMB - too unreliably reproduced, SMB printing disabled)
+      CVE-2018-14880 (OSPF6)
+      CVE-2018-16451 (SMB)
+      CVE-2018-14882 (RPL)
+      CVE-2018-16227 (802.11)
+      CVE-2018-16229 (DCCP)
+      CVE-2018-16301 (was fixed in libpcap)
+      CVE-2018-16230 (BGP)
+      CVE-2018-16452 (SMB)
+      CVE-2018-16300 (BGP)
+      CVE-2018-16228 (HNCP)
+      CVE-2019-15166 (LMP)
+      CVE-2019-15167 (VRRP)
+    Fix for cmdline argument/local issues:
+      CVE-2018-14879 (tcpdump -V)
+
 Sunday September 3, 2017 denis@ovsienko.info
   Summary for 4.9.2 tcpdump release
     Do not use getprotobynumber() for protocol name resolution.  Do not do
index 186583e..5746290 100644 (file)
@@ -31,7 +31,7 @@ Please note that if you know exactly how to solve the problem and the solution
 would not be too intrusive, it would be best to contribute some development time
 and open a pull request instead as discussed below.
 
-Still not sure how to do? Feel free to [subscribe](http://www.tcpdump.org/#mailing-lists)
+Still not sure how to do? Feel free to [subscribe](https://www.tcpdump.org/#mailing-lists)
 to the mailing list tcpdump-workers@lists.tcpdump.org and ask!
 
 
index 57d4a45..c8a8eb7 100644 (file)
@@ -63,7 +63,7 @@ config.guess  - autoconf support
 config.h.in    - autoconf input
 config.sub     - autoconf support
 configure      - configure script (run this first)
-configure.in   - configure script source
+configure.ac   - configure script source
 ether.h                - Ethernet definitions
 ethertype.h    - Ethernet type value definitions
 extract.h      - alignment definitions
index 7bf6420..fea63bb 100644 (file)
@@ -2,12 +2,12 @@
 # Auto-regenerate configure script or Makefile when things change.
 # From autoconf.info .  Works best with GNU Make.
 #
-${srcdir}/configure: configure.in aclocal.m4
+${srcdir}/configure: configure.ac aclocal.m4
        cd ${srcdir} && autoconf
 
 # autoheader might not change config.h.in, so touch a stamp file.
 ${srcdir}/config.h.in: ${srcdir}/stamp-h.in
-${srcdir}/stamp-h.in: configure.in aclocal.m4
+${srcdir}/stamp-h.in: configure.ac aclocal.m4
        cd ${srcdir} && autoheader
        echo timestamp > ${srcdir}/stamp-h.in
 
index 0941f0e..3b58918 100644 (file)
@@ -334,7 +334,7 @@ EXTRA_DIST = \
        config.h.in \
        config.sub \
        configure \
-       configure.in \
+       configure.ac \
        install-sh \
        lbl/os-osf4.h \
        lbl/os-solaris2.h \
@@ -366,7 +366,7 @@ EXTRA_DIST = \
        win32/prj/WinDump.vcproj \
        win32/src/ether_ntohost.c
 
-TEST_DIST= `find tests \( -name 'DIFF' -prune \) -o \( -name NEW -prune \) -o -type f \! -name '.*' \! -name '*~' -print`
+TEST_DIST= `git ls-files tests | grep -v 'tests/\..*'`
 
 all: $(PROG) $(LIBNETDISSECT)
 
@@ -438,7 +438,7 @@ distclean:
        rm -rf autom4te.cache tests/DIFF tests/NEW
 
 check: tcpdump
-       (cd tests && ./TESTrun.sh)
+       (mkdir -p tests && SRCDIR=`cd ${srcdir}; pwd` && export SRCDIR && $$SRCDIR/tests/TESTrun.sh )
 
 extags: $(TAGFILES)
        ctags $(TAGFILES)
index fdf8b12..c3d7c41 100644 (file)
@@ -7,7 +7,7 @@ Software Development Kit (SDK), that contains some necessary includes
 for IPv6 support. You can download it from http://www.microsoft.com/sdk
 - the WinPcap source code, that includes libpcap for win32. Download it
 from http://winpcap.polito.it or download libpcap sources from
-http://www.tcpdump.org and follow the instructions in the README.Win32
+https://www.tcpdump.org and follow the instructions in the README.Win32
 file.
 
 First, extract tcpdump and WinPcap in the same folder, and build WinPcap.
diff --git a/VERSION b/VERSION
index dad10c7..c01c413 100644 (file)
--- a/VERSION
+++ b/VERSION
@@ -1 +1 @@
-4.9.2
+4.9.3
index df7c2ce..15e5741 100644 (file)
@@ -120,7 +120,7 @@ win32_gethostbyaddr(const char *addr, int len, int type)
                    hname, sizeof(hname), NULL, 0, 0)) {
                        return NULL;
                } else {
-                       strcpy(host.h_name, hname);
+                       strlcpy(host.h_name, hname, NI_MAXHOST);
                        return &host;
                }
                break;
@@ -1226,10 +1226,7 @@ dnaddr_string(netdissect_options *ndo, u_short dnaddr)
 
        tp->addr = dnaddr;
        tp->nxt = newhnamemem(ndo);
-       if (ndo->ndo_nflag)
-               tp->name = dnnum_string(ndo, dnaddr);
-       else
-               tp->name = dnname_string(ndo, dnaddr);
+       tp->name = dnnum_string(ndo, dnaddr);
 
        return(tp->name);
 }
old mode 100644 (file)
new mode 100755 (executable)
index 44290b8..2b79f6d
@@ -1,8 +1,8 @@
 #! /bin/sh
 # Attempt to guess a canonical system name.
-#   Copyright 1992-2015 Free Software Foundation, Inc.
+#   Copyright 1992-2018 Free Software Foundation, Inc.
 
-timestamp='2015-02-23'
+timestamp='2018-07-06'
 
 # This file is free software; you can redistribute it and/or modify it
 # under the terms of the GNU General Public License as published by
@@ -15,7 +15,7 @@ timestamp='2015-02-23'
 # General Public License for more details.
 #
 # You should have received a copy of the GNU General Public License
-# along with this program; if not, see <http://www.gnu.org/licenses/>.
+# along with this program; if not, see <https://www.gnu.org/licenses/>.
 #
 # As a special exception to the GNU General Public License, if you
 # distribute this file as part of a program that contains a
@@ -27,7 +27,7 @@ timestamp='2015-02-23'
 # Originally written by Per Bothner; maintained since 2000 by Ben Elliston.
 #
 # You can get the latest version of this script from:
-# http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD
+# https://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess
 #
 # Please send patches to <config-patches@gnu.org>.
 
@@ -39,7 +39,7 @@ Usage: $0 [OPTION]
 
 Output the configuration name of the system \`$me' is run on.
 
-Operation modes:
+Options:
   -h, --help         print this help, then exit
   -t, --time-stamp   print date of last modification, then exit
   -v, --version      print version number, then exit
@@ -50,7 +50,7 @@ version="\
 GNU config.guess ($timestamp)
 
 Originally written by Per Bothner.
-Copyright 1992-2015 Free Software Foundation, Inc.
+Copyright 1992-2018 Free Software Foundation, Inc.
 
 This is free software; see the source for copying conditions.  There is NO
 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
@@ -101,15 +101,15 @@ trap "exitcode=\$?; (rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null) && e
 trap "rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null; exit 1" 1 2 13 15 ;
 : ${TMPDIR=/tmp} ;
  { tmp=`(umask 077 && mktemp -d "$TMPDIR/cgXXXXXX") 2>/dev/null` && test -n "$tmp" && test -d "$tmp" ; } ||
- { test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir $tmp) ; } ||
- { tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir $tmp) && echo "Warning: creating insecure temp directory" >&2 ; } ||
+ { test -n "$RANDOM" && tmp=$TMPDIR/cg$$-$RANDOM && (umask 077 && mkdir $tmp 2>/dev/null) ; } ||
+ { tmp=$TMPDIR/cg-$$ && (umask 077 && mkdir $tmp 2>/dev/null) && echo "Warning: creating insecure temp directory" >&2 ; } ||
  { echo "$me: cannot create a temporary directory in $TMPDIR" >&2 ; exit 1 ; } ;
 dummy=$tmp/dummy ;
 tmpfiles="$dummy.c $dummy.o $dummy.rel $dummy" ;
-case $CC_FOR_BUILD,$HOST_CC,$CC in
- ,,)    echo "int x;" > $dummy.c ;
+case ${CC_FOR_BUILD-},${HOST_CC-},${CC-} in
+ ,,)    echo "int x;" > "$dummy.c" ;
        for c in cc gcc c89 c99 ; do
-         if ($c -c -o $dummy.o $dummy.c) >/dev/null 2>&1 ; then
+         if ($c -c -o "$dummy.o" "$dummy.c") >/dev/null 2>&1 ; then
             CC_FOR_BUILD="$c"; break ;
          fi ;
        done ;
@@ -132,14 +132,14 @@ UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown
 UNAME_SYSTEM=`(uname -s) 2>/dev/null`  || UNAME_SYSTEM=unknown
 UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown
 
-case "${UNAME_SYSTEM}" in
+case "$UNAME_SYSTEM" in
 Linux|GNU|GNU/*)
        # If the system lacks a compiler, then just pick glibc.
        # We could probably try harder.
        LIBC=gnu
 
-       eval $set_cc_for_build
-       cat <<-EOF > $dummy.c
+       eval "$set_cc_for_build"
+       cat <<-EOF > "$dummy.c"
        #include <features.h>
        #if defined(__UCLIBC__)
        LIBC=uclibc
@@ -149,13 +149,20 @@ Linux|GNU|GNU/*)
        LIBC=gnu
        #endif
        EOF
-       eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^LIBC' | sed 's, ,,g'`
+       eval "`$CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^LIBC' | sed 's, ,,g'`"
+
+       # If ldd exists, use it to detect musl libc.
+       if command -v ldd >/dev/null && \
+               ldd --version 2>&1 | grep -q ^musl
+       then
+           LIBC=musl
+       fi
        ;;
 esac
 
 # Note: order is significant - the case branches are not exclusive.
 
-case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
+case "$UNAME_MACHINE:$UNAME_SYSTEM:$UNAME_RELEASE:$UNAME_VERSION" in
     *:NetBSD:*:*)
        # NetBSD (nbsd) targets should (where applicable) match one or
        # more of the tuples: *-*-netbsdelf*, *-*-netbsdaout*,
@@ -169,27 +176,30 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
        # portion of the name.  We always set it to "unknown".
        sysctl="sysctl -n hw.machine_arch"
        UNAME_MACHINE_ARCH=`(uname -p 2>/dev/null || \
-           /sbin/$sysctl 2>/dev/null || \
-           /usr/sbin/$sysctl 2>/dev/null || \
+           "/sbin/$sysctl" 2>/dev/null || \
+           "/usr/sbin/$sysctl" 2>/dev/null || \
            echo unknown)`
-       case "${UNAME_MACHINE_ARCH}" in
+       case "$UNAME_MACHINE_ARCH" in
            armeb) machine=armeb-unknown ;;
            arm*) machine=arm-unknown ;;
            sh3el) machine=shl-unknown ;;
            sh3eb) machine=sh-unknown ;;
            sh5el) machine=sh5le-unknown ;;
            earmv*)
-               arch=`echo ${UNAME_MACHINE_ARCH} | sed -e 's,^e\(armv[0-9]\).*$,\1,'`
-               endian=`echo ${UNAME_MACHINE_ARCH} | sed -ne 's,^.*\(eb\)$,\1,p'`
-               machine=${arch}${endian}-unknown
+               arch=`echo "$UNAME_MACHINE_ARCH" | sed -e 's,^e\(armv[0-9]\).*$,\1,'`
+               endian=`echo "$UNAME_MACHINE_ARCH" | sed -ne 's,^.*\(eb\)$,\1,p'`
+               machine="${arch}${endian}"-unknown
                ;;
-           *) machine=${UNAME_MACHINE_ARCH}-unknown ;;
+           *) machine="$UNAME_MACHINE_ARCH"-unknown ;;
        esac
        # The Operating System including object format, if it has switched
-       # to ELF recently, or will in the future.
-       case "${UNAME_MACHINE_ARCH}" in
-           arm*|earm*|i386|m68k|ns32k|sh3*|sparc|vax)
-               eval $set_cc_for_build
+       # to ELF recently (or will in the future) and ABI.
+       case "$UNAME_MACHINE_ARCH" in
+           earm*)
+               os=netbsdelf
+               ;;
+           arm*|i386|m68k|ns32k|sh3*|sparc|vax)
+               eval "$set_cc_for_build"
                if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \
                        | grep -q __ELF__
                then
@@ -205,10 +215,10 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
                ;;
        esac
        # Determine ABI tags.
-       case "${UNAME_MACHINE_ARCH}" in
+       case "$UNAME_MACHINE_ARCH" in
            earm*)
                expr='s/^earmv[0-9]/-eabi/;s/eb$//'
-               abi=`echo ${UNAME_MACHINE_ARCH} | sed -e "$expr"`
+               abi=`echo "$UNAME_MACHINE_ARCH" | sed -e "$expr"`
                ;;
        esac
        # The OS release
@@ -216,39 +226,55 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
        # thus, need a distinct triplet. However, they do not need
        # kernel version information, so it can be replaced with a
        # suitable tag, in the style of linux-gnu.
-       case "${UNAME_VERSION}" in
+       case "$UNAME_VERSION" in
            Debian*)
                release='-gnu'
                ;;
            *)
-               release=`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'`
+               release=`echo "$UNAME_RELEASE" | sed -e 's/[-_].*//' | cut -d. -f1,2`
                ;;
        esac
        # Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM:
        # contains redundant information, the shorter form:
        # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM is used.
-       echo "${machine}-${os}${release}${abi}"
+       echo "$machine-${os}${release}${abi-}"
        exit ;;
     *:Bitrig:*:*)
        UNAME_MACHINE_ARCH=`arch | sed 's/Bitrig.//'`
-       echo ${UNAME_MACHINE_ARCH}-unknown-bitrig${UNAME_RELEASE}
+       echo "$UNAME_MACHINE_ARCH"-unknown-bitrig"$UNAME_RELEASE"
        exit ;;
     *:OpenBSD:*:*)
        UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'`
-       echo ${UNAME_MACHINE_ARCH}-unknown-openbsd${UNAME_RELEASE}
+       echo "$UNAME_MACHINE_ARCH"-unknown-openbsd"$UNAME_RELEASE"
+       exit ;;
+    *:LibertyBSD:*:*)
+       UNAME_MACHINE_ARCH=`arch | sed 's/^.*BSD\.//'`
+       echo "$UNAME_MACHINE_ARCH"-unknown-libertybsd"$UNAME_RELEASE"
+       exit ;;
+    *:MidnightBSD:*:*)
+       echo "$UNAME_MACHINE"-unknown-midnightbsd"$UNAME_RELEASE"
        exit ;;
     *:ekkoBSD:*:*)
-       echo ${UNAME_MACHINE}-unknown-ekkobsd${UNAME_RELEASE}
+       echo "$UNAME_MACHINE"-unknown-ekkobsd"$UNAME_RELEASE"
        exit ;;
     *:SolidBSD:*:*)
-       echo ${UNAME_MACHINE}-unknown-solidbsd${UNAME_RELEASE}
+       echo "$UNAME_MACHINE"-unknown-solidbsd"$UNAME_RELEASE"
        exit ;;
     macppc:MirBSD:*:*)
-       echo powerpc-unknown-mirbsd${UNAME_RELEASE}
+       echo powerpc-unknown-mirbsd"$UNAME_RELEASE"
        exit ;;
     *:MirBSD:*:*)
-       echo ${UNAME_MACHINE}-unknown-mirbsd${UNAME_RELEASE}
+       echo "$UNAME_MACHINE"-unknown-mirbsd"$UNAME_RELEASE"
+       exit ;;
+    *:Sortix:*:*)
+       echo "$UNAME_MACHINE"-unknown-sortix
+       exit ;;
+    *:Redox:*:*)
+       echo "$UNAME_MACHINE"-unknown-redox
        exit ;;
+    mips:OSF1:*.*)
+        echo mips-dec-osf1
+        exit ;;
     alpha:OSF1:*:*)
        case $UNAME_RELEASE in
        *4.0)
@@ -265,63 +291,54 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
        ALPHA_CPU_TYPE=`/usr/sbin/psrinfo -v | sed -n -e 's/^  The alpha \(.*\) processor.*$/\1/p' | head -n 1`
        case "$ALPHA_CPU_TYPE" in
            "EV4 (21064)")
-               UNAME_MACHINE="alpha" ;;
+               UNAME_MACHINE=alpha ;;
            "EV4.5 (21064)")
-               UNAME_MACHINE="alpha" ;;
+               UNAME_MACHINE=alpha ;;
            "LCA4 (21066/21068)")
-               UNAME_MACHINE="alpha" ;;
+               UNAME_MACHINE=alpha ;;
            "EV5 (21164)")
-               UNAME_MACHINE="alphaev5" ;;
+               UNAME_MACHINE=alphaev5 ;;
            "EV5.6 (21164A)")
-               UNAME_MACHINE="alphaev56" ;;
+               UNAME_MACHINE=alphaev56 ;;
            "EV5.6 (21164PC)")
-               UNAME_MACHINE="alphapca56" ;;
+               UNAME_MACHINE=alphapca56 ;;
            "EV5.7 (21164PC)")
-               UNAME_MACHINE="alphapca57" ;;
+               UNAME_MACHINE=alphapca57 ;;
            "EV6 (21264)")
-               UNAME_MACHINE="alphaev6" ;;
+               UNAME_MACHINE=alphaev6 ;;
            "EV6.7 (21264A)")
-               UNAME_MACHINE="alphaev67" ;;
+               UNAME_MACHINE=alphaev67 ;;
            "EV6.8CB (21264C)")
-               UNAME_MACHINE="alphaev68" ;;
+               UNAME_MACHINE=alphaev68 ;;
            "EV6.8AL (21264B)")
-               UNAME_MACHINE="alphaev68" ;;
+               UNAME_MACHINE=alphaev68 ;;
            "EV6.8CX (21264D)")
-               UNAME_MACHINE="alphaev68" ;;
+               UNAME_MACHINE=alphaev68 ;;
            "EV6.9A (21264/EV69A)")
-               UNAME_MACHINE="alphaev69" ;;
+               UNAME_MACHINE=alphaev69 ;;
            "EV7 (21364)")
-               UNAME_MACHINE="alphaev7" ;;
+               UNAME_MACHINE=alphaev7 ;;
            "EV7.9 (21364A)")
-               UNAME_MACHINE="alphaev79" ;;
+               UNAME_MACHINE=alphaev79 ;;
        esac
        # A Pn.n version is a patched version.
        # A Vn.n version is a released version.
        # A Tn.n version is a released field test version.
        # A Xn.n version is an unreleased experimental baselevel.
        # 1.2 uses "1.2" for uname -r.
-       echo ${UNAME_MACHINE}-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[PVTX]//' | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
+       echo "$UNAME_MACHINE"-dec-osf"`echo "$UNAME_RELEASE" | sed -e 's/^[PVTX]//' | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz`"
        # Reset EXIT trap before exiting to avoid spurious non-zero exit code.
        exitcode=$?
        trap '' 0
        exit $exitcode ;;
-    Alpha\ *:Windows_NT*:*)
-       # How do we know it's Interix rather than the generic POSIX subsystem?
-       # Should we change UNAME_MACHINE based on the output of uname instead
-       # of the specific Alpha model?
-       echo alpha-pc-interix
-       exit ;;
-    21064:Windows_NT:50:3)
-       echo alpha-dec-winnt3.5
-       exit ;;
     Amiga*:UNIX_System_V:4.0:*)
        echo m68k-unknown-sysv4
        exit ;;
     *:[Aa]miga[Oo][Ss]:*:*)
-       echo ${UNAME_MACHINE}-unknown-amigaos
+       echo "$UNAME_MACHINE"-unknown-amigaos
        exit ;;
     *:[Mm]orph[Oo][Ss]:*:*)
-       echo ${UNAME_MACHINE}-unknown-morphos
+       echo "$UNAME_MACHINE"-unknown-morphos
        exit ;;
     *:OS/390:*:*)
        echo i370-ibm-openedition
@@ -333,7 +350,7 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
        echo powerpc-ibm-os400
        exit ;;
     arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*)
-       echo arm-acorn-riscix${UNAME_RELEASE}
+       echo arm-acorn-riscix"$UNAME_RELEASE"
        exit ;;
     arm*:riscos:*:*|arm*:RISCOS:*:*)
        echo arm-unknown-riscos
@@ -360,38 +377,38 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
            sparc) echo sparc-icl-nx7; exit ;;
        esac ;;
     s390x:SunOS:*:*)
-       echo ${UNAME_MACHINE}-ibm-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+       echo "$UNAME_MACHINE"-ibm-solaris2"`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'`"
        exit ;;
     sun4H:SunOS:5.*:*)
-       echo sparc-hal-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+       echo sparc-hal-solaris2"`echo "$UNAME_RELEASE"|sed -e 's/[^.]*//'`"
        exit ;;
     sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*)
-       echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+       echo sparc-sun-solaris2"`echo "$UNAME_RELEASE" | sed -e 's/[^.]*//'`"
        exit ;;
     i86pc:AuroraUX:5.*:* | i86xen:AuroraUX:5.*:*)
-       echo i386-pc-auroraux${UNAME_RELEASE}
+       echo i386-pc-auroraux"$UNAME_RELEASE"
        exit ;;
     i86pc:SunOS:5.*:* | i86xen:SunOS:5.*:*)
-       eval $set_cc_for_build
-       SUN_ARCH="i386"
+       eval "$set_cc_for_build"
+       SUN_ARCH=i386
        # If there is a compiler, see if it is configured for 64-bit objects.
        # Note that the Sun cc does not turn __LP64__ into 1 like gcc does.
        # This test works for both compilers.
-       if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then
+       if [ "$CC_FOR_BUILD" != no_compiler_found ]; then
            if (echo '#ifdef __amd64'; echo IS_64BIT_ARCH; echo '#endif') | \
-               (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \
+               (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \
                grep IS_64BIT_ARCH >/dev/null
            then
-               SUN_ARCH="x86_64"
+               SUN_ARCH=x86_64
            fi
        fi
-       echo ${SUN_ARCH}-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+       echo "$SUN_ARCH"-pc-solaris2"`echo "$UNAME_RELEASE"|sed -e 's/[^.]*//'`"
        exit ;;
     sun4*:SunOS:6*:*)
        # According to config.sub, this is the proper way to canonicalize
        # SunOS6.  Hard to guess exactly what SunOS6 will be like, but
        # it's likely to be more like Solaris than SunOS4.
-       echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+       echo sparc-sun-solaris3"`echo "$UNAME_RELEASE"|sed -e 's/[^.]*//'`"
        exit ;;
     sun4*:SunOS:*:*)
        case "`/usr/bin/arch -k`" in
@@ -400,25 +417,25 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
                ;;
        esac
        # Japanese Language versions have a version number like `4.1.3-JL'.
-       echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'`
+       echo sparc-sun-sunos"`echo "$UNAME_RELEASE"|sed -e 's/-/_/'`"
        exit ;;
     sun3*:SunOS:*:*)
-       echo m68k-sun-sunos${UNAME_RELEASE}
+       echo m68k-sun-sunos"$UNAME_RELEASE"
        exit ;;
     sun*:*:4.2BSD:*)
        UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null`
-       test "x${UNAME_RELEASE}" = "x" && UNAME_RELEASE=3
+       test "x$UNAME_RELEASE" = x && UNAME_RELEASE=3
        case "`/bin/arch`" in
            sun3)
-               echo m68k-sun-sunos${UNAME_RELEASE}
+               echo m68k-sun-sunos"$UNAME_RELEASE"
                ;;
            sun4)
-               echo sparc-sun-sunos${UNAME_RELEASE}
+               echo sparc-sun-sunos"$UNAME_RELEASE"
                ;;
        esac
        exit ;;
     aushp:SunOS:*:*)
-       echo sparc-auspex-sunos${UNAME_RELEASE}
+       echo sparc-auspex-sunos"$UNAME_RELEASE"
        exit ;;
     # The situation for MiNT is a little confusing.  The machine name
     # can be virtually everything (everything which is not
@@ -429,44 +446,44 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
     # MiNT.  But MiNT is downward compatible to TOS, so this should
     # be no problem.
     atarist[e]:*MiNT:*:* | atarist[e]:*mint:*:* | atarist[e]:*TOS:*:*)
-       echo m68k-atari-mint${UNAME_RELEASE}
+       echo m68k-atari-mint"$UNAME_RELEASE"
        exit ;;
     atari*:*MiNT:*:* | atari*:*mint:*:* | atarist[e]:*TOS:*:*)
-       echo m68k-atari-mint${UNAME_RELEASE}
+       echo m68k-atari-mint"$UNAME_RELEASE"
        exit ;;
     *falcon*:*MiNT:*:* | *falcon*:*mint:*:* | *falcon*:*TOS:*:*)
-       echo m68k-atari-mint${UNAME_RELEASE}
+       echo m68k-atari-mint"$UNAME_RELEASE"
        exit ;;
     milan*:*MiNT:*:* | milan*:*mint:*:* | *milan*:*TOS:*:*)
-       echo m68k-milan-mint${UNAME_RELEASE}
+       echo m68k-milan-mint"$UNAME_RELEASE"
        exit ;;
     hades*:*MiNT:*:* | hades*:*mint:*:* | *hades*:*TOS:*:*)
-       echo m68k-hades-mint${UNAME_RELEASE}
+       echo m68k-hades-mint"$UNAME_RELEASE"
        exit ;;
     *:*MiNT:*:* | *:*mint:*:* | *:*TOS:*:*)
-       echo m68k-unknown-mint${UNAME_RELEASE}
+       echo m68k-unknown-mint"$UNAME_RELEASE"
        exit ;;
     m68k:machten:*:*)
-       echo m68k-apple-machten${UNAME_RELEASE}
+       echo m68k-apple-machten"$UNAME_RELEASE"
        exit ;;
     powerpc:machten:*:*)
-       echo powerpc-apple-machten${UNAME_RELEASE}
+       echo powerpc-apple-machten"$UNAME_RELEASE"
        exit ;;
     RISC*:Mach:*:*)
        echo mips-dec-mach_bsd4.3
        exit ;;
     RISC*:ULTRIX:*:*)
-       echo mips-dec-ultrix${UNAME_RELEASE}
+       echo mips-dec-ultrix"$UNAME_RELEASE"
        exit ;;
     VAX*:ULTRIX*:*:*)
-       echo vax-dec-ultrix${UNAME_RELEASE}
+       echo vax-dec-ultrix"$UNAME_RELEASE"
        exit ;;
     2020:CLIX:*:* | 2430:CLIX:*:*)
-       echo clipper-intergraph-clix${UNAME_RELEASE}
+       echo clipper-intergraph-clix"$UNAME_RELEASE"
        exit ;;
     mips:*:*:UMIPS | mips:*:*:RISCos)
-       eval $set_cc_for_build
-       sed 's/^        //' << EOF >$dummy.c
+       eval "$set_cc_for_build"
+       sed 's/^        //' << EOF > "$dummy.c"
 #ifdef __cplusplus
 #include <stdio.h>  /* for printf() prototype */
        int main (int argc, char *argv[]) {
@@ -475,23 +492,23 @@ case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in
 #endif
        #if defined (host_mips) && defined (MIPSEB)
        #if defined (SYSTYPE_SYSV)
-         printf ("mips-mips-riscos%ssysv\n", argv[1]); exit (0);
+         printf ("mips-mips-riscos%ssysv\\n", argv[1]); exit (0);
        #endif
        #if defined (SYSTYPE_SVR4)
-         printf ("mips-mips-riscos%ssvr4\n", argv[1]); exit (0);
+         printf ("mips-mips-riscos%ssvr4\\n", argv[1]); exit (0);
        #endif
        #if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD)
-         printf ("mips-mips-riscos%sbsd\n", argv[1]); exit (0);
+         printf ("mips-mips-riscos%sbsd\\n", argv[1]); exit (0);
        #endif
        #endif
          exit (-1);
        }
 EOF
-       $CC_FOR_BUILD -o $dummy $dummy.c &&
-         dummyarg=`echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` &&
-         SYSTEM_NAME=`$dummy $dummyarg` &&
+       $CC_FOR_BUILD -o "$dummy" "$dummy.c" &&
+         dummyarg=`echo "$UNAME_RELEASE" | sed -n 's/\([0-9]*\).*/\1/p'` &&
+         SYSTEM_NAME=`"$dummy" "$dummyarg"` &&
            { echo "$SYSTEM_NAME"; exit; }
-       echo mips-mips-riscos${UNAME_RELEASE}
+       echo mips-mips-riscos"$UNAME_RELEASE"
        exit ;;
     Motorola:PowerMAX_OS:*:*)
        echo powerpc-motorola-powermax
@@ -517,17 +534,17 @@ EOF
     AViiON:dgux:*:*)
        # DG/UX returns AViiON for all architectures
        UNAME_PROCESSOR=`/usr/bin/uname -p`
-       if [ $UNAME_PROCESSOR = mc88100 ] || [ $UNAME_PROCESSOR = mc88110 ]
+       if [ "$UNAME_PROCESSOR" = mc88100 ] || [ "$UNAME_PROCESSOR" = mc88110 ]
        then
-           if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx ] || \
-              [ ${TARGET_BINARY_INTERFACE}x = x ]
+           if [ "$TARGET_BINARY_INTERFACE"x = m88kdguxelfx ] || \
+              [ "$TARGET_BINARY_INTERFACE"x = x ]
            then
-               echo m88k-dg-dgux${UNAME_RELEASE}
+               echo m88k-dg-dgux"$UNAME_RELEASE"
            else
-               echo m88k-dg-dguxbcs${UNAME_RELEASE}
+               echo m88k-dg-dguxbcs"$UNAME_RELEASE"
            fi
        else
-           echo i586-dg-dgux${UNAME_RELEASE}
+           echo i586-dg-dgux"$UNAME_RELEASE"
        fi
        exit ;;
     M88*:DolphinOS:*:*)        # DolphinOS (SVR3)
@@ -544,7 +561,7 @@ EOF
        echo m68k-tektronix-bsd
        exit ;;
     *:IRIX*:*:*)
-       echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'`
+       echo mips-sgi-irix"`echo "$UNAME_RELEASE"|sed -e 's/-/_/g'`"
        exit ;;
     ????????:AIX?:[12].1:2)   # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX.
        echo romp-ibm-aix     # uname -m gives an 8 hex-code CPU id
@@ -556,14 +573,14 @@ EOF
        if [ -x /usr/bin/oslevel ] ; then
                IBM_REV=`/usr/bin/oslevel`
        else
-               IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE}
+               IBM_REV="$UNAME_VERSION.$UNAME_RELEASE"
        fi
-       echo ${UNAME_MACHINE}-ibm-aix${IBM_REV}
+       echo "$UNAME_MACHINE"-ibm-aix"$IBM_REV"
        exit ;;
     *:AIX:2:3)
        if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then
-               eval $set_cc_for_build
-               sed 's/^                //' << EOF >$dummy.c
+               eval "$set_cc_for_build"
+               sed 's/^                //' << EOF > "$dummy.c"
                #include <sys/systemcfg.h>
 
                main()
@@ -574,7 +591,7 @@ EOF
                        exit(0);
                        }
 EOF
-               if $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy`
+               if $CC_FOR_BUILD -o "$dummy" "$dummy.c" && SYSTEM_NAME=`"$dummy"`
                then
                        echo "$SYSTEM_NAME"
                else
@@ -588,7 +605,7 @@ EOF
        exit ;;
     *:AIX:*:[4567])
        IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'`
-       if /usr/sbin/lsattr -El ${IBM_CPU_ID} | grep ' POWER' >/dev/null 2>&1; then
+       if /usr/sbin/lsattr -El "$IBM_CPU_ID" | grep ' POWER' >/dev/null 2>&1; then
                IBM_ARCH=rs6000
        else
                IBM_ARCH=powerpc
@@ -597,18 +614,18 @@ EOF
                IBM_REV=`/usr/bin/lslpp -Lqc bos.rte.libc |
                           awk -F: '{ print $3 }' | sed s/[0-9]*$/0/`
        else
-               IBM_REV=${UNAME_VERSION}.${UNAME_RELEASE}
+               IBM_REV="$UNAME_VERSION.$UNAME_RELEASE"
        fi
-       echo ${IBM_ARCH}-ibm-aix${IBM_REV}
+       echo "$IBM_ARCH"-ibm-aix"$IBM_REV"
        exit ;;
     *:AIX:*:*)
        echo rs6000-ibm-aix
        exit ;;
-    ibmrt:4.4BSD:*|romp-ibm:BSD:*)
+    ibmrt:4.4BSD:*|romp-ibm:4.4BSD:*)
        echo romp-ibm-bsd4.4
        exit ;;
     ibmrt:*BSD:*|romp-ibm:BSD:*)            # covers RT/PC BSD and
-       echo romp-ibm-bsd${UNAME_RELEASE}   # 4.3 with uname added to
+       echo romp-ibm-bsd"$UNAME_RELEASE"   # 4.3 with uname added to
        exit ;;                             # report: romp-ibm BSD 4.3
     *:BOSX:*:*)
        echo rs6000-bull-bosx
@@ -623,28 +640,28 @@ EOF
        echo m68k-hp-bsd4.4
        exit ;;
     9000/[34678]??:HP-UX:*:*)
-       HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'`
-       case "${UNAME_MACHINE}" in
-           9000/31? )            HP_ARCH=m68000 ;;
-           9000/[34]?? )         HP_ARCH=m68k ;;
+       HPUX_REV=`echo "$UNAME_RELEASE"|sed -e 's/[^.]*.[0B]*//'`
+       case "$UNAME_MACHINE" in
+           9000/31?)            HP_ARCH=m68000 ;;
+           9000/[34]??)         HP_ARCH=m68k ;;
            9000/[678][0-9][0-9])
                if [ -x /usr/bin/getconf ]; then
                    sc_cpu_version=`/usr/bin/getconf SC_CPU_VERSION 2>/dev/null`
                    sc_kernel_bits=`/usr/bin/getconf SC_KERNEL_BITS 2>/dev/null`
-                   case "${sc_cpu_version}" in
-                     523) HP_ARCH="hppa1.0" ;; # CPU_PA_RISC1_0
-                     528) HP_ARCH="hppa1.1" ;; # CPU_PA_RISC1_1
+                   case "$sc_cpu_version" in
+                     523) HP_ARCH=hppa1.0 ;; # CPU_PA_RISC1_0
+                     528) HP_ARCH=hppa1.1 ;; # CPU_PA_RISC1_1
                      532)                      # CPU_PA_RISC2_0
-                       case "${sc_kernel_bits}" in
-                         32) HP_ARCH="hppa2.0n" ;;
-                         64) HP_ARCH="hppa2.0w" ;;
-                         '') HP_ARCH="hppa2.0" ;;   # HP-UX 10.20
+                       case "$sc_kernel_bits" in
+                         32) HP_ARCH=hppa2.0n ;;
+                         64) HP_ARCH=hppa2.0w ;;
+                         '') HP_ARCH=hppa2.0 ;;   # HP-UX 10.20
                        esac ;;
                    esac
                fi
-               if [ "${HP_ARCH}" = "" ]; then
-                   eval $set_cc_for_build
-                   sed 's/^            //' << EOF >$dummy.c
+               if [ "$HP_ARCH" = "" ]; then
+                   eval "$set_cc_for_build"
+                   sed 's/^            //' << EOF > "$dummy.c"
 
                #define _HPUX_SOURCE
                #include <stdlib.h>
@@ -677,13 +694,13 @@ EOF
                    exit (0);
                }
 EOF
-                   (CCOPTS= $CC_FOR_BUILD -o $dummy $dummy.c 2>/dev/null) && HP_ARCH=`$dummy`
+                   (CCOPTS="" $CC_FOR_BUILD -o "$dummy" "$dummy.c" 2>/dev/null) && HP_ARCH=`"$dummy"`
                    test -z "$HP_ARCH" && HP_ARCH=hppa
                fi ;;
        esac
-       if [ ${HP_ARCH} = "hppa2.0w" ]
+       if [ "$HP_ARCH" = hppa2.0w ]
        then
-           eval $set_cc_for_build
+           eval "$set_cc_for_build"
 
            # hppa2.0w-hp-hpux* has a 64-bit kernel and a compiler generating
            # 32-bit code.  hppa64-hp-hpux* has the same kernel and a compiler
@@ -694,23 +711,23 @@ EOF
            # $ CC_FOR_BUILD="cc +DA2.0w" ./config.guess
            # => hppa64-hp-hpux11.23
 
-           if echo __LP64__ | (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) |
+           if echo __LP64__ | (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) |
                grep -q __LP64__
            then
-               HP_ARCH="hppa2.0w"
+               HP_ARCH=hppa2.0w
            else
-               HP_ARCH="hppa64"
+               HP_ARCH=hppa64
            fi
        fi
-       echo ${HP_ARCH}-hp-hpux${HPUX_REV}
+       echo "$HP_ARCH"-hp-hpux"$HPUX_REV"
        exit ;;
     ia64:HP-UX:*:*)
-       HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'`
-       echo ia64-hp-hpux${HPUX_REV}
+       HPUX_REV=`echo "$UNAME_RELEASE"|sed -e 's/[^.]*.[0B]*//'`
+       echo ia64-hp-hpux"$HPUX_REV"
        exit ;;
     3050*:HI-UX:*:*)
-       eval $set_cc_for_build
-       sed 's/^        //' << EOF >$dummy.c
+       eval "$set_cc_for_build"
+       sed 's/^        //' << EOF > "$dummy.c"
        #include <unistd.h>
        int
        main ()
@@ -735,11 +752,11 @@ EOF
          exit (0);
        }
 EOF
-       $CC_FOR_BUILD -o $dummy $dummy.c && SYSTEM_NAME=`$dummy` &&
+       $CC_FOR_BUILD -o "$dummy" "$dummy.c" && SYSTEM_NAME=`"$dummy"` &&
                { echo "$SYSTEM_NAME"; exit; }
        echo unknown-hitachi-hiuxwe2
        exit ;;
-    9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* )
+    9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:*)
        echo hppa1.1-hp-bsd
        exit ;;
     9000/8??:4.3bsd:*:*)
@@ -748,7 +765,7 @@ EOF
     *9??*:MPE/iX:*:* | *3000*:MPE/iX:*:*)
        echo hppa1.0-hp-mpeix
        exit ;;
-    hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* )
+    hp7??:OSF1:*:* | hp8?[79]:OSF1:*:*)
        echo hppa1.1-hp-osf
        exit ;;
     hp8??:OSF1:*:*)
@@ -756,9 +773,9 @@ EOF
        exit ;;
     i*86:OSF1:*:*)
        if [ -x /usr/sbin/sysversion ] ; then
-           echo ${UNAME_MACHINE}-unknown-osf1mk
+           echo "$UNAME_MACHINE"-unknown-osf1mk
        else
-           echo ${UNAME_MACHINE}-unknown-osf1
+           echo "$UNAME_MACHINE"-unknown-osf1
        fi
        exit ;;
     parisc*:Lites*:*:*)
@@ -783,127 +800,109 @@ EOF
        echo c4-convex-bsd
        exit ;;
     CRAY*Y-MP:*:*:*)
-       echo ymp-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
+       echo ymp-cray-unicos"$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/'
        exit ;;
     CRAY*[A-Z]90:*:*:*)
-       echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \
+       echo "$UNAME_MACHINE"-cray-unicos"$UNAME_RELEASE" \
        | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \
              -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ \
              -e 's/\.[^.]*$/.X/'
        exit ;;
     CRAY*TS:*:*:*)
-       echo t90-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
+       echo t90-cray-unicos"$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/'
        exit ;;
     CRAY*T3E:*:*:*)
-       echo alphaev5-cray-unicosmk${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
+       echo alphaev5-cray-unicosmk"$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/'
        exit ;;
     CRAY*SV1:*:*:*)
-       echo sv1-cray-unicos${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
+       echo sv1-cray-unicos"$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/'
        exit ;;
     *:UNICOS/mp:*:*)
-       echo craynv-cray-unicosmp${UNAME_RELEASE} | sed -e 's/\.[^.]*$/.X/'
+       echo craynv-cray-unicosmp"$UNAME_RELEASE" | sed -e 's/\.[^.]*$/.X/'
        exit ;;
     F30[01]:UNIX_System_V:*:* | F700:UNIX_System_V:*:*)
-       FUJITSU_PROC=`uname -m | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'`
-       FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'`
-       FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'`
+       FUJITSU_PROC=`uname -m | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz`
+       FUJITSU_SYS=`uname -p | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/\///'`
+       FUJITSU_REL=`echo "$UNAME_RELEASE" | sed -e 's/ /_/'`
        echo "${FUJITSU_PROC}-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
        exit ;;
     5000:UNIX_System_V:4.*:*)
-       FUJITSU_SYS=`uname -p | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/\///'`
-       FUJITSU_REL=`echo ${UNAME_RELEASE} | tr 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz' | sed -e 's/ /_/'`
+       FUJITSU_SYS=`uname -p | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/\///'`
+       FUJITSU_REL=`echo "$UNAME_RELEASE" | tr ABCDEFGHIJKLMNOPQRSTUVWXYZ abcdefghijklmnopqrstuvwxyz | sed -e 's/ /_/'`
        echo "sparc-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}"
        exit ;;
     i*86:BSD/386:*:* | i*86:BSD/OS:*:* | *:Ascend\ Embedded/OS:*:*)
-       echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE}
+       echo "$UNAME_MACHINE"-pc-bsdi"$UNAME_RELEASE"
        exit ;;
     sparc*:BSD/OS:*:*)
-       echo sparc-unknown-bsdi${UNAME_RELEASE}
+       echo sparc-unknown-bsdi"$UNAME_RELEASE"
        exit ;;
     *:BSD/OS:*:*)
-       echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE}
+       echo "$UNAME_MACHINE"-unknown-bsdi"$UNAME_RELEASE"
        exit ;;
     *:FreeBSD:*:*)
        UNAME_PROCESSOR=`/usr/bin/uname -p`
-       case ${UNAME_PROCESSOR} in
+       case "$UNAME_PROCESSOR" in
            amd64)
-               echo x86_64-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;;
-           *)
-               echo ${UNAME_PROCESSOR}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` ;;
+               UNAME_PROCESSOR=x86_64 ;;
+           i386)
+               UNAME_PROCESSOR=i586 ;;
        esac
+       echo "$UNAME_PROCESSOR"-unknown-freebsd"`echo "$UNAME_RELEASE"|sed -e 's/[-(].*//'`"
        exit ;;
     i*:CYGWIN*:*)
-       echo ${UNAME_MACHINE}-pc-cygwin
+       echo "$UNAME_MACHINE"-pc-cygwin
        exit ;;
     *:MINGW64*:*)
-       echo ${UNAME_MACHINE}-pc-mingw64
+       echo "$UNAME_MACHINE"-pc-mingw64
        exit ;;
     *:MINGW*:*)
-       echo ${UNAME_MACHINE}-pc-mingw32
+       echo "$UNAME_MACHINE"-pc-mingw32
        exit ;;
     *:MSYS*:*)
-       echo ${UNAME_MACHINE}-pc-msys
-       exit ;;
-    i*:windows32*:*)
-       # uname -m includes "-pc" on this system.
-       echo ${UNAME_MACHINE}-mingw32
+       echo "$UNAME_MACHINE"-pc-msys
        exit ;;
     i*:PW*:*)
-       echo ${UNAME_MACHINE}-pc-pw32
+       echo "$UNAME_MACHINE"-pc-pw32
        exit ;;
     *:Interix*:*)
-       case ${UNAME_MACHINE} in
+       case "$UNAME_MACHINE" in
            x86)
-               echo i586-pc-interix${UNAME_RELEASE}
+               echo i586-pc-interix"$UNAME_RELEASE"
                exit ;;
            authenticamd | genuineintel | EM64T)
-               echo x86_64-unknown-interix${UNAME_RELEASE}
+               echo x86_64-unknown-interix"$UNAME_RELEASE"
                exit ;;
            IA64)
-               echo ia64-unknown-interix${UNAME_RELEASE}
+               echo ia64-unknown-interix"$UNAME_RELEASE"
                exit ;;
        esac ;;
-    [345]86:Windows_95:* | [345]86:Windows_98:* | [345]86:Windows_NT:*)
-       echo i${UNAME_MACHINE}-pc-mks
-       exit ;;
-    8664:Windows_NT:*)
-       echo x86_64-pc-mks
-       exit ;;
-    i*:Windows_NT*:* | Pentium*:Windows_NT*:*)
-       # How do we know it's Interix rather than the generic POSIX subsystem?
-       # It also conflicts with pre-2.0 versions of AT&T UWIN. Should we
-       # UNAME_MACHINE based on the output of uname instead of i386?
-       echo i586-pc-interix
-       exit ;;
     i*:UWIN*:*)
-       echo ${UNAME_MACHINE}-pc-uwin
+       echo "$UNAME_MACHINE"-pc-uwin
        exit ;;
     amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*)
        echo x86_64-unknown-cygwin
        exit ;;
-    p*:CYGWIN*:*)
-       echo powerpcle-unknown-cygwin
-       exit ;;
     prep*:SunOS:5.*:*)
-       echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'`
+       echo powerpcle-unknown-solaris2"`echo "$UNAME_RELEASE"|sed -e 's/[^.]*//'`"
        exit ;;
     *:GNU:*:*)
        # the GNU system
-       echo `echo ${UNAME_MACHINE}|sed -e 's,[-/].*$,,'`-unknown-${LIBC}`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'`
+       echo "`echo "$UNAME_MACHINE"|sed -e 's,[-/].*$,,'`-unknown-$LIBC`echo "$UNAME_RELEASE"|sed -e 's,/.*$,,'`"
        exit ;;
     *:GNU/*:*:*)
        # other systems with GNU libc and userland
-       echo ${UNAME_MACHINE}-unknown-`echo ${UNAME_SYSTEM} | sed 's,^[^/]*/,,' | tr '[A-Z]' '[a-z]'``echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`-${LIBC}
+       echo "$UNAME_MACHINE-unknown-`echo "$UNAME_SYSTEM" | sed 's,^[^/]*/,,' | tr "[:upper:]" "[:lower:]"``echo "$UNAME_RELEASE"|sed -e 's/[-(].*//'`-$LIBC"
        exit ;;
-    i*86:Minix:*:*)
-       echo ${UNAME_MACHINE}-pc-minix
+    *:Minix:*:*)
+       echo "$UNAME_MACHINE"-unknown-minix
        exit ;;
     aarch64:Linux:*:*)
-       echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
+       echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"
        exit ;;
     aarch64_be:Linux:*:*)
        UNAME_MACHINE=aarch64_be
-       echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
+       echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"
        exit ;;
     alpha:Linux:*:*)
        case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in
@@ -916,58 +915,64 @@ EOF
          EV68*) UNAME_MACHINE=alphaev68 ;;
        esac
        objdump --private-headers /bin/sh | grep -q ld.so.1
-       if test "$?" = 0 ; then LIBC="gnulibc1" ; fi
-       echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
+       if test "$?" = 0 ; then LIBC=gnulibc1 ; fi
+       echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"
        exit ;;
     arc:Linux:*:* | arceb:Linux:*:*)
-       echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
+       echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"
        exit ;;
     arm*:Linux:*:*)
-       eval $set_cc_for_build
+       eval "$set_cc_for_build"
        if echo __ARM_EABI__ | $CC_FOR_BUILD -E - 2>/dev/null \
            | grep -q __ARM_EABI__
        then
-           echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
+           echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"
        else
            if echo __ARM_PCS_VFP | $CC_FOR_BUILD -E - 2>/dev/null \
                | grep -q __ARM_PCS_VFP
            then
-               echo ${UNAME_MACHINE}-unknown-linux-${LIBC}eabi
+               echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"eabi
            else
-               echo ${UNAME_MACHINE}-unknown-linux-${LIBC}eabihf
+               echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"eabihf
            fi
        fi
        exit ;;
     avr32*:Linux:*:*)
-       echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
+       echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"
        exit ;;
     cris:Linux:*:*)
-       echo ${UNAME_MACHINE}-axis-linux-${LIBC}
+       echo "$UNAME_MACHINE"-axis-linux-"$LIBC"
        exit ;;
     crisv32:Linux:*:*)
-       echo ${UNAME_MACHINE}-axis-linux-${LIBC}
+       echo "$UNAME_MACHINE"-axis-linux-"$LIBC"
+       exit ;;
+    e2k:Linux:*:*)
+       echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"
        exit ;;
     frv:Linux:*:*)
-       echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
+       echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"
        exit ;;
     hexagon:Linux:*:*)
-       echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
+       echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"
        exit ;;
     i*86:Linux:*:*)
-       echo ${UNAME_MACHINE}-pc-linux-${LIBC}
+       echo "$UNAME_MACHINE"-pc-linux-"$LIBC"
        exit ;;
     ia64:Linux:*:*)
-       echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
+       echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"
+       exit ;;
+    k1om:Linux:*:*)
+       echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"
        exit ;;
     m32r*:Linux:*:*)
-       echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
+       echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"
        exit ;;
     m68*:Linux:*:*)
-       echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
+       echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"
        exit ;;
     mips:Linux:*:* | mips64:Linux:*:*)
-       eval $set_cc_for_build
-       sed 's/^        //' << EOF >$dummy.c
+       eval "$set_cc_for_build"
+       sed 's/^        //' << EOF > "$dummy.c"
        #undef CPU
        #undef ${UNAME_MACHINE}
        #undef ${UNAME_MACHINE}el
@@ -981,64 +986,70 @@ EOF
        #endif
        #endif
 EOF
-       eval `$CC_FOR_BUILD -E $dummy.c 2>/dev/null | grep '^CPU'`
-       test x"${CPU}" != x && { echo "${CPU}-unknown-linux-${LIBC}"; exit; }
+       eval "`$CC_FOR_BUILD -E "$dummy.c" 2>/dev/null | grep '^CPU'`"
+       test "x$CPU" != x && { echo "$CPU-unknown-linux-$LIBC"; exit; }
        ;;
+    mips64el:Linux:*:*)
+       echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"
+       exit ;;
     openrisc*:Linux:*:*)
-       echo or1k-unknown-linux-${LIBC}
+       echo or1k-unknown-linux-"$LIBC"
        exit ;;
     or32:Linux:*:* | or1k*:Linux:*:*)
-       echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
+       echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"
        exit ;;
     padre:Linux:*:*)
-       echo sparc-unknown-linux-${LIBC}
+       echo sparc-unknown-linux-"$LIBC"
        exit ;;
     parisc64:Linux:*:* | hppa64:Linux:*:*)
-       echo hppa64-unknown-linux-${LIBC}
+       echo hppa64-unknown-linux-"$LIBC"
        exit ;;
     parisc:Linux:*:* | hppa:Linux:*:*)
        # Look for CPU level
        case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in
-         PA7*) echo hppa1.1-unknown-linux-${LIBC} ;;
-         PA8*) echo hppa2.0-unknown-linux-${LIBC} ;;
-         *)    echo hppa-unknown-linux-${LIBC} ;;
+         PA7*) echo hppa1.1-unknown-linux-"$LIBC" ;;
+         PA8*) echo hppa2.0-unknown-linux-"$LIBC" ;;
+         *)    echo hppa-unknown-linux-"$LIBC" ;;
        esac
        exit ;;
     ppc64:Linux:*:*)
-       echo powerpc64-unknown-linux-${LIBC}
+       echo powerpc64-unknown-linux-"$LIBC"
        exit ;;
     ppc:Linux:*:*)
-       echo powerpc-unknown-linux-${LIBC}
+       echo powerpc-unknown-linux-"$LIBC"
        exit ;;
     ppc64le:Linux:*:*)
-       echo powerpc64le-unknown-linux-${LIBC}
+       echo powerpc64le-unknown-linux-"$LIBC"
        exit ;;
     ppcle:Linux:*:*)
-       echo powerpcle-unknown-linux-${LIBC}
+       echo powerpcle-unknown-linux-"$LIBC"
+       exit ;;
+    riscv32:Linux:*:* | riscv64:Linux:*:*)
+       echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"
        exit ;;
     s390:Linux:*:* | s390x:Linux:*:*)
-       echo ${UNAME_MACHINE}-ibm-linux-${LIBC}
+       echo "$UNAME_MACHINE"-ibm-linux-"$LIBC"
        exit ;;
     sh64*:Linux:*:*)
-       echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
+       echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"
        exit ;;
     sh*:Linux:*:*)
-       echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
+       echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"
        exit ;;
     sparc:Linux:*:* | sparc64:Linux:*:*)
-       echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
+       echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"
        exit ;;
     tile*:Linux:*:*)
-       echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
+       echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"
        exit ;;
     vax:Linux:*:*)
-       echo ${UNAME_MACHINE}-dec-linux-${LIBC}
+       echo "$UNAME_MACHINE"-dec-linux-"$LIBC"
        exit ;;
     x86_64:Linux:*:*)
-       echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
+       echo "$UNAME_MACHINE"-pc-linux-"$LIBC"
        exit ;;
     xtensa*:Linux:*:*)
-       echo ${UNAME_MACHINE}-unknown-linux-${LIBC}
+       echo "$UNAME_MACHINE"-unknown-linux-"$LIBC"
        exit ;;
     i*86:DYNIX/ptx:4*:*)
        # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there.
@@ -1052,34 +1063,34 @@ EOF
        # I am not positive that other SVR4 systems won't match this,
        # I just have to hope.  -- rms.
        # Use sysv4.2uw... so that sysv4* matches it.
-       echo ${UNAME_MACHINE}-pc-sysv4.2uw${UNAME_VERSION}
+       echo "$UNAME_MACHINE"-pc-sysv4.2uw"$UNAME_VERSION"
        exit ;;
     i*86:OS/2:*:*)
        # If we were able to find `uname', then EMX Unix compatibility
        # is probably installed.
-       echo ${UNAME_MACHINE}-pc-os2-emx
+       echo "$UNAME_MACHINE"-pc-os2-emx
        exit ;;
     i*86:XTS-300:*:STOP)
-       echo ${UNAME_MACHINE}-unknown-stop
+       echo "$UNAME_MACHINE"-unknown-stop
        exit ;;
     i*86:atheos:*:*)
-       echo ${UNAME_MACHINE}-unknown-atheos
+       echo "$UNAME_MACHINE"-unknown-atheos
        exit ;;
     i*86:syllable:*:*)
-       echo ${UNAME_MACHINE}-pc-syllable
+       echo "$UNAME_MACHINE"-pc-syllable
        exit ;;
     i*86:LynxOS:2.*:* | i*86:LynxOS:3.[01]*:* | i*86:LynxOS:4.[02]*:*)
-       echo i386-unknown-lynxos${UNAME_RELEASE}
+       echo i386-unknown-lynxos"$UNAME_RELEASE"
        exit ;;
     i*86:*DOS:*:*)
-       echo ${UNAME_MACHINE}-pc-msdosdjgpp
+       echo "$UNAME_MACHINE"-pc-msdosdjgpp
        exit ;;
-    i*86:*:4.*:* | i*86:SYSTEM_V:4.*:*)
-       UNAME_REL=`echo ${UNAME_RELEASE} | sed 's/\/MP$//'`
+    i*86:*:4.*:*)
+       UNAME_REL=`echo "$UNAME_RELEASE" | sed 's/\/MP$//'`
        if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then
-               echo ${UNAME_MACHINE}-univel-sysv${UNAME_REL}
+               echo "$UNAME_MACHINE"-univel-sysv"$UNAME_REL"
        else
-               echo ${UNAME_MACHINE}-pc-sysv${UNAME_REL}
+               echo "$UNAME_MACHINE"-pc-sysv"$UNAME_REL"
        fi
        exit ;;
     i*86:*:5:[678]*)
@@ -1089,12 +1100,12 @@ EOF
            *Pentium)        UNAME_MACHINE=i586 ;;
            *Pent*|*Celeron) UNAME_MACHINE=i686 ;;
        esac
-       echo ${UNAME_MACHINE}-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}${UNAME_VERSION}
+       echo "$UNAME_MACHINE-unknown-sysv${UNAME_RELEASE}${UNAME_SYSTEM}{$UNAME_VERSION}"
        exit ;;
     i*86:*:3.2:*)
        if test -f /usr/options/cb.name; then
                UNAME_REL=`sed -n 's/.*Version //p' </usr/options/cb.name`
-               echo ${UNAME_MACHINE}-pc-isc$UNAME_REL
+               echo "$UNAME_MACHINE"-pc-isc"$UNAME_REL"
        elif /bin/uname -X 2>/dev/null >/dev/null ; then
                UNAME_REL=`(/bin/uname -X|grep Release|sed -e 's/.*= //')`
                (/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486
@@ -1104,9 +1115,9 @@ EOF
                        && UNAME_MACHINE=i686
                (/bin/uname -X|grep '^Machine.*Pentium Pro' >/dev/null) \
                        && UNAME_MACHINE=i686
-               echo ${UNAME_MACHINE}-pc-sco$UNAME_REL
+               echo "$UNAME_MACHINE"-pc-sco"$UNAME_REL"
        else
-               echo ${UNAME_MACHINE}-pc-sysv32
+               echo "$UNAME_MACHINE"-pc-sysv32
        fi
        exit ;;
     pc:*:*:*)
@@ -1114,7 +1125,7 @@ EOF
        # uname -m prints for DJGPP always 'pc', but it prints nothing about
        # the processor, so we play safe by assuming i586.
        # Note: whatever this is, it MUST be the same as what config.sub
-       # prints for the "djgpp" host, or else GDB configury will decide that
+       # prints for the "djgpp" host, or else GDB configure will decide that
        # this is a cross-build.
        echo i586-pc-msdosdjgpp
        exit ;;
@@ -1126,9 +1137,9 @@ EOF
        exit ;;
     i860:*:4.*:*) # i860-SVR4
        if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then
-         echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4
+         echo i860-stardent-sysv"$UNAME_RELEASE" # Stardent Vistra i860-SVR4
        else # Add other i860-SVR4 vendors below as they are discovered.
-         echo i860-unknown-sysv${UNAME_RELEASE}  # Unknown i860-SVR4
+         echo i860-unknown-sysv"$UNAME_RELEASE"  # Unknown i860-SVR4
        fi
        exit ;;
     mini*:CTIX:SYS*5:*)
@@ -1148,9 +1159,9 @@ EOF
        test -r /etc/.relid \
        && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid`
        /bin/uname -p 2>/dev/null | grep 86 >/dev/null \
-         && { echo i486-ncr-sysv4.3${OS_REL}; exit; }
+         && { echo i486-ncr-sysv4.3"$OS_REL"; exit; }
        /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \
-         && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;;
+         && { echo i586-ncr-sysv4.3"$OS_REL"; exit; } ;;
     3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*)
        /bin/uname -p 2>/dev/null | grep 86 >/dev/null \
          && { echo i486-ncr-sysv4; exit; } ;;
@@ -1159,28 +1170,28 @@ EOF
        test -r /etc/.relid \
            && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid`
        /bin/uname -p 2>/dev/null | grep 86 >/dev/null \
-           && { echo i486-ncr-sysv4.3${OS_REL}; exit; }
+           && { echo i486-ncr-sysv4.3"$OS_REL"; exit; }
        /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \
-           && { echo i586-ncr-sysv4.3${OS_REL}; exit; }
+           && { echo i586-ncr-sysv4.3"$OS_REL"; exit; }
        /bin/uname -p 2>/dev/null | /bin/grep pteron >/dev/null \
-           && { echo i586-ncr-sysv4.3${OS_REL}; exit; } ;;
+           && { echo i586-ncr-sysv4.3"$OS_REL"; exit; } ;;
     m68*:LynxOS:2.*:* | m68*:LynxOS:3.0*:*)
-       echo m68k-unknown-lynxos${UNAME_RELEASE}
+       echo m68k-unknown-lynxos"$UNAME_RELEASE"
        exit ;;
     mc68030:UNIX_System_V:4.*:*)
        echo m68k-atari-sysv4
        exit ;;
     TSUNAMI:LynxOS:2.*:*)
-       echo sparc-unknown-lynxos${UNAME_RELEASE}
+       echo sparc-unknown-lynxos"$UNAME_RELEASE"
        exit ;;
     rs6000:LynxOS:2.*:*)
-       echo rs6000-unknown-lynxos${UNAME_RELEASE}
+       echo rs6000-unknown-lynxos"$UNAME_RELEASE"
        exit ;;
     PowerPC:LynxOS:2.*:* | PowerPC:LynxOS:3.[01]*:* | PowerPC:LynxOS:4.[02]*:*)
-       echo powerpc-unknown-lynxos${UNAME_RELEASE}
+       echo powerpc-unknown-lynxos"$UNAME_RELEASE"
        exit ;;
     SM[BE]S:UNIX_SV:*:*)
-       echo mips-dde-sysv${UNAME_RELEASE}
+       echo mips-dde-sysv"$UNAME_RELEASE"
        exit ;;
     RM*:ReliantUNIX-*:*:*)
        echo mips-sni-sysv4
@@ -1191,7 +1202,7 @@ EOF
     *:SINIX-*:*:*)
        if uname -p 2>/dev/null >/dev/null ; then
                UNAME_MACHINE=`(uname -p) 2>/dev/null`
-               echo ${UNAME_MACHINE}-sni-sysv4
+               echo "$UNAME_MACHINE"-sni-sysv4
        else
                echo ns32k-sni-sysv
        fi
@@ -1211,23 +1222,23 @@ EOF
        exit ;;
     i*86:VOS:*:*)
        # From Paul.Green@stratus.com.
-       echo ${UNAME_MACHINE}-stratus-vos
+       echo "$UNAME_MACHINE"-stratus-vos
        exit ;;
     *:VOS:*:*)
        # From Paul.Green@stratus.com.
        echo hppa1.1-stratus-vos
        exit ;;
     mc68*:A/UX:*:*)
-       echo m68k-apple-aux${UNAME_RELEASE}
+       echo m68k-apple-aux"$UNAME_RELEASE"
        exit ;;
     news*:NEWS-OS:6*:*)
        echo mips-sony-newsos6
        exit ;;
     R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*)
        if [ -d /usr/nec ]; then
-               echo mips-nec-sysv${UNAME_RELEASE}
+               echo mips-nec-sysv"$UNAME_RELEASE"
        else
-               echo mips-unknown-sysv${UNAME_RELEASE}
+               echo mips-unknown-sysv"$UNAME_RELEASE"
        fi
        exit ;;
     BeBox:BeOS:*:*)    # BeOS running on hardware made by Be, PPC only.
@@ -1246,46 +1257,56 @@ EOF
        echo x86_64-unknown-haiku
        exit ;;
     SX-4:SUPER-UX:*:*)
-       echo sx4-nec-superux${UNAME_RELEASE}
+       echo sx4-nec-superux"$UNAME_RELEASE"
        exit ;;
     SX-5:SUPER-UX:*:*)
-       echo sx5-nec-superux${UNAME_RELEASE}
+       echo sx5-nec-superux"$UNAME_RELEASE"
        exit ;;
     SX-6:SUPER-UX:*:*)
-       echo sx6-nec-superux${UNAME_RELEASE}
+       echo sx6-nec-superux"$UNAME_RELEASE"
        exit ;;
     SX-7:SUPER-UX:*:*)
-       echo sx7-nec-superux${UNAME_RELEASE}
+       echo sx7-nec-superux"$UNAME_RELEASE"
        exit ;;
     SX-8:SUPER-UX:*:*)
-       echo sx8-nec-superux${UNAME_RELEASE}
+       echo sx8-nec-superux"$UNAME_RELEASE"
        exit ;;
     SX-8R:SUPER-UX:*:*)
-       echo sx8r-nec-superux${UNAME_RELEASE}
+       echo sx8r-nec-superux"$UNAME_RELEASE"
+       exit ;;
+    SX-ACE:SUPER-UX:*:*)
+       echo sxace-nec-superux"$UNAME_RELEASE"
        exit ;;
     Power*:Rhapsody:*:*)
-       echo powerpc-apple-rhapsody${UNAME_RELEASE}
+       echo powerpc-apple-rhapsody"$UNAME_RELEASE"
        exit ;;
     *:Rhapsody:*:*)
-       echo ${UNAME_MACHINE}-apple-rhapsody${UNAME_RELEASE}
+       echo "$UNAME_MACHINE"-apple-rhapsody"$UNAME_RELEASE"
        exit ;;
     *:Darwin:*:*)
        UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown
-       eval $set_cc_for_build
+       eval "$set_cc_for_build"
        if test "$UNAME_PROCESSOR" = unknown ; then
            UNAME_PROCESSOR=powerpc
        fi
-       if test `echo "$UNAME_RELEASE" | sed -e 's/\..*//'` -le 10 ; then
-           if [ "$CC_FOR_BUILD" != 'no_compiler_found' ]; then
+       if test "`echo "$UNAME_RELEASE" | sed -e 's/\..*//'`" -le 10 ; then
+           if [ "$CC_FOR_BUILD" != no_compiler_found ]; then
                if (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \
-                   (CCOPTS= $CC_FOR_BUILD -E - 2>/dev/null) | \
-                   grep IS_64BIT_ARCH >/dev/null
+                      (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \
+                      grep IS_64BIT_ARCH >/dev/null
                then
                    case $UNAME_PROCESSOR in
                        i386) UNAME_PROCESSOR=x86_64 ;;
                        powerpc) UNAME_PROCESSOR=powerpc64 ;;
                    esac
                fi
+               # On 10.4-10.6 one might compile for PowerPC via gcc -arch ppc
+               if (echo '#ifdef __POWERPC__'; echo IS_PPC; echo '#endif') | \
+                      (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \
+                      grep IS_PPC >/dev/null
+               then
+                   UNAME_PROCESSOR=powerpc
+               fi
            fi
        elif test "$UNAME_PROCESSOR" = i386 ; then
            # Avoid executing cc on OS X 10.9, as it ships with a stub
@@ -1296,27 +1317,33 @@ EOF
            # that Apple uses in portable devices.
            UNAME_PROCESSOR=x86_64
        fi
-       echo ${UNAME_PROCESSOR}-apple-darwin${UNAME_RELEASE}
+       echo "$UNAME_PROCESSOR"-apple-darwin"$UNAME_RELEASE"
        exit ;;
     *:procnto*:*:* | *:QNX:[0123456789]*:*)
        UNAME_PROCESSOR=`uname -p`
-       if test "$UNAME_PROCESSOR" = "x86"; then
+       if test "$UNAME_PROCESSOR" = x86; then
                UNAME_PROCESSOR=i386
                UNAME_MACHINE=pc
        fi
-       echo ${UNAME_PROCESSOR}-${UNAME_MACHINE}-nto-qnx${UNAME_RELEASE}
+       echo "$UNAME_PROCESSOR"-"$UNAME_MACHINE"-nto-qnx"$UNAME_RELEASE"
        exit ;;
     *:QNX:*:4*)
        echo i386-pc-qnx
        exit ;;
-    NEO-?:NONSTOP_KERNEL:*:*)
-       echo neo-tandem-nsk${UNAME_RELEASE}
+    NEO-*:NONSTOP_KERNEL:*:*)
+       echo neo-tandem-nsk"$UNAME_RELEASE"
        exit ;;
     NSE-*:NONSTOP_KERNEL:*:*)
-       echo nse-tandem-nsk${UNAME_RELEASE}
+       echo nse-tandem-nsk"$UNAME_RELEASE"
+       exit ;;
+    NSR-*:NONSTOP_KERNEL:*:*)
+       echo nsr-tandem-nsk"$UNAME_RELEASE"
        exit ;;
-    NSR-?:NONSTOP_KERNEL:*:*)
-       echo nsr-tandem-nsk${UNAME_RELEASE}
+    NSV-*:NONSTOP_KERNEL:*:*)
+       echo nsv-tandem-nsk"$UNAME_RELEASE"
+       exit ;;
+    NSX-*:NONSTOP_KERNEL:*:*)
+       echo nsx-tandem-nsk"$UNAME_RELEASE"
        exit ;;
     *:NonStop-UX:*:*)
        echo mips-compaq-nonstopux
@@ -1325,18 +1352,18 @@ EOF
        echo bs2000-siemens-sysv
        exit ;;
     DS/*:UNIX_System_V:*:*)
-       echo ${UNAME_MACHINE}-${UNAME_SYSTEM}-${UNAME_RELEASE}
+       echo "$UNAME_MACHINE"-"$UNAME_SYSTEM"-"$UNAME_RELEASE"
        exit ;;
     *:Plan9:*:*)
        # "uname -m" is not consistent, so use $cputype instead. 386
        # is converted to i386 for consistency with other x86
        # operating systems.
-       if test "$cputype" = "386"; then
+       if test "$cputype" = 386; then
            UNAME_MACHINE=i386
        else
            UNAME_MACHINE="$cputype"
        fi
-       echo ${UNAME_MACHINE}-unknown-plan9
+       echo "$UNAME_MACHINE"-unknown-plan9
        exit ;;
     *:TOPS-10:*:*)
        echo pdp10-unknown-tops10
@@ -1357,14 +1384,14 @@ EOF
        echo pdp10-unknown-its
        exit ;;
     SEI:*:*:SEIUX)
-       echo mips-sei-seiux${UNAME_RELEASE}
+       echo mips-sei-seiux"$UNAME_RELEASE"
        exit ;;
     *:DragonFly:*:*)
-       echo ${UNAME_MACHINE}-unknown-dragonfly`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'`
+       echo "$UNAME_MACHINE"-unknown-dragonfly"`echo "$UNAME_RELEASE"|sed -e 's/[-(].*//'`"
        exit ;;
     *:*VMS:*:*)
        UNAME_MACHINE=`(uname -p) 2>/dev/null`
-       case "${UNAME_MACHINE}" in
+       case "$UNAME_MACHINE" in
            A*) echo alpha-dec-vms ; exit ;;
            I*) echo ia64-dec-vms ; exit ;;
            V*) echo vax-dec-vms ; exit ;;
@@ -1373,34 +1400,48 @@ EOF
        echo i386-pc-xenix
        exit ;;
     i*86:skyos:*:*)
-       echo ${UNAME_MACHINE}-pc-skyos`echo ${UNAME_RELEASE}` | sed -e 's/ .*$//'
+       echo "$UNAME_MACHINE"-pc-skyos"`echo "$UNAME_RELEASE" | sed -e 's/ .*$//'`"
        exit ;;
     i*86:rdos:*:*)
-       echo ${UNAME_MACHINE}-pc-rdos
+       echo "$UNAME_MACHINE"-pc-rdos
        exit ;;
     i*86:AROS:*:*)
-       echo ${UNAME_MACHINE}-pc-aros
+       echo "$UNAME_MACHINE"-pc-aros
        exit ;;
     x86_64:VMkernel:*:*)
-       echo ${UNAME_MACHINE}-unknown-esx
+       echo "$UNAME_MACHINE"-unknown-esx
+       exit ;;
+    amd64:Isilon\ OneFS:*:*)
+       echo x86_64-unknown-onefs
        exit ;;
 esac
 
+echo "$0: unable to guess system type" >&2
+
+case "$UNAME_MACHINE:$UNAME_SYSTEM" in
+    mips:Linux | mips64:Linux)
+       # If we got here on MIPS GNU/Linux, output extra information.
+       cat >&2 <<EOF
+
+NOTE: MIPS GNU/Linux systems require a C compiler to fully recognize
+the system type. Please install a C compiler and try again.
+EOF
+       ;;
+esac
+
 cat >&2 <<EOF
-$0: unable to guess system type
 
-This script, last modified $timestamp, has failed to recognize
-the operating system you are using. It is advised that you
-download the most up to date version of the config scripts from
+This script (version $timestamp), has failed to recognize the
+operating system you are using. If your script is old, overwrite *all*
+copies of config.guess and config.sub with the latest versions from:
 
-  http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess;hb=HEAD
+  https://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess
 and
-  http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub;hb=HEAD
+  https://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub
 
-If the version you run ($0) is already up to date, please
-send the following data and any information you think might be
-pertinent to <config-patches@gnu.org> in order to provide the needed
-information to handle your system.
+If $0 has already been updated, send the following data and any
+information you think might be pertinent to config-patches@gnu.org to
+provide the necessary information to handle your system.
 
 config.guess timestamp = $timestamp
 
@@ -1419,16 +1460,16 @@ hostinfo               = `(hostinfo) 2>/dev/null`
 /usr/bin/oslevel       = `(/usr/bin/oslevel) 2>/dev/null`
 /usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null`
 
-UNAME_MACHINE = ${UNAME_MACHINE}
-UNAME_RELEASE = ${UNAME_RELEASE}
-UNAME_SYSTEM  = ${UNAME_SYSTEM}
-UNAME_VERSION = ${UNAME_VERSION}
+UNAME_MACHINE = "$UNAME_MACHINE"
+UNAME_RELEASE = "$UNAME_RELEASE"
+UNAME_SYSTEM  = "$UNAME_SYSTEM"
+UNAME_VERSION = "$UNAME_VERSION"
 EOF
 
 exit 1
 
 # Local variables:
-# eval: (add-hook 'write-file-hooks 'time-stamp)
+# eval: (add-hook 'before-save-hook 'time-stamp)
 # time-stamp-start: "timestamp='"
 # time-stamp-format: "%:y-%02m-%02d"
 # time-stamp-end: "'"
index 40aacda..f23a6f8 100644 (file)
@@ -1,4 +1,4 @@
-/* config.h.in.  Generated from configure.in by autoheader.  */
+/* config.h.in.  Generated from configure.ac by autoheader.  */
 
 /* define if you want to build the possibly-buggy SMB printer */
 #undef ENABLE_SMB
@@ -28,9 +28,6 @@
    don't. */
 #undef HAVE_DECL_ETHER_NTOHOST
 
-/* define if you have the dnet_htoa function */
-#undef HAVE_DNET_HTOA
-
 /* Define to 1 if you have the `ether_ntohost' function. */
 #undef HAVE_ETHER_NTOHOST
 
 /* Define to 1 if you have the <memory.h> header file. */
 #undef HAVE_MEMORY_H
 
-/* Define to 1 if you have the <netdnet/dnetdb.h> header file. */
-#undef HAVE_NETDNET_DNETDB_H
-
-/* define if you have a dnet_htoa declaration in <netdnet/dnetdb.h> */
-#undef HAVE_NETDNET_DNETDB_H_DNET_HTOA
-
 /* Define to 1 if you have the <netinet/ether.h> header file. */
 #undef HAVE_NETINET_ETHER_H
 
old mode 100644 (file)
new mode 100755 (executable)
index bc855a2..c95acc6
@@ -1,8 +1,8 @@
 #! /bin/sh
 # Configuration validation subroutine script.
-#   Copyright 1992-2015 Free Software Foundation, Inc.
+#   Copyright 1992-2018 Free Software Foundation, Inc.
 
-timestamp='2015-02-22'
+timestamp='2018-07-03'
 
 # This file is free software; you can redistribute it and/or modify it
 # under the terms of the GNU General Public License as published by
@@ -15,7 +15,7 @@ timestamp='2015-02-22'
 # General Public License for more details.
 #
 # You should have received a copy of the GNU General Public License
-# along with this program; if not, see <http://www.gnu.org/licenses/>.
+# along with this program; if not, see <https://www.gnu.org/licenses/>.
 #
 # As a special exception to the GNU General Public License, if you
 # distribute this file as part of a program that contains a
@@ -33,7 +33,7 @@ timestamp='2015-02-22'
 # Otherwise, we print the canonical config type on stdout and succeed.
 
 # You can get the latest version of this script from:
-# http://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub;hb=HEAD
+# https://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub
 
 # This file is supposed to be the same for all GNU packages
 # and recognize all the CPU types, system types and aliases
@@ -53,12 +53,11 @@ timestamp='2015-02-22'
 me=`echo "$0" | sed -e 's,.*/,,'`
 
 usage="\
-Usage: $0 [OPTION] CPU-MFR-OPSYS
-       $0 [OPTION] ALIAS
+Usage: $0 [OPTION] CPU-MFR-OPSYS or ALIAS
 
 Canonicalize a configuration name.
 
-Operation modes:
+Options:
   -h, --help         print this help, then exit
   -t, --time-stamp   print date of last modification, then exit
   -v, --version      print version number, then exit
@@ -68,7 +67,7 @@ Report bugs and patches to <config-patches@gnu.org>."
 version="\
 GNU config.sub ($timestamp)
 
-Copyright 1992-2015 Free Software Foundation, Inc.
+Copyright 1992-2018 Free Software Foundation, Inc.
 
 This is free software; see the source for copying conditions.  There is NO
 warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
@@ -95,7 +94,7 @@ while test $# -gt 0 ; do
 
     *local*)
        # First pass through any local machine types.
-       echo $1
+       echo "$1"
        exit ;;
 
     * )
@@ -111,134 +110,455 @@ case $# in
     exit 1;;
 esac
 
-# Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any).
-# Here we must recognize all the valid KERNEL-OS combinations.
-maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'`
-case $maybe_os in
-  nto-qnx* | linux-gnu* | linux-android* | linux-dietlibc | linux-newlib* | \
-  linux-musl* | linux-uclibc* | uclinux-uclibc* | uclinux-gnu* | kfreebsd*-gnu* | \
-  knetbsd*-gnu* | netbsd*-gnu* | netbsd*-eabi* | \
-  kopensolaris*-gnu* | \
-  storm-chaos* | os2-emx* | rtmk-nova*)
-    os=-$maybe_os
-    basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`
-    ;;
-  android-linux)
-    os=-linux-android
-    basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'`-unknown
-    ;;
-  *)
-    basic_machine=`echo $1 | sed 's/-[^-]*$//'`
-    if [ $basic_machine != $1 ]
-    then os=`echo $1 | sed 's/.*-/-/'`
-    else os=; fi
-    ;;
-esac
+# Split fields of configuration type
+IFS="-" read -r field1 field2 field3 field4 <<EOF
+$1
+EOF
 
-### Let's recognize common machines as not being operating systems so
-### that things like config.sub decstation-3100 work.  We also
-### recognize some manufacturers as not being operating systems, so we
-### can provide default operating systems below.
-case $os in
-       -sun*os*)
-               # Prevent following clause from handling this invalid input.
-               ;;
-       -dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \
-       -att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \
-       -unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \
-       -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\
-       -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \
-       -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \
-       -apple | -axis | -knuth | -cray | -microblaze*)
-               os=
-               basic_machine=$1
-               ;;
-       -bluegene*)
-               os=-cnk
-               ;;
-       -sim | -cisco | -oki | -wec | -winbond)
-               os=
-               basic_machine=$1
-               ;;
-       -scout)
-               ;;
-       -wrs)
-               os=-vxworks
-               basic_machine=$1
-               ;;
-       -chorusos*)
-               os=-chorusos
-               basic_machine=$1
-               ;;
-       -chorusrdb)
-               os=-chorusrdb
-               basic_machine=$1
-               ;;
-       -hiux*)
-               os=-hiuxwe2
-               ;;
-       -sco6)
-               os=-sco5v6
-               basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
-               ;;
-       -sco5)
-               os=-sco3.2v5
-               basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
-               ;;
-       -sco4)
-               os=-sco3.2v4
-               basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
-               ;;
-       -sco3.2.[4-9]*)
-               os=`echo $os | sed -e 's/sco3.2./sco3.2v/'`
-               basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
-               ;;
-       -sco3.2v[4-9]*)
-               # Don't forget version if it is 3.2v4 or newer.
-               basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
-               ;;
-       -sco5v6*)
-               # Don't forget version if it is 3.2v4 or newer.
-               basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
-               ;;
-       -sco*)
-               os=-sco3.2v2
-               basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
-               ;;
-       -udk*)
-               basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
-               ;;
-       -isc)
-               os=-isc2.2
-               basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
-               ;;
-       -clix*)
-               basic_machine=clipper-intergraph
-               ;;
-       -isc*)
-               basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'`
-               ;;
-       -lynx*178)
-               os=-lynxos178
-               ;;
-       -lynx*5)
-               os=-lynxos5
-               ;;
-       -lynx*)
-               os=-lynxos
+# Separate into logical components for further validation
+case $1 in
+       *-*-*-*-*)
+               echo Invalid configuration \`"$1"\': more than four components >&2
+               exit 1
                ;;
-       -ptx*)
-               basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'`
+       *-*-*-*)
+               basic_machine=$field1-$field2
+               os=$field3-$field4
                ;;
-       -windowsnt*)
-               os=`echo $os | sed -e 's/windowsnt/winnt/'`
+       *-*-*)
+               # Ambiguous whether COMPANY is present, or skipped and KERNEL-OS is two
+               # parts
+               maybe_os=$field2-$field3
+               case $maybe_os in
+                       nto-qnx* | linux-gnu* | linux-android* | linux-dietlibc \
+                       | linux-newlib* | linux-musl* | linux-uclibc* | uclinux-uclibc* \
+                       | uclinux-gnu* | kfreebsd*-gnu* | knetbsd*-gnu* | netbsd*-gnu* \
+                       | netbsd*-eabi* | kopensolaris*-gnu* | cloudabi*-eabi* \
+                       | storm-chaos* | os2-emx* | rtmk-nova*)
+                               basic_machine=$field1
+                               os=$maybe_os
+                               ;;
+                       android-linux)
+                               basic_machine=$field1-unknown
+                               os=linux-android
+                               ;;
+                       *)
+                               basic_machine=$field1-$field2
+                               os=$field3
+                               ;;
+               esac
                ;;
-       -psos*)
-               os=-psos
+       *-*)
+               # Second component is usually, but not always the OS
+               case $field2 in
+                       # Prevent following clause from handling this valid os
+                       sun*os*)
+                               basic_machine=$field1
+                               os=$field2
+                               ;;
+                       # Manufacturers
+                       dec* | mips* | sequent* | encore* | pc532* | sgi* | sony* \
+                       | att* | 7300* | 3300* | delta* | motorola* | sun[234]* \
+                       | unicom* | ibm* | next | hp | isi* | apollo | altos* \
+                       | convergent* | ncr* | news | 32* | 3600* | 3100* | hitachi* \
+                       | c[123]* | convex* | sun | crds | omron* | dg | ultra | tti* \
+                       | harris | dolphin | highlevel | gould | cbm | ns | masscomp \
+                       | apple | axis | knuth | cray | microblaze* \
+                       | sim | cisco | oki | wec | wrs | winbond)
+                               basic_machine=$field1-$field2
+                               os=
+                               ;;
+                       *)
+                               basic_machine=$field1
+                               os=$field2
+                               ;;
+               esac
                ;;
-       -mint | -mint[0-9]*)
-               basic_machine=m68k-atari
-               os=-mint
+       *)
+               # Convert single-component short-hands not valid as part of
+               # multi-component configurations.
+               case $field1 in
+                       386bsd)
+                               basic_machine=i386-pc
+                               os=bsd
+                               ;;
+                       a29khif)
+                               basic_machine=a29k-amd
+                               os=udi
+                               ;;
+                       adobe68k)
+                               basic_machine=m68010-adobe
+                               os=scout
+                               ;;
+                       am29k)
+                               basic_machine=a29k-none
+                               os=bsd
+                               ;;
+                       amdahl)
+                               basic_machine=580-amdahl
+                               os=sysv
+                               ;;
+                       amigaos | amigados)
+                               basic_machine=m68k-unknown
+                               os=amigaos
+                               ;;
+                       amigaunix | amix)
+                               basic_machine=m68k-unknown
+                               os=sysv4
+                               ;;
+                       apollo68)
+                               basic_machine=m68k-apollo
+                               os=sysv
+                               ;;
+                       apollo68bsd)
+                               basic_machine=m68k-apollo
+                               os=bsd
+                               ;;
+                       aros)
+                               basic_machine=i386-pc
+                               os=aros
+                               ;;
+                       aux)
+                               basic_machine=m68k-apple
+                               os=aux
+                               ;;
+                       balance)
+                               basic_machine=ns32k-sequent
+                               os=dynix
+                               ;;
+                       blackfin)
+                               basic_machine=bfin-unknown
+                               os=linux
+                               ;;
+                       cegcc)
+                               basic_machine=arm-unknown
+                               os=cegcc
+                               ;;
+                       cray)
+                               basic_machine=j90-cray
+                               os=unicos
+                               ;;
+                       craynv)
+                               basic_machine=craynv-cray
+                               os=unicosmp
+                               ;;
+                       delta88)
+                               basic_machine=m88k-motorola
+                               os=sysv3
+                               ;;
+                       dicos)
+                               basic_machine=i686-pc
+                               os=dicos
+                               ;;
+                       djgpp)
+                               basic_machine=i586-pc
+                               os=msdosdjgpp
+                               ;;
+                       ebmon29k)
+                               basic_machine=a29k-amd
+                               os=ebmon
+                               ;;
+                       es1800 | OSE68k | ose68k | ose | OSE)
+                               basic_machine=m68k-ericsson
+                               os=ose
+                               ;;
+                       gmicro)
+                               basic_machine=tron-gmicro
+                               os=sysv
+                               ;;
+                       go32)
+                               basic_machine=i386-pc
+                               os=go32
+                               ;;
+                       h8300hms)
+                               basic_machine=h8300-hitachi
+                               os=hms
+                               ;;
+                       h8300xray)
+                               basic_machine=h8300-hitachi
+                               os=xray
+                               ;;
+                       h8500hms)
+                               basic_machine=h8500-hitachi
+                               os=hms
+                               ;;
+                       harris)
+                               basic_machine=m88k-harris
+                               os=sysv3
+                               ;;
+                       hp300bsd)
+                               basic_machine=m68k-hp
+                               os=bsd
+                               ;;
+                       hp300hpux)
+                               basic_machine=m68k-hp
+                               os=hpux
+                               ;;
+                       hppaosf)
+                               basic_machine=hppa1.1-hp
+                               os=osf
+                               ;;
+                       hppro)
+                               basic_machine=hppa1.1-hp
+                               os=proelf
+                               ;;
+                       i386mach)
+                               basic_machine=i386-mach
+                               os=mach
+                               ;;
+                       vsta)
+                               basic_machine=i386-unknown
+                               os=vsta
+                               ;;
+                       isi68 | isi)
+                               basic_machine=m68k-isi
+                               os=sysv
+                               ;;
+                       m68knommu)
+                               basic_machine=m68k-unknown
+                               os=linux
+                               ;;
+                       magnum | m3230)
+                               basic_machine=mips-mips
+                               os=sysv
+                               ;;
+                       merlin)
+                               basic_machine=ns32k-utek
+                               os=sysv
+                               ;;
+                       mingw64)
+                               basic_machine=x86_64-pc
+                               os=mingw64
+                               ;;
+                       mingw32)
+                               basic_machine=i686-pc
+                               os=mingw32
+                               ;;
+                       mingw32ce)
+                               basic_machine=arm-unknown
+                               os=mingw32ce
+                               ;;
+                       monitor)
+                               basic_machine=m68k-rom68k
+                               os=coff
+                               ;;
+                       morphos)
+                               basic_machine=powerpc-unknown
+                               os=morphos
+                               ;;
+                       moxiebox)
+                               basic_machine=moxie-unknown
+                               os=moxiebox
+                               ;;
+                       msdos)
+                               basic_machine=i386-pc
+                               os=msdos
+                               ;;
+                       msys)
+                               basic_machine=i686-pc
+                               os=msys
+                               ;;
+                       mvs)
+                               basic_machine=i370-ibm
+                               os=mvs
+                               ;;
+                       nacl)
+                               basic_machine=le32-unknown
+                               os=nacl
+                               ;;
+                       ncr3000)
+                               basic_machine=i486-ncr
+                               os=sysv4
+                               ;;
+                       netbsd386)
+                               basic_machine=i386-unknown
+                               os=netbsd
+                               ;;
+                       netwinder)
+                               basic_machine=armv4l-rebel
+                               os=linux
+                               ;;
+                       news | news700 | news800 | news900)
+                               basic_machine=m68k-sony
+                               os=newsos
+                               ;;
+                       news1000)
+                               basic_machine=m68030-sony
+                               os=newsos
+                               ;;
+                       necv70)
+                               basic_machine=v70-nec
+                               os=sysv
+                               ;;
+                       nh3000)
+                               basic_machine=m68k-harris
+                               os=cxux
+                               ;;
+                       nh[45]000)
+                               basic_machine=m88k-harris
+                               os=cxux
+                               ;;
+                       nindy960)
+                               basic_machine=i960-intel
+                               os=nindy
+                               ;;
+                       mon960)
+                               basic_machine=i960-intel
+                               os=mon960
+                               ;;
+                       nonstopux)
+                               basic_machine=mips-compaq
+                               os=nonstopux
+                               ;;
+                       os400)
+                               basic_machine=powerpc-ibm
+                               os=os400
+                               ;;
+                       OSE68000 | ose68000)
+                               basic_machine=m68000-ericsson
+                               os=ose
+                               ;;
+                       os68k)
+                               basic_machine=m68k-none
+                               os=os68k
+                               ;;
+                       paragon)
+                               basic_machine=i860-intel
+                               os=osf
+                               ;;
+                       parisc)
+                               basic_machine=hppa-unknown
+                               os=linux
+                               ;;
+                       pw32)
+                               basic_machine=i586-unknown
+                               os=pw32
+                               ;;
+                       rdos | rdos64)
+                               basic_machine=x86_64-pc
+                               os=rdos
+                               ;;
+                       rdos32)
+                               basic_machine=i386-pc
+                               os=rdos
+                               ;;
+                       rom68k)
+                               basic_machine=m68k-rom68k
+                               os=coff
+                               ;;
+                       sa29200)
+                               basic_machine=a29k-amd
+                               os=udi
+                               ;;
+                       sei)
+                               basic_machine=mips-sei
+                               os=seiux
+                               ;;
+                       sps7)
+                               basic_machine=m68k-bull
+                               os=sysv2
+                               ;;
+                       stratus)
+                               basic_machine=i860-stratus
+                               os=sysv4
+                               ;;
+                       sun2os3)
+                               basic_machine=m68000-sun
+                               os=sunos3
+                               ;;
+                       sun2os4)
+                               basic_machine=m68000-sun
+                               os=sunos4
+                               ;;
+                       sun3os3)
+                               basic_machine=m68k-sun
+                               os=sunos3
+                               ;;
+                       sun3os4)
+                               basic_machine=m68k-sun
+                               os=sunos4
+                               ;;
+                       sun4os3)
+                               basic_machine=sparc-sun
+                               os=sunos3
+                               ;;
+                       sun4os4)
+                               basic_machine=sparc-sun
+                               os=sunos4
+                               ;;
+                       sun4sol2)
+                               basic_machine=sparc-sun
+                               os=solaris2
+                               ;;
+                       sv1)
+                               basic_machine=sv1-cray
+                               os=unicos
+                               ;;
+                       symmetry)
+                               basic_machine=i386-sequent
+                               os=dynix
+                               ;;
+                       t3e)
+                               basic_machine=alphaev5-cray
+                               os=unicos
+                               ;;
+                       t90)
+                               basic_machine=t90-cray
+                               os=unicos
+                               ;;
+                       toad1)
+                               basic_machine=pdp10-xkl
+                               os=tops20
+                               ;;
+                       tpf)
+                               basic_machine=s390x-ibm
+                               os=tpf
+                               ;;
+                       udi29k)
+                               basic_machine=a29k-amd
+                               os=udi
+                               ;;
+                       ultra3)
+                               basic_machine=a29k-nyu
+                               os=sym1
+                               ;;
+                       v810 | necv810)
+                               basic_machine=v810-nec
+                               os=none
+                               ;;
+                       vaxv)
+                               basic_machine=vax-dec
+                               os=sysv
+                               ;;
+                       vms)
+                               basic_machine=vax-dec
+                               os=vms
+                               ;;
+                       vxworks960)
+                               basic_machine=i960-wrs
+                               os=vxworks
+                               ;;
+                       vxworks68)
+                               basic_machine=m68k-wrs
+                               os=vxworks
+                               ;;
+                       vxworks29k)
+                               basic_machine=a29k-wrs
+                               os=vxworks
+                               ;;
+                       xbox)
+                               basic_machine=i686-pc
+                               os=mingw32
+                               ;;
+                       ymp)
+                               basic_machine=ymp-cray
+                               os=unicos
+                               ;;
+                       *)
+                               basic_machine=$1
+                               os=
+                               ;;
+               esac
                ;;
 esac
 
@@ -253,17 +573,18 @@ case $basic_machine in
        | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] | alpha64pca5[67] \
        | am33_2.0 \
        | arc | arceb \
-       | arm | arm[bl]e | arme[lb] | armv[2-8] | armv[3-8][lb] | armv7[arm] \
+       | arm | arm[bl]e | arme[lb] | armv[2-8] | armv[3-8][lb] | armv6m | armv[78][arm] \
        | avr | avr32 \
+       | ba \
        | be32 | be64 \
        | bfin \
-       | c4x | c8051 | clipper \
+       | c4x | c8051 | clipper | csky \
        | d10v | d30v | dlx | dsp16xx \
-       | epiphany \
+       | e2k | epiphany \
        | fido | fr30 | frv | ft32 \
        | h8300 | h8500 | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \
        | hexagon \
-       | i370 | i860 | i960 | ia64 \
+       | i370 | i860 | i960 | ia16 | ia64 \
        | ip2k | iq2000 \
        | k1om \
        | le32 | le64 \
@@ -296,16 +617,18 @@ case $basic_machine in
        | mt \
        | msp430 \
        | nds32 | nds32le | nds32be \
+       | nfp \
        | nios | nios2 | nios2eb | nios2el \
        | ns16k | ns32k \
        | open8 | or1k | or1knd | or32 \
-       | pdp10 | pdp11 | pj | pjl \
+       | pdp10 | pj | pjl \
        | powerpc | powerpc64 | powerpc64le | powerpcle \
+       | pru \
        | pyramid \
-       | riscv32 | riscv64 \
+       | riscv | riscv32 | riscv64 \
        | rl78 | rx \
        | score \
-       | sh | sh[1234] | sh[24]a | sh[24]aeb | sh[23]e | sh[34]eb | sheb | shbe | shle | sh[1234]le | sh3ele \
+       | sh | sh[1234] | sh[24]a | sh[24]aeb | sh[23]e | sh[234]eb | sheb | shbe | shle | sh[1234]le | sh3ele \
        | sh64 | sh64le \
        | sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet | sparclite \
        | sparcv8 | sparcv9 | sparcv9b | sparcv9v \
@@ -314,7 +637,7 @@ case $basic_machine in
        | ubicom32 \
        | v850 | v850e | v850e1 | v850e2 | v850es | v850e2v3 \
        | visium \
-       | we32k \
+       | wasm32 \
        | x86 | xc16x | xstormy16 | xtensa \
        | z8k | z80)
                basic_machine=$basic_machine-unknown
@@ -333,20 +656,23 @@ case $basic_machine in
                ;;
        m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x | nvptx | picochip)
                basic_machine=$basic_machine-unknown
-               os=-none
+               os=${os:-none}
+               ;;
+       m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65)
                ;;
-       m88110 | m680[12346]0 | m683?2 | m68360 | m5200 | v70 | w65 | z8k)
+       m9s12z | m68hcs12z | hcs12z | s12z)
+               basic_machine=s12z-unknown
+               os=${os:-none}
                ;;
        ms1)
                basic_machine=mt-unknown
                ;;
-
        strongarm | thumb | xscale)
                basic_machine=arm-unknown
                ;;
        xgate)
                basic_machine=$basic_machine-unknown
-               os=-none
+               os=${os:-none}
                ;;
        xscaleeb)
                basic_machine=armeb-unknown
@@ -362,11 +688,6 @@ case $basic_machine in
        i*86 | x86_64)
          basic_machine=$basic_machine-pc
          ;;
-       # Object if more than one company name word.
-       *-*-*)
-               echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2
-               exit 1
-               ;;
        # Recognize the basic CPU types with company name.
        580-* \
        | a29k-* \
@@ -376,17 +697,18 @@ case $basic_machine in
        | alphapca5[67]-* | alpha64pca5[67]-* | arc-* | arceb-* \
        | arm-*  | armbe-* | armle-* | armeb-* | armv*-* \
        | avr-* | avr32-* \
+       | ba-* \
        | be32-* | be64-* \
        | bfin-* | bs2000-* \
        | c[123]* | c30-* | [cjt]90-* | c4x-* \
-       | c8051-* | clipper-* | craynv-* | cydra-* \
+       | c8051-* | clipper-* | craynv-* | csky-* | cydra-* \
        | d10v-* | d30v-* | dlx-* \
-       | elxsi-* \
+       | e2k-* | elxsi-* \
        | f30[01]-* | f700-* | fido-* | fr30-* | frv-* | fx80-* \
        | h8300-* | h8500-* \
        | hppa-* | hppa1.[01]-* | hppa2.0-* | hppa2.0[nw]-* | hppa64-* \
        | hexagon-* \
-       | i*86-* | i860-* | i960-* | ia64-* \
+       | i*86-* | i860-* | i960-* | ia16-* | ia64-* \
        | ip2k-* | iq2000-* \
        | k1om-* \
        | le32-* | le64-* \
@@ -420,6 +742,7 @@ case $basic_machine in
        | mt-* \
        | msp430-* \
        | nds32-* | nds32le-* | nds32be-* \
+       | nfp-* \
        | nios-* | nios2-* | nios2eb-* | nios2el-* \
        | none-* | np1-* | ns16k-* | ns32k-* \
        | open8-* \
@@ -427,13 +750,15 @@ case $basic_machine in
        | orion-* \
        | pdp10-* | pdp11-* | pj-* | pjl-* | pn-* | power-* \
        | powerpc-* | powerpc64-* | powerpc64le-* | powerpcle-* \
+       | pru-* \
        | pyramid-* \
+       | riscv-* | riscv32-* | riscv64-* \
        | rl78-* | romp-* | rs6000-* | rx-* \
        | sh-* | sh[1234]-* | sh[24]a-* | sh[24]aeb-* | sh[23]e-* | sh[34]eb-* | sheb-* | shbe-* \
        | shle-* | sh[1234]le-* | sh3ele-* | sh64-* | sh64le-* \
        | sparc-* | sparc64-* | sparc64b-* | sparc64v-* | sparc86x-* | sparclet-* \
        | sparclite-* \
-       | sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | sv1-* | sx?-* \
+       | sparcv8-* | sparcv9-* | sparcv9b-* | sparcv9v-* | sv1-* | sx*-* \
        | tahoe-* \
        | tic30-* | tic4x-* | tic54x-* | tic55x-* | tic6x-* | tic80-* \
        | tile*-* \
@@ -442,6 +767,7 @@ case $basic_machine in
        | v850-* | v850e-* | v850e1-* | v850es-* | v850e2-* | v850e2v3-* \
        | vax-* \
        | visium-* \
+       | wasm32-* \
        | we32k-* \
        | x86-* | x86_64-* | xc16x-* | xps100-* \
        | xstormy16-* | xtensa*-* \
@@ -454,138 +780,77 @@ case $basic_machine in
                ;;
        # Recognize the various machine names and aliases which stand
        # for a CPU type and a company and sometimes even an OS.
-       386bsd)
-               basic_machine=i386-unknown
-               os=-bsd
-               ;;
        3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc)
                basic_machine=m68000-att
                ;;
        3b*)
                basic_machine=we32k-att
                ;;
-       a29khif)
-               basic_machine=a29k-amd
-               os=-udi
-               ;;
        abacus)
                basic_machine=abacus-unknown
                ;;
-       adobe68k)
-               basic_machine=m68010-adobe
-               os=-scout
-               ;;
        alliant | fx80)
                basic_machine=fx80-alliant
                ;;
        altos | altos3068)
                basic_machine=m68k-altos
                ;;
-       am29k)
-               basic_machine=a29k-none
-               os=-bsd
-               ;;
        amd64)
                basic_machine=x86_64-pc
                ;;
        amd64-*)
-               basic_machine=x86_64-`echo $basic_machine | sed 's/^[^-]*-//'`
-               ;;
-       amdahl)
-               basic_machine=580-amdahl
-               os=-sysv
+               basic_machine=x86_64-`echo "$basic_machine" | sed 's/^[^-]*-//'`
                ;;
        amiga | amiga-*)
                basic_machine=m68k-unknown
                ;;
-       amigaos | amigados)
-               basic_machine=m68k-unknown
-               os=-amigaos
-               ;;
-       amigaunix | amix)
-               basic_machine=m68k-unknown
-               os=-sysv4
-               ;;
-       apollo68)
-               basic_machine=m68k-apollo
-               os=-sysv
-               ;;
-       apollo68bsd)
-               basic_machine=m68k-apollo
-               os=-bsd
-               ;;
-       aros)
-               basic_machine=i386-pc
-               os=-aros
-               ;;
-       aux)
-               basic_machine=m68k-apple
-               os=-aux
-               ;;
-       balance)
-               basic_machine=ns32k-sequent
-               os=-dynix
-               ;;
-       blackfin)
-               basic_machine=bfin-unknown
-               os=-linux
+       asmjs)
+               basic_machine=asmjs-unknown
                ;;
        blackfin-*)
-               basic_machine=bfin-`echo $basic_machine | sed 's/^[^-]*-//'`
-               os=-linux
+               basic_machine=bfin-`echo "$basic_machine" | sed 's/^[^-]*-//'`
+               os=linux
                ;;
        bluegene*)
                basic_machine=powerpc-ibm
-               os=-cnk
+               os=cnk
                ;;
        c54x-*)
-               basic_machine=tic54x-`echo $basic_machine | sed 's/^[^-]*-//'`
+               basic_machine=tic54x-`echo "$basic_machine" | sed 's/^[^-]*-//'`
                ;;
        c55x-*)
-               basic_machine=tic55x-`echo $basic_machine | sed 's/^[^-]*-//'`
+               basic_machine=tic55x-`echo "$basic_machine" | sed 's/^[^-]*-//'`
                ;;
        c6x-*)
-               basic_machine=tic6x-`echo $basic_machine | sed 's/^[^-]*-//'`
+               basic_machine=tic6x-`echo "$basic_machine" | sed 's/^[^-]*-//'`
                ;;
        c90)
                basic_machine=c90-cray
-               os=-unicos
-               ;;
-       cegcc)
-               basic_machine=arm-unknown
-               os=-cegcc
+               os=${os:-unicos}
                ;;
        convex-c1)
                basic_machine=c1-convex
-               os=-bsd
+               os=bsd
                ;;
        convex-c2)
                basic_machine=c2-convex
-               os=-bsd
+               os=bsd
                ;;
        convex-c32)
                basic_machine=c32-convex
-               os=-bsd
+               os=bsd
                ;;
        convex-c34)
                basic_machine=c34-convex
-               os=-bsd
+               os=bsd
                ;;
        convex-c38)
                basic_machine=c38-convex
-               os=-bsd
-               ;;
-       cray | j90)
-               basic_machine=j90-cray
-               os=-unicos
-               ;;
-       craynv)
-               basic_machine=craynv-cray
-               os=-unicosmp
+               os=bsd
                ;;
        cr16 | cr16-*)
                basic_machine=cr16-unknown
-               os=-elf
+               os=${os:-elf}
                ;;
        crds | unos)
                basic_machine=m68k-crds
@@ -598,7 +863,7 @@ case $basic_machine in
                ;;
        crx)
                basic_machine=crx-unknown
-               os=-elf
+               os=${os:-elf}
                ;;
        da30 | da30-*)
                basic_machine=m68k-da30
@@ -608,50 +873,38 @@ case $basic_machine in
                ;;
        decsystem10* | dec10*)
                basic_machine=pdp10-dec
-               os=-tops10
+               os=tops10
                ;;
        decsystem20* | dec20*)
                basic_machine=pdp10-dec
-               os=-tops20
+               os=tops20
                ;;
        delta | 3300 | motorola-3300 | motorola-delta \
              | 3300-motorola | delta-motorola)
                basic_machine=m68k-motorola
                ;;
-       delta88)
-               basic_machine=m88k-motorola
-               os=-sysv3
-               ;;
-       dicos)
-               basic_machine=i686-pc
-               os=-dicos
-               ;;
-       djgpp)
-               basic_machine=i586-pc
-               os=-msdosdjgpp
-               ;;
        dpx20 | dpx20-*)
                basic_machine=rs6000-bull
-               os=-bosx
+               os=${os:-bosx}
                ;;
-       dpx2* | dpx2*-bull)
+       dpx2*)
                basic_machine=m68k-bull
-               os=-sysv3
+               os=sysv3
                ;;
-       ebmon29k)
-               basic_machine=a29k-amd
-               os=-ebmon
+       e500v[12])
+               basic_machine=powerpc-unknown
+               os=$os"spe"
                ;;
-       elxsi)
-               basic_machine=elxsi-elxsi
-               os=-bsd
+       e500v[12]-*)
+               basic_machine=powerpc-`echo "$basic_machine" | sed 's/^[^-]*-//'`
+               os=$os"spe"
                ;;
        encore | umax | mmax)
                basic_machine=ns32k-encore
                ;;
-       es1800 | OSE68k | ose68k | ose | OSE)
-               basic_machine=m68k-ericsson
-               os=-ose
+       elxsi)
+               basic_machine=elxsi-elxsi
+               os=${os:-bsd}
                ;;
        fx2800)
                basic_machine=i860-alliant
@@ -659,45 +912,13 @@ case $basic_machine in
        genix)
                basic_machine=ns32k-ns
                ;;
-       gmicro)
-               basic_machine=tron-gmicro
-               os=-sysv
-               ;;
-       go32)
-               basic_machine=i386-pc
-               os=-go32
-               ;;
        h3050r* | hiux*)
                basic_machine=hppa1.1-hitachi
-               os=-hiuxwe2
-               ;;
-       h8300hms)
-               basic_machine=h8300-hitachi
-               os=-hms
-               ;;
-       h8300xray)
-               basic_machine=h8300-hitachi
-               os=-xray
-               ;;
-       h8500hms)
-               basic_machine=h8500-hitachi
-               os=-hms
-               ;;
-       harris)
-               basic_machine=m88k-harris
-               os=-sysv3
+               os=hiuxwe2
                ;;
        hp300-*)
                basic_machine=m68k-hp
                ;;
-       hp300bsd)
-               basic_machine=m68k-hp
-               os=-bsd
-               ;;
-       hp300hpux)
-               basic_machine=m68k-hp
-               os=-hpux
-               ;;
        hp3k9[0-9][0-9] | hp9[0-9][0-9])
                basic_machine=hppa1.0-hp
                ;;
@@ -727,200 +948,82 @@ case $basic_machine in
        hp9k8[0-9][0-9] | hp8[0-9][0-9])
                basic_machine=hppa1.0-hp
                ;;
-       hppa-next)
-               os=-nextstep3
-               ;;
-       hppaosf)
-               basic_machine=hppa1.1-hp
-               os=-osf
-               ;;
-       hppro)
-               basic_machine=hppa1.1-hp
-               os=-proelf
-               ;;
        i370-ibm* | ibm*)
                basic_machine=i370-ibm
                ;;
        i*86v32)
-               basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
-               os=-sysv32
+               basic_machine=`echo "$1" | sed -e 's/86.*/86-pc/'`
+               os=sysv32
                ;;
        i*86v4*)
-               basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
-               os=-sysv4
+               basic_machine=`echo "$1" | sed -e 's/86.*/86-pc/'`
+               os=sysv4
                ;;
        i*86v)
-               basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
-               os=-sysv
+               basic_machine=`echo "$1" | sed -e 's/86.*/86-pc/'`
+               os=sysv
                ;;
        i*86sol2)
-               basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'`
-               os=-solaris2
-               ;;
-       i386mach)
-               basic_machine=i386-mach
-               os=-mach
+               basic_machine=`echo "$1" | sed -e 's/86.*/86-pc/'`
+               os=solaris2
                ;;
-       i386-vsta | vsta)
-               basic_machine=i386-unknown
-               os=-vsta
+       j90 | j90-cray)
+               basic_machine=j90-cray
+               os=${os:-unicos}
                ;;
        iris | iris4d)
                basic_machine=mips-sgi
                case $os in
-                   -irix*)
+                   irix*)
                        ;;
                    *)
-                       os=-irix4
+                       os=irix4
                        ;;
                esac
                ;;
-       isi68 | isi)
-               basic_machine=m68k-isi
-               os=-sysv
-               ;;
        leon-*|leon[3-9]-*)
-               basic_machine=sparc-`echo $basic_machine | sed 's/-.*//'`
-               ;;
-       m68knommu)
-               basic_machine=m68k-unknown
-               os=-linux
+               basic_machine=sparc-`echo "$basic_machine" | sed 's/-.*//'`
                ;;
        m68knommu-*)
-               basic_machine=m68k-`echo $basic_machine | sed 's/^[^-]*-//'`
-               os=-linux
-               ;;
-       m88k-omron*)
-               basic_machine=m88k-omron
-               ;;
-       magnum | m3230)
-               basic_machine=mips-mips
-               os=-sysv
-               ;;
-       merlin)
-               basic_machine=ns32k-utek
-               os=-sysv
+               basic_machine=m68k-`echo "$basic_machine" | sed 's/^[^-]*-//'`
+               os=linux
                ;;
        microblaze*)
                basic_machine=microblaze-xilinx
                ;;
-       mingw64)
-               basic_machine=x86_64-pc
-               os=-mingw64
-               ;;
-       mingw32)
-               basic_machine=i686-pc
-               os=-mingw32
-               ;;
-       mingw32ce)
-               basic_machine=arm-unknown
-               os=-mingw32ce
-               ;;
        miniframe)
                basic_machine=m68000-convergent
                ;;
-       *mint | -mint[0-9]* | *MiNT | *MiNT[0-9]*)
+       *mint | mint[0-9]* | *MiNT | *MiNT[0-9]*)
                basic_machine=m68k-atari
-               os=-mint
+               os=mint
                ;;
        mips3*-*)
-               basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`
+               basic_machine=`echo "$basic_machine" | sed -e 's/mips3/mips64/'`
                ;;
        mips3*)
-               basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown
-               ;;
-       monitor)
-               basic_machine=m68k-rom68k
-               os=-coff
-               ;;
-       morphos)
-               basic_machine=powerpc-unknown
-               os=-morphos
-               ;;
-       moxiebox)
-               basic_machine=moxie-unknown
-               os=-moxiebox
-               ;;
-       msdos)
-               basic_machine=i386-pc
-               os=-msdos
+               basic_machine=`echo "$basic_machine" | sed -e 's/mips3/mips64/'`-unknown
                ;;
        ms1-*)
-               basic_machine=`echo $basic_machine | sed -e 's/ms1-/mt-/'`
-               ;;
-       msys)
-               basic_machine=i686-pc
-               os=-msys
-               ;;
-       mvs)
-               basic_machine=i370-ibm
-               os=-mvs
-               ;;
-       nacl)
-               basic_machine=le32-unknown
-               os=-nacl
-               ;;
-       ncr3000)
-               basic_machine=i486-ncr
-               os=-sysv4
-               ;;
-       netbsd386)
-               basic_machine=i386-unknown
-               os=-netbsd
-               ;;
-       netwinder)
-               basic_machine=armv4l-rebel
-               os=-linux
-               ;;
-       news | news700 | news800 | news900)
-               basic_machine=m68k-sony
-               os=-newsos
-               ;;
-       news1000)
-               basic_machine=m68030-sony
-               os=-newsos
+               basic_machine=`echo "$basic_machine" | sed -e 's/ms1-/mt-/'`
                ;;
        news-3600 | risc-news)
                basic_machine=mips-sony
-               os=-newsos
+               os=newsos
                ;;
-       necv70)
-               basic_machine=v70-nec
-               os=-sysv
-               ;;
-       next | m*-next )
+       next | m*-next)
                basic_machine=m68k-next
                case $os in
-                   -nextstep* )
+                   nextstep* )
                        ;;
-                   -ns2*)
-                     os=-nextstep2
+                   ns2*)
+                     os=nextstep2
                        ;;
                    *)
-                     os=-nextstep3
+                     os=nextstep3
                        ;;
                esac
                ;;
-       nh3000)
-               basic_machine=m68k-harris
-               os=-cxux
-               ;;
-       nh[45]000)
-               basic_machine=m88k-harris
-               os=-cxux
-               ;;
-       nindy960)
-               basic_machine=i960-intel
-               os=-nindy
-               ;;
-       mon960)
-               basic_machine=i960-intel
-               os=-mon960
-               ;;
-       nonstopux)
-               basic_machine=mips-compaq
-               os=-nonstopux
-               ;;
        np1)
                basic_machine=np1-gould
                ;;
@@ -933,40 +1036,26 @@ case $basic_machine in
        nsr-tandem)
                basic_machine=nsr-tandem
                ;;
+       nsv-tandem)
+               basic_machine=nsv-tandem
+               ;;
+       nsx-tandem)
+               basic_machine=nsx-tandem
+               ;;
        op50n-* | op60c-*)
                basic_machine=hppa1.1-oki
-               os=-proelf
+               os=proelf
                ;;
        openrisc | openrisc-*)
                basic_machine=or32-unknown
                ;;
-       os400)
-               basic_machine=powerpc-ibm
-               os=-os400
-               ;;
-       OSE68000 | ose68000)
-               basic_machine=m68000-ericsson
-               os=-ose
-               ;;
-       os68k)
-               basic_machine=m68k-none
-               os=-os68k
-               ;;
        pa-hitachi)
                basic_machine=hppa1.1-hitachi
-               os=-hiuxwe2
-               ;;
-       paragon)
-               basic_machine=i860-intel
-               os=-osf
-               ;;
-       parisc)
-               basic_machine=hppa-unknown
-               os=-linux
+               os=hiuxwe2
                ;;
        parisc-*)
-               basic_machine=hppa-`echo $basic_machine | sed 's/^[^-]*-//'`
-               os=-linux
+               basic_machine=hppa-`echo "$basic_machine" | sed 's/^[^-]*-//'`
+               os=linux
                ;;
        pbd)
                basic_machine=sparc-tti
@@ -981,7 +1070,7 @@ case $basic_machine in
                basic_machine=i386-pc
                ;;
        pc98-*)
-               basic_machine=i386-`echo $basic_machine | sed 's/^[^-]*-//'`
+               basic_machine=i386-`echo "$basic_machine" | sed 's/^[^-]*-//'`
                ;;
        pentium | p5 | k5 | k6 | nexgen | viac3)
                basic_machine=i586-pc
@@ -996,16 +1085,16 @@ case $basic_machine in
                basic_machine=i786-pc
                ;;
        pentium-* | p5-* | k5-* | k6-* | nexgen-* | viac3-*)
-               basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'`
+               basic_machine=i586-`echo "$basic_machine" | sed 's/^[^-]*-//'`
                ;;
        pentiumpro-* | p6-* | 6x86-* | athlon-*)
-               basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'`
+               basic_machine=i686-`echo "$basic_machine" | sed 's/^[^-]*-//'`
                ;;
        pentiumii-* | pentium2-* | pentiumiii-* | pentium3-*)
-               basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'`
+               basic_machine=i686-`echo "$basic_machine" | sed 's/^[^-]*-//'`
                ;;
        pentium4-*)
-               basic_machine=i786-`echo $basic_machine | sed 's/^[^-]*-//'`
+               basic_machine=i786-`echo "$basic_machine" | sed 's/^[^-]*-//'`
                ;;
        pn)
                basic_machine=pn-gould
@@ -1015,43 +1104,27 @@ case $basic_machine in
        ppc | ppcbe)    basic_machine=powerpc-unknown
                ;;
        ppc-* | ppcbe-*)
-               basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'`
+               basic_machine=powerpc-`echo "$basic_machine" | sed 's/^[^-]*-//'`
                ;;
-       ppcle | powerpclittle | ppc-le | powerpc-little)
+       ppcle | powerpclittle)
                basic_machine=powerpcle-unknown
                ;;
        ppcle-* | powerpclittle-*)
-               basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'`
+               basic_machine=powerpcle-`echo "$basic_machine" | sed 's/^[^-]*-//'`
                ;;
        ppc64)  basic_machine=powerpc64-unknown
                ;;
-       ppc64-*) basic_machine=powerpc64-`echo $basic_machine | sed 's/^[^-]*-//'`
+       ppc64-*) basic_machine=powerpc64-`echo "$basic_machine" | sed 's/^[^-]*-//'`
                ;;
-       ppc64le | powerpc64little | ppc64-le | powerpc64-little)
+       ppc64le | powerpc64little)
                basic_machine=powerpc64le-unknown
                ;;
        ppc64le-* | powerpc64little-*)
-               basic_machine=powerpc64le-`echo $basic_machine | sed 's/^[^-]*-//'`
+               basic_machine=powerpc64le-`echo "$basic_machine" | sed 's/^[^-]*-//'`
                ;;
        ps2)
                basic_machine=i386-ibm
                ;;
-       pw32)
-               basic_machine=i586-unknown
-               os=-pw32
-               ;;
-       rdos | rdos64)
-               basic_machine=x86_64-pc
-               os=-rdos
-               ;;
-       rdos32)
-               basic_machine=i386-pc
-               os=-rdos
-               ;;
-       rom68k)
-               basic_machine=m68k-rom68k
-               os=-coff
-               ;;
        rm[46]00)
                basic_machine=mips-siemens
                ;;
@@ -1064,10 +1137,6 @@ case $basic_machine in
        s390x | s390x-*)
                basic_machine=s390x-ibm
                ;;
-       sa29200)
-               basic_machine=a29k-amd
-               os=-udi
-               ;;
        sb1)
                basic_machine=mipsisa64sb1-unknown
                ;;
@@ -1076,32 +1145,17 @@ case $basic_machine in
                ;;
        sde)
                basic_machine=mipsisa32-sde
-               os=-elf
-               ;;
-       sei)
-               basic_machine=mips-sei
-               os=-seiux
+               os=${os:-elf}
                ;;
        sequent)
                basic_machine=i386-sequent
                ;;
-       sh)
-               basic_machine=sh-hitachi
-               os=-hms
-               ;;
        sh5el)
                basic_machine=sh5le-unknown
                ;;
-       sh64)
-               basic_machine=sh64-unknown
-               ;;
-       sparclite-wrs | simso-wrs)
+       simso-wrs)
                basic_machine=sparclite-wrs
-               os=-vxworks
-               ;;
-       sps7)
-               basic_machine=m68k-bull
-               os=-sysv2
+               os=vxworks
                ;;
        spur)
                basic_machine=spur-unknown
@@ -1109,44 +1163,12 @@ case $basic_machine in
        st2000)
                basic_machine=m68k-tandem
                ;;
-       stratus)
-               basic_machine=i860-stratus
-               os=-sysv4
-               ;;
        strongarm-* | thumb-*)
-               basic_machine=arm-`echo $basic_machine | sed 's/^[^-]*-//'`
+               basic_machine=arm-`echo "$basic_machine" | sed 's/^[^-]*-//'`
                ;;
        sun2)
                basic_machine=m68000-sun
                ;;
-       sun2os3)
-               basic_machine=m68000-sun
-               os=-sunos3
-               ;;
-       sun2os4)
-               basic_machine=m68000-sun
-               os=-sunos4
-               ;;
-       sun3os3)
-               basic_machine=m68k-sun
-               os=-sunos3
-               ;;
-       sun3os4)
-               basic_machine=m68k-sun
-               os=-sunos4
-               ;;
-       sun4os3)
-               basic_machine=sparc-sun
-               os=-sunos3
-               ;;
-       sun4os4)
-               basic_machine=sparc-sun
-               os=-sunos4
-               ;;
-       sun4sol2)
-               basic_machine=sparc-sun
-               os=-solaris2
-               ;;
        sun3 | sun3-*)
                basic_machine=m68k-sun
                ;;
@@ -1156,25 +1178,9 @@ case $basic_machine in
        sun386 | sun386i | roadrunner)
                basic_machine=i386-sun
                ;;
-       sv1)
-               basic_machine=sv1-cray
-               os=-unicos
-               ;;
-       symmetry)
-               basic_machine=i386-sequent
-               os=-dynix
-               ;;
-       t3e)
-               basic_machine=alphaev5-cray
-               os=-unicos
-               ;;
-       t90)
-               basic_machine=t90-cray
-               os=-unicos
-               ;;
        tile*)
                basic_machine=$basic_machine-unknown
-               os=-linux-gnu
+               os=linux-gnu
                ;;
        tx39)
                basic_machine=mipstx39-unknown
@@ -1182,85 +1188,32 @@ case $basic_machine in
        tx39el)
                basic_machine=mipstx39el-unknown
                ;;
-       toad1)
-               basic_machine=pdp10-xkl
-               os=-tops20
-               ;;
        tower | tower-32)
                basic_machine=m68k-ncr
                ;;
-       tpf)
-               basic_machine=s390x-ibm
-               os=-tpf
-               ;;
-       udi29k)
-               basic_machine=a29k-amd
-               os=-udi
-               ;;
-       ultra3)
-               basic_machine=a29k-nyu
-               os=-sym1
-               ;;
-       v810 | necv810)
-               basic_machine=v810-nec
-               os=-none
-               ;;
-       vaxv)
-               basic_machine=vax-dec
-               os=-sysv
-               ;;
-       vms)
-               basic_machine=vax-dec
-               os=-vms
-               ;;
        vpp*|vx|vx-*)
                basic_machine=f301-fujitsu
                ;;
-       vxworks960)
-               basic_machine=i960-wrs
-               os=-vxworks
-               ;;
-       vxworks68)
-               basic_machine=m68k-wrs
-               os=-vxworks
-               ;;
-       vxworks29k)
-               basic_machine=a29k-wrs
-               os=-vxworks
-               ;;
        w65*)
                basic_machine=w65-wdc
-               os=-none
+               os=none
                ;;
        w89k-*)
                basic_machine=hppa1.1-winbond
-               os=-proelf
+               os=proelf
                ;;
-       xbox)
-               basic_machine=i686-pc
-               os=-mingw32
+       x64)
+               basic_machine=x86_64-pc
                ;;
        xps | xps100)
                basic_machine=xps100-honeywell
                ;;
        xscale-* | xscalee[bl]-*)
-               basic_machine=`echo $basic_machine | sed 's/^xscale/arm/'`
-               ;;
-       ymp)
-               basic_machine=ymp-cray
-               os=-unicos
-               ;;
-       z8k-*-coff)
-               basic_machine=z8k-unknown
-               os=-sim
-               ;;
-       z80-*-coff)
-               basic_machine=z80-unknown
-               os=-sim
+               basic_machine=`echo "$basic_machine" | sed 's/^xscale/arm/'`
                ;;
        none)
                basic_machine=none-none
-               os=-none
+               os=${os:-none}
                ;;
 
 # Here we handle the default manufacturer of certain CPU types.  It is in
@@ -1286,10 +1239,6 @@ case $basic_machine in
        vax)
                basic_machine=vax-dec
                ;;
-       pdp10)
-               # there are many clones, so DEC is not a safe bet
-               basic_machine=pdp10-unknown
-               ;;
        pdp11)
                basic_machine=pdp11-dec
                ;;
@@ -1299,9 +1248,6 @@ case $basic_machine in
        sh[1234] | sh[24]a | sh[24]aeb | sh[34]eb | sh[1234]le | sh[23]ele)
                basic_machine=sh-unknown
                ;;
-       sparc | sparcv8 | sparcv9 | sparcv9b | sparcv9v)
-               basic_machine=sparc-sun
-               ;;
        cydra)
                basic_machine=cydra-cydrome
                ;;
@@ -1321,7 +1267,7 @@ case $basic_machine in
                # Make sure to match an already-canonicalized machine name.
                ;;
        *)
-               echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2
+               echo Invalid configuration \`"$1"\': machine \`"$basic_machine"\' not recognized 1>&2
                exit 1
                ;;
 esac
@@ -1329,10 +1275,10 @@ esac
 # Here we canonicalize certain aliases for manufacturers.
 case $basic_machine in
        *-digital*)
-               basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'`
+               basic_machine=`echo "$basic_machine" | sed 's/digital.*/dec/'`
                ;;
        *-commodore*)
-               basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'`
+               basic_machine=`echo "$basic_machine" | sed 's/commodore.*/cbm/'`
                ;;
        *)
                ;;
@@ -1340,197 +1286,246 @@ esac
 
 # Decode manufacturer-specific aliases for certain operating systems.
 
-if [ x"$os" != x"" ]
+if [ x$os != x ]
 then
 case $os in
-       # First match some system type aliases
-       # that might get confused with valid system types.
-       # -solaris* is a basic system type, with this one exception.
-       -auroraux)
-               os=-auroraux
+       # First match some system type aliases that might get confused
+       # with valid system types.
+       # solaris* is a basic system type, with this one exception.
+       auroraux)
+               os=auroraux
                ;;
-       -solaris1 | -solaris1.*)
-               os=`echo $os | sed -e 's|solaris1|sunos4|'`
+       bluegene*)
+               os=cnk
                ;;
-       -solaris)
-               os=-solaris2
+       solaris1 | solaris1.*)
+               os=`echo $os | sed -e 's|solaris1|sunos4|'`
                ;;
-       -svr4*)
-               os=-sysv4
+       solaris)
+               os=solaris2
                ;;
-       -unixware*)
-               os=-sysv4.2uw
+       unixware*)
+               os=sysv4.2uw
                ;;
-       -gnu/linux*)
+       gnu/linux*)
                os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'`
                ;;
-       # First accept the basic system types.
+       # es1800 is here to avoid being matched by es* (a different OS)
+       es1800*)
+               os=ose
+               ;;
+       # Some version numbers need modification
+       chorusos*)
+               os=chorusos
+               ;;
+       isc)
+               os=isc2.2
+               ;;
+       sco6)
+               os=sco5v6
+               ;;
+       sco5)
+               os=sco3.2v5
+               ;;
+       sco4)
+               os=sco3.2v4
+               ;;
+       sco3.2.[4-9]*)
+               os=`echo $os | sed -e 's/sco3.2./sco3.2v/'`
+               ;;
+       sco3.2v[4-9]* | sco5v6*)
+               # Don't forget version if it is 3.2v4 or newer.
+               ;;
+       scout)
+               # Don't match below
+               ;;
+       sco*)
+               os=sco3.2v2
+               ;;
+       psos*)
+               os=psos
+               ;;
+       # Now accept the basic system types.
        # The portable systems comes first.
-       # Each alternative MUST END IN A *, to match a version number.
-       # -sysv* is not here because it comes later, after sysvr4.
-       -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \
-             | -*vms* | -sco* | -esix* | -isc* | -aix* | -cnk* | -sunos | -sunos[34]*\
-             | -hpux* | -unos* | -osf* | -luna* | -dgux* | -auroraux* | -solaris* \
-             | -sym* | -kopensolaris* | -plan9* \
-             | -amigaos* | -amigados* | -msdos* | -newsos* | -unicos* | -aof* \
-             | -aos* | -aros* \
-             | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \
-             | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \
-             | -hiux* | -386bsd* | -knetbsd* | -mirbsd* | -netbsd* \
-             | -bitrig* | -openbsd* | -solidbsd* \
-             | -ekkobsd* | -kfreebsd* | -freebsd* | -riscix* | -lynxos* \
-             | -bosx* | -nextstep* | -cxux* | -aout* | -elf* | -oabi* \
-             | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \
-             | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \
-             | -chorusos* | -chorusrdb* | -cegcc* \
-             | -cygwin* | -msys* | -pe* | -psos* | -moss* | -proelf* | -rtems* \
-             | -mingw32* | -mingw64* | -linux-gnu* | -linux-android* \
-             | -linux-newlib* | -linux-musl* | -linux-uclibc* \
-             | -uxpv* | -beos* | -mpeix* | -udk* | -moxiebox* \
-             | -interix* | -uwin* | -mks* | -rhapsody* | -darwin* | -opened* \
-             | -openstep* | -oskit* | -conix* | -pw32* | -nonstopux* \
-             | -storm-chaos* | -tops10* | -tenex* | -tops20* | -its* \
-             | -os2* | -vos* | -palmos* | -uclinux* | -nucleus* \
-             | -morphos* | -superux* | -rtmk* | -rtmk-nova* | -windiss* \
-             | -powermax* | -dnix* | -nx6 | -nx7 | -sei* | -dragonfly* \
-             | -skyos* | -haiku* | -rdos* | -toppers* | -drops* | -es* | -tirtos*)
+       # Each alternative MUST end in a * to match a version number.
+       # sysv* is not here because it comes later, after sysvr4.
+       gnu* | bsd* | mach* | minix* | genix* | ultrix* | irix* \
+            | *vms* | esix* | aix* | cnk* | sunos | sunos[34]*\
+            | hpux* | unos* | osf* | luna* | dgux* | auroraux* | solaris* \
+            | sym* | kopensolaris* | plan9* \
+            | amigaos* | amigados* | msdos* | newsos* | unicos* | aof* \
+            | aos* | aros* | cloudabi* | sortix* \
+            | nindy* | vxsim* | vxworks* | ebmon* | hms* | mvs* \
+            | clix* | riscos* | uniplus* | iris* | rtu* | xenix* \
+            | knetbsd* | mirbsd* | netbsd* \
+            | bitrig* | openbsd* | solidbsd* | libertybsd* \
+            | ekkobsd* | kfreebsd* | freebsd* | riscix* | lynxos* \
+            | bosx* | nextstep* | cxux* | aout* | elf* | oabi* \
+            | ptx* | coff* | ecoff* | winnt* | domain* | vsta* \
+            | udi* | eabi* | lites* | ieee* | go32* | aux* | hcos* \
+            | chorusrdb* | cegcc* | glidix* \
+            | cygwin* | msys* | pe* | moss* | proelf* | rtems* \
+            | midipix* | mingw32* | mingw64* | linux-gnu* | linux-android* \
+            | linux-newlib* | linux-musl* | linux-uclibc* \
+            | uxpv* | beos* | mpeix* | udk* | moxiebox* \
+            | interix* | uwin* | mks* | rhapsody* | darwin* \
+            | openstep* | oskit* | conix* | pw32* | nonstopux* \
+            | storm-chaos* | tops10* | tenex* | tops20* | its* \
+            | os2* | vos* | palmos* | uclinux* | nucleus* \
+            | morphos* | superux* | rtmk* | windiss* \
+            | powermax* | dnix* | nx6 | nx7 | sei* | dragonfly* \
+            | skyos* | haiku* | rdos* | toppers* | drops* | es* \
+            | onefs* | tirtos* | phoenix* | fuchsia* | redox* | bme* \
+            | midnightbsd*)
        # Remember, each alternative MUST END IN *, to match a version number.
                ;;
-       -qnx*)
+       qnx*)
                case $basic_machine in
                    x86-* | i*86-*)
                        ;;
                    *)
-                       os=-nto$os
+                       os=nto-$os
                        ;;
                esac
                ;;
-       -nto-qnx*)
+       hiux*)
+               os=hiuxwe2
                ;;
-       -nto*)
-               os=`echo $os | sed -e 's|nto|nto-qnx|'`
+       nto-qnx*)
                ;;
-       -sim | -es1800* | -hms* | -xray | -os68k* | -none* | -v88r* \
-             | -windows* | -osx | -abug | -netware* | -os9* | -beos* | -haiku* \
-             | -macos* | -mpw* | -magic* | -mmixware* | -mon960* | -lnews*)
+       nto*)
+               os=`echo $os | sed -e 's|nto|nto-qnx|'`
                ;;
-       -mac*)
-               os=`echo $os | sed -e 's|mac|macos|'`
+       sim | xray | os68k* | v88r* \
+           | windows* | osx | abug | netware* | os9* \
+           | macos* | mpw* | magic* | mmixware* | mon960* | lnews*)
                ;;
-       -linux-dietlibc)
-               os=-linux-dietlibc
+       linux-dietlibc)
+               os=linux-dietlibc
                ;;
-       -linux*)
+       linux*)
                os=`echo $os | sed -e 's|linux|linux-gnu|'`
                ;;
-       -sunos5*)
-               os=`echo $os | sed -e 's|sunos5|solaris2|'`
+       lynx*178)
+               os=lynxos178
+               ;;
+       lynx*5)
+               os=lynxos5
+               ;;
+       lynx*)
+               os=lynxos
                ;;
-       -sunos6*)
-               os=`echo $os | sed -e 's|sunos6|solaris3|'`
+       mac*)
+               os=`echo "$os" | sed -e 's|mac|macos|'`
                ;;
-       -opened*)
-               os=-openedition
+       opened*)
+               os=openedition
                ;;
-       -os400*)
-               os=-os400
+       os400*)
+               os=os400
                ;;
-       -wince*)
-               os=-wince
+       sunos5*)
+               os=`echo "$os" | sed -e 's|sunos5|solaris2|'`
                ;;
-       -osfrose*)
-               os=-osfrose
+       sunos6*)
+               os=`echo "$os" | sed -e 's|sunos6|solaris3|'`
                ;;
-       -osf*)
-               os=-osf
+       wince*)
+               os=wince
                ;;
-       -utek*)
-               os=-bsd
+       utek*)
+               os=bsd
                ;;
-       -dynix*)
-               os=-bsd
+       dynix*)
+               os=bsd
                ;;
-       -acis*)
-               os=-aos
+       acis*)
+               os=aos
                ;;
-       -atheos*)
-               os=-atheos
+       atheos*)
+               os=atheos
                ;;
-       -syllable*)
-               os=-syllable
+       syllable*)
+               os=syllable
                ;;
-       -386bsd)
-               os=-bsd
+       386bsd)
+               os=bsd
                ;;
-       -ctix* | -uts*)
-               os=-sysv
+       ctix* | uts*)
+               os=sysv
                ;;
-       -nova*)
-               os=-rtmk-nova
+       nova*)
+               os=rtmk-nova
                ;;
-       -ns2 )
-               os=-nextstep2
+       ns2)
+               os=nextstep2
                ;;
-       -nsk*)
-               os=-nsk
+       nsk*)
+               os=nsk
                ;;
        # Preserve the version number of sinix5.
-       -sinix5.*)
+       sinix5.*)
                os=`echo $os | sed -e 's|sinix|sysv|'`
                ;;
-       -sinix*)
-               os=-sysv4
+       sinix*)
+               os=sysv4
                ;;
-       -tpf*)
-               os=-tpf
+       tpf*)
+               os=tpf
                ;;
-       -triton*)
-               os=-sysv3
+       triton*)
+               os=sysv3
                ;;
-       -oss*)
-               os=-sysv3
+       oss*)
+               os=sysv3
                ;;
-       -svr4)
-               os=-sysv4
+       svr4*)
+               os=sysv4
                ;;
-       -svr3)
-               os=-sysv3
+       svr3)
+               os=sysv3
                ;;
-       -sysvr4)
-               os=-sysv4
+       sysvr4)
+               os=sysv4
                ;;
-       # This must come after -sysvr4.
-       -sysv*)
+       # This must come after sysvr4.
+       sysv*)
                ;;
-       -ose*)
-               os=-ose
+       ose*)
+               os=ose
                ;;
-       -es1800*)
-               os=-ose
+       *mint | mint[0-9]* | *MiNT | MiNT[0-9]*)
+               os=mint
                ;;
-       -xenix)
-               os=-xenix
+       zvmoe)
+               os=zvmoe
                ;;
-       -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*)
-               os=-mint
+       dicos*)
+               os=dicos
                ;;
-       -aros*)
-               os=-aros
+       pikeos*)
+               # Until real need of OS specific support for
+               # particular features comes up, bare metal
+               # configurations are quite functional.
+               case $basic_machine in
+                   arm*)
+                       os=eabi
+                       ;;
+                   *)
+                       os=elf
+                       ;;
+               esac
                ;;
-       -zvmoe)
-               os=-zvmoe
+       nacl*)
                ;;
-       -dicos*)
-               os=-dicos
+       ios)
                ;;
-       -nacl*)
+       none)
                ;;
-       -none)
+       *-eabi)
                ;;
        *)
-               # Get rid of the `-' at the beginning of $os.
-               os=`echo $os | sed 's/[^-]*-//'`
-               echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2
+               echo Invalid configuration \`"$1"\': system \`"$os"\' not recognized 1>&2
                exit 1
                ;;
 esac
@@ -1548,176 +1543,179 @@ else
 
 case $basic_machine in
        score-*)
-               os=-elf
+               os=elf
                ;;
        spu-*)
-               os=-elf
+               os=elf
                ;;
        *-acorn)
-               os=-riscix1.2
+               os=riscix1.2
                ;;
        arm*-rebel)
-               os=-linux
+               os=linux
                ;;
        arm*-semi)
-               os=-aout
+               os=aout
                ;;
        c4x-* | tic4x-*)
-               os=-coff
+               os=coff
                ;;
        c8051-*)
-               os=-elf
+               os=elf
+               ;;
+       clipper-intergraph)
+               os=clix
                ;;
        hexagon-*)
-               os=-elf
+               os=elf
                ;;
        tic54x-*)
-               os=-coff
+               os=coff
                ;;
        tic55x-*)
-               os=-coff
+               os=coff
                ;;
        tic6x-*)
-               os=-coff
+               os=coff
                ;;
        # This must come before the *-dec entry.
        pdp10-*)
-               os=-tops20
+               os=tops20
                ;;
        pdp11-*)
-               os=-none
+               os=none
                ;;
        *-dec | vax-*)
-               os=-ultrix4.2
+               os=ultrix4.2
                ;;
        m68*-apollo)
-               os=-domain
+               os=domain
                ;;
        i386-sun)
-               os=-sunos4.0.2
+               os=sunos4.0.2
                ;;
        m68000-sun)
-               os=-sunos3
+               os=sunos3
                ;;
        m68*-cisco)
-               os=-aout
+               os=aout
                ;;
        mep-*)
-               os=-elf
+               os=elf
                ;;
        mips*-cisco)
-               os=-elf
+               os=elf
                ;;
        mips*-*)
-               os=-elf
+               os=elf
                ;;
        or32-*)
-               os=-coff
+               os=coff
                ;;
        *-tti)  # must be before sparc entry or we get the wrong os.
-               os=-sysv3
+               os=sysv3
                ;;
        sparc-* | *-sun)
-               os=-sunos4.1.1
+               os=sunos4.1.1
                ;;
-       *-be)
-               os=-beos
+       pru-*)
+               os=elf
                ;;
-       *-haiku)
-               os=-haiku
+       *-be)
+               os=beos
                ;;
        *-ibm)
-               os=-aix
+               os=aix
                ;;
        *-knuth)
-               os=-mmixware
+               os=mmixware
                ;;
        *-wec)
-               os=-proelf
+               os=proelf
                ;;
        *-winbond)
-               os=-proelf
+               os=proelf
                ;;
        *-oki)
-               os=-proelf
+               os=proelf
                ;;
        *-hp)
-               os=-hpux
+               os=hpux
                ;;
        *-hitachi)
-               os=-hiux
+               os=hiux
                ;;
        i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent)
-               os=-sysv
+               os=sysv
                ;;
        *-cbm)
-               os=-amigaos
+               os=amigaos
                ;;
        *-dg)
-               os=-dgux
+               os=dgux
                ;;
        *-dolphin)
-               os=-sysv3
+               os=sysv3
                ;;
        m68k-ccur)
-               os=-rtu
+               os=rtu
                ;;
        m88k-omron*)
-               os=-luna
+               os=luna
                ;;
-       *-next )
-               os=-nextstep
+       *-next)
+               os=nextstep
                ;;
        *-sequent)
-               os=-ptx
+               os=ptx
                ;;
        *-crds)
-               os=-unos
+               os=unos
                ;;
        *-ns)
-               os=-genix
+               os=genix
                ;;
        i370-*)
-               os=-mvs
-               ;;
-       *-next)
-               os=-nextstep3
+               os=mvs
                ;;
        *-gould)
-               os=-sysv
+               os=sysv
                ;;
        *-highlevel)
-               os=-bsd
+               os=bsd
                ;;
        *-encore)
-               os=-bsd
+               os=bsd
                ;;
        *-sgi)
-               os=-irix
+               os=irix
                ;;
        *-siemens)
-               os=-sysv4
+               os=sysv4
                ;;
        *-masscomp)
-               os=-rtu
+               os=rtu
                ;;
        f30[01]-fujitsu | f700-fujitsu)
-               os=-uxpv
+               os=uxpv
                ;;
        *-rom68k)
-               os=-coff
+               os=coff
                ;;
        *-*bug)
-               os=-coff
+               os=coff
                ;;
        *-apple)
-               os=-macos
+               os=macos
                ;;
        *-atari*)
-               os=-mint
+               os=mint
+               ;;
+       *-wrs)
+               os=vxworks
                ;;
        *)
-               os=-none
+               os=none
                ;;
 esac
 fi
@@ -1728,79 +1726,82 @@ vendor=unknown
 case $basic_machine in
        *-unknown)
                case $os in
-                       -riscix*)
+                       riscix*)
                                vendor=acorn
                                ;;
-                       -sunos*)
+                       sunos*)
                                vendor=sun
                                ;;
-                       -cnk*|-aix*)
+                       cnk*|-aix*)
                                vendor=ibm
                                ;;
-                       -beos*)
+                       beos*)
                                vendor=be
                                ;;
-                       -hpux*)
+                       hpux*)
                                vendor=hp
                                ;;
-                       -mpeix*)
+                       mpeix*)
                                vendor=hp
                                ;;
-                       -hiux*)
+                       hiux*)
                                vendor=hitachi
                                ;;
-                       -unos*)
+                       unos*)
                                vendor=crds
                                ;;
-                       -dgux*)
+                       dgux*)
                                vendor=dg
                                ;;
-                       -luna*)
+                       luna*)
                                vendor=omron
                                ;;
-                       -genix*)
+                       genix*)
                                vendor=ns
                                ;;
-                       -mvs* | -opened*)
+                       clix*)
+                               vendor=intergraph
+                               ;;
+                       mvs* | opened*)
                                vendor=ibm
                                ;;
-                       -os400*)
+                       os400*)
                                vendor=ibm
                                ;;
-                       -ptx*)
+                       ptx*)
                                vendor=sequent
                                ;;
-                       -tpf*)
+                       tpf*)
                                vendor=ibm
                                ;;
-                       -vxsim* | -vxworks* | -windiss*)
+                       vxsim* | vxworks* | windiss*)
                                vendor=wrs
                                ;;
-                       -aux*)
+                       aux*)
                                vendor=apple
                                ;;
-                       -hms*)
+                       hms*)
                                vendor=hitachi
                                ;;
-                       -mpw* | -macos*)
+                       mpw* | macos*)
                                vendor=apple
                                ;;
-                       -*mint | -mint[0-9]* | -*MiNT | -MiNT[0-9]*)
+                       *mint | mint[0-9]* | *MiNT | MiNT[0-9]*)
                                vendor=atari
                                ;;
-                       -vos*)
+                       vos*)
                                vendor=stratus
                                ;;
                esac
-               basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"`
+               basic_machine=`echo "$basic_machine" | sed "s/unknown/$vendor/"`
                ;;
 esac
 
-echo $basic_machine$os
+echo "$basic_machine-$os"
 exit
 
 # Local variables:
-# eval: (add-hook 'write-file-hooks 'time-stamp)
+# eval: (add-hook 'before-save-hook 'time-stamp)
 # time-stamp-start: "timestamp='"
 # time-stamp-format: "%:y-%02m-%02d"
 # time-stamp-end: "'"
index 7124f6f..5f055d2 100755 (executable)
--- a/configure
+++ b/configure
@@ -675,6 +675,7 @@ infodir
 docdir
 oldincludedir
 includedir
+runstatedir
 localstatedir
 sharedstatedir
 sysconfdir
@@ -755,6 +756,7 @@ datadir='${datarootdir}'
 sysconfdir='${prefix}/etc'
 sharedstatedir='${prefix}/com'
 localstatedir='${prefix}/var'
+runstatedir='${localstatedir}/run'
 includedir='${prefix}/include'
 oldincludedir='/usr/include'
 docdir='${datarootdir}/doc/${PACKAGE}'
@@ -1007,6 +1009,15 @@ do
   | -silent | --silent | --silen | --sile | --sil)
     silent=yes ;;
 
+  -runstatedir | --runstatedir | --runstatedi | --runstated \
+  | --runstate | --runstat | --runsta | --runst | --runs \
+  | --run | --ru | --r)
+    ac_prev=runstatedir ;;
+  -runstatedir=* | --runstatedir=* | --runstatedi=* | --runstated=* \
+  | --runstate=* | --runstat=* | --runsta=* | --runst=* | --runs=* \
+  | --run=* | --ru=* | --r=*)
+    runstatedir=$ac_optarg ;;
+
   -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb)
     ac_prev=sbindir ;;
   -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \
@@ -1144,7 +1155,7 @@ fi
 for ac_var in  exec_prefix prefix bindir sbindir libexecdir datarootdir \
                datadir sysconfdir sharedstatedir localstatedir includedir \
                oldincludedir docdir infodir htmldir dvidir pdfdir psdir \
-               libdir localedir mandir
+               libdir localedir mandir runstatedir
 do
   eval ac_val=\$$ac_var
   # Remove trailing slashes.
@@ -1297,6 +1308,7 @@ Fine tuning of the installation directories:
   --sysconfdir=DIR        read-only single-machine data [PREFIX/etc]
   --sharedstatedir=DIR    modifiable architecture-independent data [PREFIX/com]
   --localstatedir=DIR     modifiable single-machine data [PREFIX/var]
+  --runstatedir=DIR       modifiable per-process data [LOCALSTATEDIR/run]
   --libdir=DIR            object code libraries [EPREFIX/lib]
   --includedir=DIR        C header files [PREFIX/include]
   --oldincludedir=DIR     C header files for non-gcc [/usr/include]
@@ -1329,7 +1341,7 @@ Optional Features:
   --disable-FEATURE       do not include FEATURE (same as --enable-FEATURE=no)
   --enable-FEATURE[=ARG]  include FEATURE [ARG=yes]
   --disable-universal     don't build universal on OS X
-  --enable-smb            enable possibly-buggy SMB printer default=yes
+  --enable-smb            enable possibly-buggy SMB printer default=no
   --disable-smb           disable possibly-buggy SMB printer
 
 Optional Packages:
@@ -4193,7 +4205,7 @@ fi
 done
 
 
-for ac_header in fcntl.h rpc/rpc.h rpc/rpcent.h netdnet/dnetdb.h
+for ac_header in fcntl.h rpc/rpc.h rpc/rpcent.h
 do :
   as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
 ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default"
@@ -4492,14 +4504,12 @@ $as_echo_n "checking whether to enable the possibly-buggy SMB printer... " >&6;
 if test "${enable_smb+set}" = set; then :
   enableval=$enable_smb;
 else
-  enableval=yes
+  enableval=no
 fi
 
 case "$enableval" in
 yes)   { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5
 $as_echo "yes" >&6; }
-       { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: The SMB printer may have exploitable buffer overflows!!!" >&5
-$as_echo "$as_me: WARNING: The SMB printer may have exploitable buffer overflows!!!" >&2;}
 
 $as_echo "#define ENABLE_SMB 1" >>confdefs.h
 
@@ -5059,33 +5069,6 @@ if test "$ipv6" = "yes" -a "$ipv6lib" != "none"; then
        fi
 fi
 
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for dnet_htoa declaration in netdnet/dnetdb.h" >&5
-$as_echo_n "checking for dnet_htoa declaration in netdnet/dnetdb.h... " >&6; }
-if ${td_cv_decl_netdnet_dnetdb_h_dnet_htoa+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-#include <netdnet/dnetdb.h>
-
-_ACEOF
-if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
-  $EGREP "dnet_htoa" >/dev/null 2>&1; then :
-  td_cv_decl_netdnet_dnetdb_h_dnet_htoa=yes
-else
-  td_cv_decl_netdnet_dnetdb_h_dnet_htoa=no
-fi
-rm -f conftest*
-
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $td_cv_decl_netdnet_dnetdb_h_dnet_htoa" >&5
-$as_echo "$td_cv_decl_netdnet_dnetdb_h_dnet_htoa" >&6; }
-if test "$td_cv_decl_netdnet_dnetdb_h_dnet_htoa" = yes; then
-
-$as_echo "#define HAVE_NETDNET_DNETDB_H_DNET_HTOA 1" >>confdefs.h
-
-fi
-
 ac_fn_c_check_func "$LINENO" "vfprintf" "ac_cv_func_vfprintf"
 if test "x$ac_cv_func_vfprintf" = xyes; then :
   $as_echo "#define HAVE_VFPRINTF 1" >>confdefs.h
@@ -5293,65 +5276,6 @@ done
            ;;
     esac
 
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing dnet_htoa" >&5
-$as_echo_n "checking for library containing dnet_htoa... " >&6; }
-if ${ac_cv_search_dnet_htoa+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  ac_func_search_save_LIBS=$LIBS
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-/* Override any GCC internal prototype to avoid an error.
-   Use char because int might match the return type of a GCC
-   builtin and then its argument prototype would still apply.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-char dnet_htoa ();
-int
-main ()
-{
-return dnet_htoa ();
-  ;
-  return 0;
-}
-_ACEOF
-for ac_lib in '' dnet; do
-  if test -z "$ac_lib"; then
-    ac_res="none required"
-  else
-    ac_res=-l$ac_lib
-    LIBS="-l$ac_lib  $ac_func_search_save_LIBS"
-  fi
-  if ac_fn_c_try_link "$LINENO"; then :
-  ac_cv_search_dnet_htoa=$ac_res
-fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext
-  if ${ac_cv_search_dnet_htoa+:} false; then :
-  break
-fi
-done
-if ${ac_cv_search_dnet_htoa+:} false; then :
-
-else
-  ac_cv_search_dnet_htoa=no
-fi
-rm conftest.$ac_ext
-LIBS=$ac_func_search_save_LIBS
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_dnet_htoa" >&5
-$as_echo "$ac_cv_search_dnet_htoa" >&6; }
-ac_res=$ac_cv_search_dnet_htoa
-if test "$ac_res" != no; then :
-  test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
-
-$as_echo "#define HAVE_DNET_HTOA 1" >>confdefs.h
-
-fi
-
-
 { $as_echo "$as_me:${as_lineno-$LINENO}: checking for main in -lrpc" >&5
 $as_echo_n "checking for main in -lrpc... " >&6; }
 if ${ac_cv_lib_rpc_main+:} false; then :
similarity index 97%
rename from configure.in
rename to configure.ac
index b2305a5..56e2a62 100644 (file)
@@ -32,7 +32,7 @@ if test "$ac_cv___attribute__" = "yes"; then
        fi
 fi
 
-AC_CHECK_HEADERS(fcntl.h rpc/rpc.h rpc/rpcent.h netdnet/dnetdb.h)
+AC_CHECK_HEADERS(fcntl.h rpc/rpc.h rpc/rpcent.h)
 AC_CHECK_HEADERS(net/pfvar.h, , , [#include <sys/types.h>
 #include <sys/socket.h>
 #include <net/if.h>])
@@ -169,12 +169,11 @@ fi
 
 AC_MSG_CHECKING([whether to enable the possibly-buggy SMB printer])
 AC_ARG_ENABLE(smb,
-[  --enable-smb            enable possibly-buggy SMB printer [default=yes]
+[  --enable-smb            enable possibly-buggy SMB printer [default=no]
   --disable-smb           disable possibly-buggy SMB printer],,
-   enableval=yes)
+   enableval=no)
 case "$enableval" in
 yes)   AC_MSG_RESULT(yes)
-       AC_WARN([The SMB printer may have exploitable buffer overflows!!!])
        AC_DEFINE(ENABLE_SMB, 1,
            [define if you want to build the possibly-buggy SMB printer])
        LOCALSRC="print-smb.c smbutil.c $LOCALSRC"
@@ -386,16 +385,6 @@ if test "$ipv6" = "yes" -a "$ipv6lib" != "none"; then
        fi
 fi
 
-AC_CACHE_CHECK([for dnet_htoa declaration in netdnet/dnetdb.h],
-[td_cv_decl_netdnet_dnetdb_h_dnet_htoa],
-[AC_EGREP_HEADER(dnet_htoa, netdnet/dnetdb.h,
-       td_cv_decl_netdnet_dnetdb_h_dnet_htoa=yes,
-       td_cv_decl_netdnet_dnetdb_h_dnet_htoa=no)])
-if test "$td_cv_decl_netdnet_dnetdb_h_dnet_htoa" = yes; then
-       AC_DEFINE(HAVE_NETDNET_DNETDB_H_DNET_HTOA, 1,
-           [define if you have a dnet_htoa declaration in <netdnet/dnetdb.h>])
-fi
-
 AC_REPLACE_FUNCS(vfprintf strlcat strlcpy strdup strsep getopt_long)
 AC_CHECK_FUNCS(fork vfork strftime)
 AC_CHECK_FUNCS(setlinebuf alarm)
@@ -409,9 +398,6 @@ fi
 
 AC_LBL_TYPE_SIGNAL
 
-AC_SEARCH_LIBS(dnet_htoa, dnet,
-    AC_DEFINE(HAVE_DNET_HTOA, 1, [define if you have the dnet_htoa function]))
-
 AC_CHECK_LIB(rpc, main)                dnl It's unclear why we might need -lrpc
 
 dnl Some platforms may need -lnsl for getrpcbynumber.
index 089b040..02f196c 100644 (file)
@@ -514,6 +514,7 @@ extern void hsrp_print(netdissect_options *, const u_char *, u_int);
 extern void http_print(netdissect_options *, const u_char *, u_int);
 extern void icmp6_print(netdissect_options *, const u_char *, u_int, const u_char *, int);
 extern void icmp_print(netdissect_options *, const u_char *, u_int, const u_char *, int);
+extern u_int ieee802_11_radio_print(netdissect_options *, const u_char *, u_int, u_int);
 extern void igmp_print(netdissect_options *, const u_char *, u_int);
 extern void igrp_print(netdissect_options *, const u_char *, u_int);
 extern void ip6_print(netdissect_options *, const u_char *, u_int);
@@ -640,7 +641,6 @@ extern int nextproto6_cksum(netdissect_options *, const struct ip6_hdr *, const
 extern int mask2plen(uint32_t);
 extern int mask62plen(const u_char *);
 
-extern const char *dnname_string(netdissect_options *, u_short);
 extern const char *dnnum_string(netdissect_options *, u_short);
 
 extern char *smb_errstr(int, int);
index d8bf039..50a3e9f 100644 (file)
@@ -2058,6 +2058,10 @@ ieee802_11_print(netdissect_options *ndo,
                hdrlen = roundup2(hdrlen, 4);
        if (ndo->ndo_Hflag && FC_TYPE(fc) == T_DATA &&
            DATA_FRAME_IS_QOS(FC_SUBTYPE(fc))) {
+               if (caplen < hdrlen + 1) {
+                       ND_PRINT((ndo, "%s", tstr));
+                       return hdrlen;
+               }
                meshdrlen = extract_mesh_header_length(p+hdrlen);
                hdrlen += meshdrlen;
        } else
@@ -3071,7 +3075,7 @@ print_in_radiotap_namespace(netdissect_options *ndo,
        return 0;
 }
 
-static u_int
+u_int
 ieee802_11_radio_print(netdissect_options *ndo,
                        const u_char *p, u_int length, u_int caplen)
 {
@@ -3101,6 +3105,15 @@ ieee802_11_radio_print(netdissect_options *ndo,
        hdr = (const struct ieee80211_radiotap_header *)p;
 
        len = EXTRACT_LE_16BITS(&hdr->it_len);
+       if (len < sizeof(*hdr)) {
+               /*
+                * The length is the length of the entire header, so
+                * it must be as large as the fixed-length part of
+                * the header.
+                */
+               ND_PRINT((ndo, "%s", tstr));
+               return caplen;
+       }
 
        /*
         * If we don't have the entire radiotap header, just give up.
index 97e93df..fcb7526 100644 (file)
@@ -325,6 +325,7 @@ aoev1_reserve_print(netdissect_options *ndo,
                goto invalid;
        /* addresses */
        for (i = 0; i < nmacs; i++) {
+               ND_TCHECK2(*cp, ETHER_ADDR_LEN);
                ND_PRINT((ndo, "\n\tEthernet Address %u: %s", i, etheraddr_string(ndo, cp)));
                cp += ETHER_ADDR_LEN;
        }
@@ -350,6 +351,7 @@ aoev1_print(netdissect_options *ndo,
        if (len < AOEV1_COMMON_HDR_LEN)
                goto invalid;
        /* Flags */
+       ND_TCHECK2(*cp, 1);
        flags = *cp & 0x0F;
        ND_PRINT((ndo, ", Flags: [%s]", bittok2str(aoev1_flag_str, "none", flags)));
        cp += 1;
index f8741d7..0bb2483 100644 (file)
@@ -352,6 +352,8 @@ babel_print_v2(netdissect_options *ndo,
         goto invalid;
     bodylen = EXTRACT_16BITS(cp + 2);
     ND_PRINT((ndo, " (%u)", bodylen));
+    if (4U + bodylen > length)
+        goto invalid;
 
     /* Process the TLVs in the body */
     i = 0;
@@ -480,7 +482,7 @@ babel_print_v2(netdissect_options *ndo,
         case MESSAGE_UPDATE: {
             if (!ndo->ndo_vflag) {
                 ND_PRINT((ndo, " update"));
-                if(len < 1)
+                if(len < 10)
                     ND_PRINT((ndo, "/truncated"));
                 else
                     ND_PRINT((ndo, "%s%s%s",
index 10b8f35..0e766ca 100644 (file)
 
 /* \summary: Bidirectional Forwarding Detection (BFD) printer */
 
-/* specification: RFC 5880 (for version 1) and RFC 5881 */
+/*
+ * specification: draft-ietf-bfd-base-01 for version 0,
+ * RFC 5880 for version 1, and RFC 5881
+ */
 
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #include "udp.h"
 
 /*
- * Control packet, BFDv0, draft-katz-ward-bfd-01.txt
+ * Control packet, BFDv0, draft-ietf-bfd-base-01
  *
  *     0                   1                   2                   3
  *     0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1
  *    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
- *    |Vers |  Diag   |H|D|P|F| Rsvd  |  Detect Mult  |    Length     |
+ *    |Vers |  Diag   |H|D|P|F|C|A|Rsv|  Detect Mult  |    Length     |
  *    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
  *    |                       My Discriminator                        |
  *    +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+
@@ -126,12 +129,6 @@ enum auth_length {
 #define BFD_EXTRACT_VERSION(x) (((x)&0xe0)>>5)
 #define BFD_EXTRACT_DIAG(x)     ((x)&0x1f)
 
-static const struct tok bfd_port_values[] = {
-    { BFD_CONTROL_PORT, "Control" },
-    { BFD_ECHO_PORT,    "Echo" },
-    { 0, NULL }
-};
-
 static const struct tok bfd_diag_values[] = {
     { 0, "No Diagnostic" },
     { 1, "Control Detection Time Expired" },
@@ -145,20 +142,20 @@ static const struct tok bfd_diag_values[] = {
     { 0, NULL }
 };
 
+#define BFD_FLAG_AUTH 0x04
+
 static const struct tok bfd_v0_flag_values[] = {
     { 0x80, "I Hear You" },
     { 0x40, "Demand" },
     { 0x20, "Poll" },
     { 0x10, "Final" },
-    { 0x08, "Reserved" },
-    { 0x04, "Reserved" },
+    { 0x08, "Control Plane Independent" },
+    { BFD_FLAG_AUTH, "Authentication Present" },
     { 0x02, "Reserved" },
     { 0x01, "Reserved" },
     { 0, NULL }
 };
 
-#define BFD_FLAG_AUTH 0x04
-
 static const struct tok bfd_v1_flag_values[] = {
     { 0x20, "Poll" },
     { 0x10, "Final" },
@@ -292,106 +289,124 @@ void
 bfd_print(netdissect_options *ndo, register const u_char *pptr,
           register u_int len, register u_int port)
 {
-        const struct bfd_header_t *bfd_header;
-        uint8_t version = 0;
-
-        bfd_header = (const struct bfd_header_t *)pptr;
         if (port == BFD_CONTROL_PORT) {
+            /*
+             * Control packet.
+             */
+            const struct bfd_header_t *bfd_header;
+            uint8_t version_diag;
+            uint8_t version = 0;
+            uint8_t flags;
+
+            bfd_header = (const struct bfd_header_t *)pptr;
             ND_TCHECK(*bfd_header);
-            version = BFD_EXTRACT_VERSION(bfd_header->version_diag);
-        } else if (port == BFD_ECHO_PORT) {
-            /* Echo is BFD v1 only */
-            version = 1;
-        }
-        switch ((port << 8) | version) {
+            version_diag = bfd_header->version_diag;
+            version = BFD_EXTRACT_VERSION(version_diag);
+            flags = bfd_header->flags;
+
+            switch (version) {
+
+                /* BFDv0 */
+            case 0:
+                if (ndo->ndo_vflag < 1)
+                {
+                    ND_PRINT((ndo, "BFDv0, Control, Flags: [%s], length: %u",
+                           bittok2str(bfd_v0_flag_values, "none", flags),
+                           len));
+                    return;
+                }
+
+                ND_PRINT((ndo, "BFDv0, length: %u\n\tControl, Flags: [%s], Diagnostic: %s (0x%02x)",
+                       len,
+                       bittok2str(bfd_v0_flag_values, "none", flags),
+                       tok2str(bfd_diag_values,"unknown",BFD_EXTRACT_DIAG(version_diag)),
+                       BFD_EXTRACT_DIAG(version_diag)));
+
+                ND_PRINT((ndo, "\n\tDetection Timer Multiplier: %u (%u ms Detection time), BFD Length: %u",
+                       bfd_header->detect_time_multiplier,
+                       bfd_header->detect_time_multiplier * EXTRACT_32BITS(bfd_header->desired_min_tx_interval)/1000,
+                       bfd_header->length));
 
-            /* BFDv0 */
-        case (BFD_CONTROL_PORT << 8):
-            if (ndo->ndo_vflag < 1)
-            {
-                ND_PRINT((ndo, "BFDv%u, %s, Flags: [%s], length: %u",
-                       version,
-                       tok2str(bfd_port_values, "unknown (%u)", port),
-                       bittok2str(bfd_v0_flag_values, "none", bfd_header->flags),
-                       len));
-                return;
-            }
 
-            ND_PRINT((ndo, "BFDv%u, length: %u\n\t%s, Flags: [%s], Diagnostic: %s (0x%02x)",
-                   version,
-                   len,
-                   tok2str(bfd_port_values, "unknown (%u)", port),
-                   bittok2str(bfd_v0_flag_values, "none", bfd_header->flags),
-                   tok2str(bfd_diag_values,"unknown",BFD_EXTRACT_DIAG(bfd_header->version_diag)),
-                   BFD_EXTRACT_DIAG(bfd_header->version_diag)));
-
-            ND_PRINT((ndo, "\n\tDetection Timer Multiplier: %u (%u ms Detection time), BFD Length: %u",
-                   bfd_header->detect_time_multiplier,
-                   bfd_header->detect_time_multiplier * EXTRACT_32BITS(bfd_header->desired_min_tx_interval)/1000,
-                   bfd_header->length));
-
-
-            ND_PRINT((ndo, "\n\tMy Discriminator: 0x%08x", EXTRACT_32BITS(bfd_header->my_discriminator)));
-            ND_PRINT((ndo, ", Your Discriminator: 0x%08x", EXTRACT_32BITS(bfd_header->your_discriminator)));
-            ND_PRINT((ndo, "\n\t  Desired min Tx Interval:    %4u ms", EXTRACT_32BITS(bfd_header->desired_min_tx_interval)/1000));
-            ND_PRINT((ndo, "\n\t  Required min Rx Interval:   %4u ms", EXTRACT_32BITS(bfd_header->required_min_rx_interval)/1000));
-            ND_PRINT((ndo, "\n\t  Required min Echo Interval: %4u ms", EXTRACT_32BITS(bfd_header->required_min_echo_interval)/1000));
-            break;
-
-            /* BFDv1 */
-        case (BFD_CONTROL_PORT << 8 | 1):
-            if (ndo->ndo_vflag < 1)
-            {
-                ND_PRINT((ndo, "BFDv%u, %s, State %s, Flags: [%s], length: %u",
+                ND_PRINT((ndo, "\n\tMy Discriminator: 0x%08x", EXTRACT_32BITS(bfd_header->my_discriminator)));
+                ND_PRINT((ndo, ", Your Discriminator: 0x%08x", EXTRACT_32BITS(bfd_header->your_discriminator)));
+                ND_PRINT((ndo, "\n\t  Desired min Tx Interval:    %4u ms", EXTRACT_32BITS(bfd_header->desired_min_tx_interval)/1000));
+                ND_PRINT((ndo, "\n\t  Required min Rx Interval:   %4u ms", EXTRACT_32BITS(bfd_header->required_min_rx_interval)/1000));
+                ND_PRINT((ndo, "\n\t  Required min Echo Interval: %4u ms", EXTRACT_32BITS(bfd_header->required_min_echo_interval)/1000));
+
+                if (flags & BFD_FLAG_AUTH) {
+                    if (auth_print(ndo, pptr))
+                        goto trunc;
+                }
+                break;
+
+                /* BFDv1 */
+            case 1:
+                if (ndo->ndo_vflag < 1)
+                {
+                    ND_PRINT((ndo, "BFDv1, Control, State %s, Flags: [%s], length: %u",
+                           tok2str(bfd_v1_state_values, "unknown (%u)", (flags & 0xc0) >> 6),
+                           bittok2str(bfd_v1_flag_values, "none", flags & 0x3f),
+                           len));
+                    return;
+                }
+
+                ND_PRINT((ndo, "BFDv1, length: %u\n\tControl, State %s, Flags: [%s], Diagnostic: %s (0x%02x)",
+                       len,
+                       tok2str(bfd_v1_state_values, "unknown (%u)", (flags & 0xc0) >> 6),
+                       bittok2str(bfd_v1_flag_values, "none", flags & 0x3f),
+                       tok2str(bfd_diag_values,"unknown",BFD_EXTRACT_DIAG(version_diag)),
+                       BFD_EXTRACT_DIAG(version_diag)));
+
+                ND_PRINT((ndo, "\n\tDetection Timer Multiplier: %u (%u ms Detection time), BFD Length: %u",
+                       bfd_header->detect_time_multiplier,
+                       bfd_header->detect_time_multiplier * EXTRACT_32BITS(bfd_header->desired_min_tx_interval)/1000,
+                       bfd_header->length));
+
+
+                ND_PRINT((ndo, "\n\tMy Discriminator: 0x%08x", EXTRACT_32BITS(bfd_header->my_discriminator)));
+                ND_PRINT((ndo, ", Your Discriminator: 0x%08x", EXTRACT_32BITS(bfd_header->your_discriminator)));
+                ND_PRINT((ndo, "\n\t  Desired min Tx Interval:    %4u ms", EXTRACT_32BITS(bfd_header->desired_min_tx_interval)/1000));
+                ND_PRINT((ndo, "\n\t  Required min Rx Interval:   %4u ms", EXTRACT_32BITS(bfd_header->required_min_rx_interval)/1000));
+                ND_PRINT((ndo, "\n\t  Required min Echo Interval: %4u ms", EXTRACT_32BITS(bfd_header->required_min_echo_interval)/1000));
+
+                if (flags & BFD_FLAG_AUTH) {
+                    if (auth_print(ndo, pptr))
+                        goto trunc;
+                }
+                break;
+
+            default:
+                ND_PRINT((ndo, "BFDv%u, Control, length: %u",
                        version,
-                       tok2str(bfd_port_values, "unknown (%u)", port),
-                       tok2str(bfd_v1_state_values, "unknown (%u)", (bfd_header->flags & 0xc0) >> 6),
-                       bittok2str(bfd_v1_flag_values, "none", bfd_header->flags & 0x3f),
                        len));
-                return;
+                if (ndo->ndo_vflag >= 1) {
+                    if(!print_unknown_data(ndo, pptr,"\n\t",len))
+                        return;
+                }
+                break;
             }
-
-            ND_PRINT((ndo, "BFDv%u, length: %u\n\t%s, State %s, Flags: [%s], Diagnostic: %s (0x%02x)",
-                   version,
-                   len,
-                   tok2str(bfd_port_values, "unknown (%u)", port),
-                   tok2str(bfd_v1_state_values, "unknown (%u)", (bfd_header->flags & 0xc0) >> 6),
-                   bittok2str(bfd_v1_flag_values, "none", bfd_header->flags & 0x3f),
-                   tok2str(bfd_diag_values,"unknown",BFD_EXTRACT_DIAG(bfd_header->version_diag)),
-                   BFD_EXTRACT_DIAG(bfd_header->version_diag)));
-
-            ND_PRINT((ndo, "\n\tDetection Timer Multiplier: %u (%u ms Detection time), BFD Length: %u",
-                   bfd_header->detect_time_multiplier,
-                   bfd_header->detect_time_multiplier * EXTRACT_32BITS(bfd_header->desired_min_tx_interval)/1000,
-                   bfd_header->length));
-
-
-            ND_PRINT((ndo, "\n\tMy Discriminator: 0x%08x", EXTRACT_32BITS(bfd_header->my_discriminator)));
-            ND_PRINT((ndo, ", Your Discriminator: 0x%08x", EXTRACT_32BITS(bfd_header->your_discriminator)));
-            ND_PRINT((ndo, "\n\t  Desired min Tx Interval:    %4u ms", EXTRACT_32BITS(bfd_header->desired_min_tx_interval)/1000));
-            ND_PRINT((ndo, "\n\t  Required min Rx Interval:   %4u ms", EXTRACT_32BITS(bfd_header->required_min_rx_interval)/1000));
-            ND_PRINT((ndo, "\n\t  Required min Echo Interval: %4u ms", EXTRACT_32BITS(bfd_header->required_min_echo_interval)/1000));
-
-            if (bfd_header->flags & BFD_FLAG_AUTH) {
-                if (auth_print(ndo, pptr))
-                    goto trunc;
+        } else if (port == BFD_ECHO_PORT) {
+            /*
+             * Echo packet.
+             */
+            ND_PRINT((ndo, "BFD, Echo, length: %u",
+                   len));
+            if (ndo->ndo_vflag >= 1) {
+                if(!print_unknown_data(ndo, pptr,"\n\t",len))
+                    return;
             }
-            break;
-
-            /* BFDv0 */
-        case (BFD_ECHO_PORT << 8): /* not yet supported - fall through */
-            /* BFDv1 */
-        case (BFD_ECHO_PORT << 8 | 1):
-
-        default:
-            ND_PRINT((ndo, "BFD, %s, length: %u",
-                   tok2str(bfd_port_values, "unknown (%u)", port),
+        } else {
+            /*
+             * Unknown packet type.
+             */
+            ND_PRINT((ndo, "BFD, unknown (%u), length: %u",
+                   port,
                    len));
             if (ndo->ndo_vflag >= 1) {
                     if(!print_unknown_data(ndo, pptr,"\n\t",len))
                             return;
             }
-            break;
         }
         return;
 
index c82f1cc..7db3c6b 100644 (file)
@@ -47,6 +47,8 @@
 #include "af.h"
 #include "l2vpn.h"
 
+static const char tstr[] = "[|BGP]";
+
 struct bgp {
        uint8_t bgp_marker[16];
        uint16_t bgp_len;
@@ -1013,7 +1015,7 @@ trunc:
  */
 #define UPDATE_BUF_BUFLEN(buf, buflen, stringlen) \
     if (stringlen<0) \
-               buflen=0; \
+        buflen=0; \
     else if ((u_int)stringlen>buflen) \
         buflen=0; \
     else { \
@@ -1359,7 +1361,7 @@ trunc:
 
 static int
 bgp_attr_print(netdissect_options *ndo,
-               u_int atype, const u_char *pptr, u_int len)
+               u_int atype, const u_char *pptr, u_int len, const unsigned attr_set_level)
 {
        int i;
        uint16_t af;
@@ -1482,7 +1484,7 @@ bgp_attr_print(netdissect_options *ndo,
                }
                ND_TCHECK2(tptr[0], 8);
                ND_PRINT((ndo, " AS #%s, origin %s",
-                   as_printf(ndo, astostr, sizeof(astostr), EXTRACT_32BITS(tptr)),
+                   as_printf(ndo, astostr, sizeof(astostr), EXTRACT_32BITS(tptr)),
                    ipaddr_string(ndo, tptr + 4)));
                break;
        case BGPTYPE_COMMUNITIES:
@@ -1698,10 +1700,12 @@ bgp_attr_print(netdissect_options *ndo,
                                        bgp_vpn_rd_print(ndo, tptr),
                                        isonsap_string(ndo, tptr+BGP_VPN_RD_LEN,tlen-BGP_VPN_RD_LEN)));
                                 /* rfc986 mapped IPv4 address ? */
-                                if (EXTRACT_32BITS(tptr+BGP_VPN_RD_LEN) ==  0x47000601)
+                                if (tlen == BGP_VPN_RD_LEN + 4 + sizeof(struct in_addr)
+                                    && EXTRACT_32BITS(tptr+BGP_VPN_RD_LEN) ==  0x47000601)
                                     ND_PRINT((ndo, " = %s", ipaddr_string(ndo, tptr+BGP_VPN_RD_LEN+4)));
                                 /* rfc1888 mapped IPv6 address ? */
-                                else if (EXTRACT_24BITS(tptr+BGP_VPN_RD_LEN) ==  0x350000)
+                                else if (tlen == BGP_VPN_RD_LEN + 3 + sizeof(struct in6_addr)
+                                         && EXTRACT_24BITS(tptr+BGP_VPN_RD_LEN) ==  0x350000)
                                     ND_PRINT((ndo, " = %s", ip6addr_string(ndo, tptr+BGP_VPN_RD_LEN+3)));
                                 tptr += tlen;
                                 tlen = 0;
@@ -2280,8 +2284,16 @@ bgp_attr_print(netdissect_options *ndo,
                             ND_PRINT((ndo, "+%x", aflags & 0xf));
                         ND_PRINT((ndo, "]: "));
                     }
-                    /* FIXME check for recursion */
-                    if (!bgp_attr_print(ndo, atype, tptr, alen))
+                    /* The protocol encoding per se allows ATTR_SET to be nested as many times
+                     * as the message can accommodate. This printer used to be able to recurse
+                     * into ATTR_SET contents until the stack exhaustion, but now there is a
+                     * limit on that (if live protocol exchange goes that many levels deep,
+                     * something is probably wrong anyway). Feel free to refine this value if
+                     * you can find the spec with respective normative text.
+                     */
+                    if (attr_set_level == 10)
+                        ND_PRINT((ndo, "(too many nested levels, not recursing)"));
+                    else if (!bgp_attr_print(ndo, atype, tptr, alen, attr_set_level + 1))
                         return 0;
                     tptr += alen;
                     len -= alen;
@@ -2342,6 +2354,8 @@ bgp_capabilities_print(netdissect_options *ndo,
                 ND_TCHECK2(opt[i+2], cap_len);
                 switch (cap_type) {
                 case BGP_CAPCODE_MP:
+                    /* AFI (16 bits), Reserved (8 bits), SAFI (8 bits) */
+                    ND_TCHECK_8BITS(opt + i + 5);
                     ND_PRINT((ndo, "\n\t\tAFI %s (%u), SAFI %s (%u)",
                            tok2str(af_values, "Unknown",
                                       EXTRACT_16BITS(opt+i+2)),
@@ -2351,12 +2365,15 @@ bgp_capabilities_print(netdissect_options *ndo,
                            opt[i+5]));
                     break;
                 case BGP_CAPCODE_RESTART:
+                    /* Restart Flags (4 bits), Restart Time in seconds (12 bits) */
+                    ND_TCHECK_16BITS(opt + i + 2);
                     ND_PRINT((ndo, "\n\t\tRestart Flags: [%s], Restart Time %us",
                            ((opt[i+2])&0x80) ? "R" : "none",
                            EXTRACT_16BITS(opt+i+2)&0xfff));
                     tcap_len-=2;
                     cap_offset=4;
                     while(tcap_len>=4) {
+                        ND_TCHECK_8BITS(opt + i + cap_offset + 3);
                         ND_PRINT((ndo, "\n\t\t  AFI %s (%u), SAFI %s (%u), Forwarding state preserved: %s",
                                tok2str(af_values,"Unknown",
                                           EXTRACT_16BITS(opt+i+cap_offset)),
@@ -2420,7 +2437,7 @@ bgp_capabilities_print(netdissect_options *ndo,
         return;
 
 trunc:
-       ND_PRINT((ndo, "[|BGP]"));
+       ND_PRINT((ndo, "%s", tstr));
 }
 
 static void
@@ -2483,7 +2500,7 @@ bgp_open_print(netdissect_options *ndo,
        }
        return;
 trunc:
-       ND_PRINT((ndo, "[|BGP]"));
+       ND_PRINT((ndo, "%s", tstr));
 }
 
 static void
@@ -2583,7 +2600,7 @@ bgp_update_print(netdissect_options *ndo,
                                goto trunc;
                        if (length < alen)
                                goto trunc;
-                       if (!bgp_attr_print(ndo, atype, p, alen))
+                       if (!bgp_attr_print(ndo, atype, p, alen, 0))
                                goto trunc;
                        p += alen;
                        len -= alen;
@@ -2620,7 +2637,7 @@ bgp_update_print(netdissect_options *ndo,
        }
        return;
 trunc:
-       ND_PRINT((ndo, "[|BGP]"));
+       ND_PRINT((ndo, "%s", tstr));
 }
 
 static void
@@ -2701,7 +2718,7 @@ bgp_notification_print(netdissect_options *ndo,
 
        return;
 trunc:
-       ND_PRINT((ndo, "[|BGP]"));
+       ND_PRINT((ndo, "%s", tstr));
 }
 
 static void
@@ -2735,7 +2752,7 @@ bgp_route_refresh_print(netdissect_options *ndo,
 
         return;
 trunc:
-       ND_PRINT((ndo, "[|BGP]"));
+       ND_PRINT((ndo, "%s", tstr));
 }
 
 static int
@@ -2775,7 +2792,7 @@ bgp_header_print(netdissect_options *ndo,
        }
        return 1;
 trunc:
-       ND_PRINT((ndo, "[|BGP]"));
+       ND_PRINT((ndo, "%s", tstr));
        return 0;
 }
 
@@ -2824,7 +2841,7 @@ bgp_print(netdissect_options *ndo,
                memcpy(&bgp, p, BGP_SIZE);
 
                if (start != p)
-                       ND_PRINT((ndo, " [|BGP]"));
+                       ND_PRINT((ndo, " %s", tstr));
 
                hlen = ntohs(bgp.bgp_len);
                if (hlen < BGP_SIZE) {
@@ -2850,7 +2867,7 @@ bgp_print(netdissect_options *ndo,
        return;
 
 trunc:
-       ND_PRINT((ndo, " [|BGP]"));
+       ND_PRINT((ndo, "%s", tstr));
 }
 
 /*
index d87911f..c076f42 100644 (file)
@@ -358,7 +358,7 @@ bootp_print(netdissect_options *ndo,
        if (*bp->bp_sname) {
                ND_PRINT((ndo, "\n\t  sname \""));
                if (fn_printztn(ndo, bp->bp_sname, (u_int)sizeof bp->bp_sname,
-                   ndo->ndo_snapend)) {
+                   ndo->ndo_snapend) == 0) {
                        ND_PRINT((ndo, "\""));
                        ND_PRINT((ndo, "%s", tstr + 1));
                        return;
@@ -369,7 +369,7 @@ bootp_print(netdissect_options *ndo,
        if (*bp->bp_file) {
                ND_PRINT((ndo, "\n\t  file \""));
                if (fn_printztn(ndo, bp->bp_file, (u_int)sizeof bp->bp_file,
-                   ndo->ndo_snapend)) {
+                   ndo->ndo_snapend) == 0) {
                        ND_PRINT((ndo, "\""));
                        ND_PRINT((ndo, "%s", tstr + 1));
                        return;
@@ -378,7 +378,7 @@ bootp_print(netdissect_options *ndo,
        }
 
        /* Decode the vendor buffer */
-       ND_TCHECK(bp->bp_vend[0]);
+       ND_TCHECK2(bp->bp_vend[0], 4);
        if (memcmp((const char *)bp->bp_vend, vm_rfc1048,
                    sizeof(uint32_t)) == 0)
                rfc1048_print(ndo, bp->bp_vend);
@@ -388,6 +388,7 @@ bootp_print(netdissect_options *ndo,
        else {
                uint32_t ul;
 
+               ND_TCHECK_32BITS(&bp->bp_vend);
                ul = EXTRACT_32BITS(&bp->bp_vend);
                if (ul != 0)
                        ND_PRINT((ndo, "\n\t  Vendor-#0x%x", ul));
index 6e25264..bc3feb7 100644 (file)
@@ -530,7 +530,8 @@ static const struct tok dccp_option_values[] = {
        { 0, NULL }
 };
 
-static int dccp_print_option(netdissect_options *ndo, const u_char *option, u_int hlen)
+static int
+dccp_print_option(netdissect_options *ndo, const u_char *option, u_int hlen)
 {
        uint8_t optlen, i;
 
@@ -623,16 +624,54 @@ static int dccp_print_option(netdissect_options *ndo, const u_char *option, u_in
                        }
                        break;
                case 41:
-                       if (optlen == 4)
+               /*
+                * 13.1.  Timestamp Option
+                *
+                *  +--------+--------+--------+--------+--------+--------+
+                *  |00101001|00000110|          Timestamp Value          |
+                *  +--------+--------+--------+--------+--------+--------+
+                *   Type=41  Length=6
+                */
+                       if (optlen == 6)
                                ND_PRINT((ndo, " %u", EXTRACT_32BITS(option + 2)));
                        else
-                               ND_PRINT((ndo, " optlen != 4"));
+                               ND_PRINT((ndo, " [optlen != 6]"));
                        break;
                case 42:
-                       if (optlen == 4)
+               /*
+                * 13.3.  Timestamp Echo Option
+                *
+                *  +--------+--------+--------+--------+--------+--------+
+                *  |00101010|00000110|           Timestamp Echo          |
+                *  +--------+--------+--------+--------+--------+--------+
+                *   Type=42    Len=6
+                *
+                *  +--------+--------+------- ... -------+--------+--------+
+                *  |00101010|00001000|  Timestamp Echo   |   Elapsed Time  |
+                *  +--------+--------+------- ... -------+--------+--------+
+                *   Type=42    Len=8       (4 bytes)
+                *
+                *  +--------+--------+------- ... -------+------- ... -------+
+                *  |00101010|00001010|  Timestamp Echo   |    Elapsed Time   |
+                *  +--------+--------+------- ... -------+------- ... -------+
+                *   Type=42   Len=10       (4 bytes)           (4 bytes)
+                */
+                       switch (optlen) {
+                       case 6:
                                ND_PRINT((ndo, " %u", EXTRACT_32BITS(option + 2)));
-                       else
-                               ND_PRINT((ndo, " optlen != 4"));
+                               break;
+                       case 8:
+                               ND_PRINT((ndo, " %u", EXTRACT_32BITS(option + 2)));
+                               ND_PRINT((ndo, " (elapsed time %u)", EXTRACT_16BITS(option + 6)));
+                               break;
+                       case 10:
+                               ND_PRINT((ndo, " %u", EXTRACT_32BITS(option + 2)));
+                               ND_PRINT((ndo, " (elapsed time %u)", EXTRACT_32BITS(option + 6)));
+                               break;
+                       default:
+                               ND_PRINT((ndo, " [optlen != 6 or 8 or 10]"));
+                               break;
+                       }
                        break;
                case 43:
                        if (optlen == 6)
@@ -640,7 +679,7 @@ static int dccp_print_option(netdissect_options *ndo, const u_char *option, u_in
                        else if (optlen == 4)
                                ND_PRINT((ndo, " %u", EXTRACT_16BITS(option + 2)));
                        else
-                               ND_PRINT((ndo, " optlen != 4 or 6"));
+                               ND_PRINT((ndo, " [optlen != 4 or 6]"));
                        break;
                case 44:
                        if (optlen > 2) {
index de7de27..6e2c791 100644 (file)
 struct mbuf;
 struct rtentry;
 
-#ifdef HAVE_NETDNET_DNETDB_H
-#include <netdnet/dnetdb.h>
-#endif
-
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
@@ -75,12 +71,6 @@ typedef union etheraddress etheraddr;        /* Ethernet address */
 #define        AREASHIFT       10              /* bit-offset for area field */
 #define NODEMASK       01777           /* mask for node address field */
 
-#define DN_MAXADDL     20              /* max size of DECnet address */
-struct dn_naddr {
-       uint16_t        a_len;          /* length of address */
-       uint8_t a_addr[DN_MAXADDL]; /* address as bytes */
-};
-
 /*
  * Define long and short header formats.
  */
@@ -492,10 +482,6 @@ static int print_elist(const char *, u_int);
 static int print_nsp(netdissect_options *, const u_char *, u_int);
 static void print_reason(netdissect_options *, int);
 
-#ifndef HAVE_NETDNET_DNETDB_H_DNET_HTOA
-extern char *dnet_htoa(struct dn_naddr *);
-#endif
-
 void
 decnet_print(netdissect_options *ndo,
              register const u_char *ap, register u_int length,
@@ -1252,22 +1238,3 @@ dnnum_string(netdissect_options *ndo, u_short dnaddr)
        snprintf(str, siz, "%d.%d", area, node);
        return(str);
 }
-
-const char *
-dnname_string(netdissect_options *ndo, u_short dnaddr)
-{
-#ifdef HAVE_DNET_HTOA
-       struct dn_naddr dna;
-       char *dnname;
-
-       dna.a_len = sizeof(short);
-       memcpy((char *)dna.a_addr, (char *)&dnaddr, sizeof(short));
-       dnname = dnet_htoa(&dna);
-       if(dnname != NULL)
-               return (strdup(dnname));
-       else
-               return(dnnum_string(ndo, dnaddr));
-#else
-       return(dnnum_string(ndo, dnaddr));      /* punt */
-#endif
-}
index 9a2b9e8..e29a9b4 100644 (file)
@@ -582,6 +582,13 @@ ns_print(netdissect_options *ndo,
        register const u_char *cp;
        uint16_t b2;
 
+       if(length < sizeof(*np)) {
+               ND_PRINT((ndo, "domain"));
+               ND_PRINT((ndo, " [length %u < %zu]", length, sizeof(*np)));
+               ND_PRINT((ndo, " (invalid)"));
+               return;
+       }
+
        np = (const HEADER *)bp;
        ND_TCHECK(*np);
        /* get the byte-order right */
index 60f836e..36a8d5b 100644 (file)
@@ -32,6 +32,8 @@
 #include "addrtoname.h"
 
 /*
+ * See: RFC 1075 and draft-ietf-idmr-dvmrp-v3
+ *
  * DVMRP message types and flag values shamelessly stolen from
  * mrouted/dvmrp.h.
  */
 static int print_probe(netdissect_options *, const u_char *, const u_char *, u_int);
 static int print_report(netdissect_options *, const u_char *, const u_char *, u_int);
 static int print_neighbors(netdissect_options *, const u_char *, const u_char *, u_int);
-static int print_neighbors2(netdissect_options *, const u_char *, const u_char *, u_int);
+static int print_neighbors2(netdissect_options *, const u_char *, const u_char *, u_int, uint8_t, uint8_t);
 static int print_prune(netdissect_options *, const u_char *);
 static int print_graft(netdissect_options *, const u_char *);
 static int print_graft_ack(netdissect_options *, const u_char *);
 
-static uint32_t target_level;
-
 void
 dvmrp_print(netdissect_options *ndo,
             register const u_char *bp, register u_int len)
 {
        register const u_char *ep;
        register u_char type;
+       uint8_t major_version, minor_version;
 
        ep = (const u_char *)ndo->ndo_snapend;
        if (bp >= ep)
@@ -118,15 +119,15 @@ dvmrp_print(netdissect_options *ndo,
        case DVMRP_NEIGHBORS2:
                ND_PRINT((ndo, " Neighbors2"));
                /*
-                * extract version and capabilities from IGMP group
-                * address field
+                * extract version from IGMP group address field
                 */
                bp -= 4;
                ND_TCHECK2(bp[0], 4);
-               target_level = (bp[0] << 24) | (bp[1] << 16) |
-                   (bp[2] << 8) | bp[3];
+               major_version = *(bp + 3);
+               minor_version = *(bp + 2);
                bp += 4;
-               if (print_neighbors2(ndo, bp, ep, len) < 0)
+               if (print_neighbors2(ndo, bp, ep, len, major_version,
+                   minor_version) < 0)
                        goto trunc;
                break;
 
@@ -230,7 +231,7 @@ print_probe(netdissect_options *ndo,
                ND_PRINT((ndo, " [|}"));
                return (0);
        }
-       genid = (bp[0] << 24) | (bp[1] << 16) | (bp[2] << 8) | bp[3];
+       genid = EXTRACT_32BITS(bp);
        bp += 4;
        len -= 4;
        ND_PRINT((ndo, ndo->ndo_vflag > 1 ? "\n\t" : " "));
@@ -283,15 +284,14 @@ trunc:
 static int
 print_neighbors2(netdissect_options *ndo,
                  register const u_char *bp, register const u_char *ep,
-                 register u_int len)
+                 register u_int len, uint8_t major_version,
+                 uint8_t minor_version)
 {
        const u_char *laddr;
        register u_char metric, thresh, flags;
        register int ncount;
 
-       ND_PRINT((ndo, " (v %d.%d):",
-              (int)target_level & 0xff,
-              (int)(target_level >> 8) & 0xff));
+       ND_PRINT((ndo, " (v %d.%d):", major_version, minor_version));
 
        while (len > 0 && bp < ep) {
                ND_TCHECK2(bp[0], 8);
index aa11341..c9b3526 100644 (file)
@@ -353,6 +353,7 @@ eigrp_print(netdissect_options *ndo, register const u_char *pptr, register u_int
             }
             byte_length = (bit_length + 7) / 8; /* variable length encoding */
             memset(prefix, 0, 4);
+            ND_TCHECK2(tlv_ptr.eigrp_tlv_ip_int->destination, byte_length);
             memcpy(prefix,&tlv_ptr.eigrp_tlv_ip_int->destination,byte_length);
 
             ND_PRINT((ndo, "\n\t    IPv4 prefix: %15s/%u, nexthop: ",
@@ -387,6 +388,7 @@ eigrp_print(netdissect_options *ndo, register const u_char *pptr, register u_int
             }
             byte_length = (bit_length + 7) / 8; /* variable length encoding */
             memset(prefix, 0, 4);
+            ND_TCHECK2(tlv_ptr.eigrp_tlv_ip_ext->destination, byte_length);
             memcpy(prefix,&tlv_ptr.eigrp_tlv_ip_ext->destination,byte_length);
 
             ND_PRINT((ndo, "\n\t    IPv4 prefix: %15s/%u, nexthop: ",
index d12b97d..6fabff1 100644 (file)
@@ -191,8 +191,8 @@ int esp_print_decrypt_buffer_by_ikev2(netdissect_options *ndo,
        const u_char *iv;
        unsigned int len;
        EVP_CIPHER_CTX *ctx;
-       unsigned int block_size, output_buffer_size;
-       u_char *output_buffer;
+       unsigned int block_size, buffer_size;
+       u_char *input_buffer, *output_buffer;
 
        /* initiator arg is any non-zero value */
        if(initiator) initiator=1;
@@ -227,19 +227,39 @@ int esp_print_decrypt_buffer_by_ikev2(netdissect_options *ndo,
                (*ndo->ndo_warning)(ndo, "espkey init failed");
        set_cipher_parameters(ctx, NULL, NULL, iv, 0);
        /*
-        * Allocate a buffer for the decrypted data.
-        * The output buffer must be separate from the input buffer, and
-        * its size must be a multiple of the cipher block size.
+        * Allocate buffers for the encrypted and decrypted data.
+        * Both buffers' sizes must be a multiple of the cipher block
+        * size, and the output buffer must be separate from the input
+        * buffer.
         */
        block_size = (unsigned int)EVP_CIPHER_CTX_block_size(ctx);
-       output_buffer_size = len + (block_size - len % block_size);
-       output_buffer = (u_char *)malloc(output_buffer_size);
+       buffer_size = len + (block_size - len % block_size);
+
+       /*
+        * Attempt to allocate the input buffer.
+        */
+       input_buffer = (u_char *)malloc(buffer_size);
+       if (input_buffer == NULL) {
+               EVP_CIPHER_CTX_free(ctx);
+               (*ndo->ndo_error)(ndo, "can't allocate memory for encrypted data buffer");
+       }
+       /*
+        * Copy the input data to the encrypted data buffer, and pad it
+        * with zeroes.
+        */
+       memcpy(input_buffer, buf, len);
+       memset(input_buffer + len, 0, buffer_size - len);
+
+       /*
+        * Attempt to allocate the output buffer.
+        */
+       output_buffer = (u_char *)malloc(buffer_size);
        if (output_buffer == NULL) {
-               (*ndo->ndo_warning)(ndo, "can't allocate memory for decryption buffer");
+               free(input_buffer);
                EVP_CIPHER_CTX_free(ctx);
-               return 0;
+               (*ndo->ndo_error)(ndo, "can't allocate memory for decryption buffer");
        }
-       EVP_Cipher(ctx, output_buffer, buf, len);
+       EVP_Cipher(ctx, output_buffer, input_buffer, len);
        EVP_CIPHER_CTX_free(ctx);
 
        /*
@@ -247,6 +267,7 @@ int esp_print_decrypt_buffer_by_ikev2(netdissect_options *ndo,
         * but changing this would require a more complicated fix.
         */
        memcpy(buf, output_buffer, len);
+       free(input_buffer);
        free(output_buffer);
 
        ndo->ndo_packetp = buf;
@@ -287,7 +308,6 @@ static u_int hexdigit(netdissect_options *ndo, char hex)
                return (hex - 'a' + 10);
        else {
                (*ndo->ndo_error)(ndo, "invalid hex digit %c in espsecret\n", hex);
-               return 0;
        }
 }
 
@@ -398,7 +418,7 @@ espprint_decode_encalgo(netdissect_options *ndo,
 USES_APPLE_RST
 
 /*
- * for the moment, ignore the auth algorith, just hard code the authenticator
+ * for the moment, ignore the auth algorithm, just hard code the authenticator
  * length. Need to research how openssl looks up HMAC stuff.
  */
 static int
@@ -521,7 +541,6 @@ static void esp_print_decode_onesecret(netdissect_options *ndo, char *line,
                if (secretfile == NULL) {
                        (*ndo->ndo_error)(ndo, "print_esp: can't open %s: %s\n",
                            filename, strerror(errno));
-                       return;
                }
 
                while (fgets(fileline, sizeof(fileline)-1, secretfile) != NULL) {
@@ -551,6 +570,10 @@ static void esp_print_decode_onesecret(netdissect_options *ndo, char *line,
                uint32_t spino;
 
                spistr = strsep(&spikey, "@");
+               if (spistr == NULL) {
+                       (*ndo->ndo_warning)(ndo, "print_esp: failed to find the @ token");
+                       return;
+               }
 
                spino = strtoul(spistr, &foo, 0);
                if (spistr == foo || !spikey) {
@@ -660,8 +683,8 @@ esp_print(netdissect_options *ndo,
        const u_char *ivoff;
        const u_char *p;
        EVP_CIPHER_CTX *ctx;
-       unsigned int block_size, output_buffer_size;
-       u_char *output_buffer;
+       unsigned int block_size, buffer_size;
+       u_char *input_buffer, *output_buffer;
 #endif
 
        esp = (const struct newesp *)bp;
@@ -777,21 +800,41 @@ esp_print(netdissect_options *ndo,
                        len = ep - (p + ivlen);
 
                        /*
-                        * Allocate a buffer for the decrypted data.
-                        * The output buffer must be separate from the
-                        * input buffer, and its size must be a multiple
-                        * of the cipher block size.
+                        * Allocate buffers for the encrypted and decrypted
+                        * data.  Both buffers' sizes must be a multiple of
+                        * the cipher block size, and the output buffer must
+                        * be separate from the input buffer.
                         */
                        block_size = (unsigned int)EVP_CIPHER_CTX_block_size(ctx);
-                       output_buffer_size = len + (block_size - len % block_size);
-                       output_buffer = (u_char *)malloc(output_buffer_size);
+                       buffer_size = len + (block_size - len % block_size);
+
+                       /*
+                        * Attempt to allocate the input buffer.
+                        */
+                       input_buffer = (u_char *)malloc(buffer_size);
+                       if (input_buffer == NULL) {
+                               EVP_CIPHER_CTX_free(ctx);
+                               (*ndo->ndo_error)(ndo, "can't allocate memory for encrypted data buffer");
+                       }
+                       /*
+                        * Copy the input data to the encrypted data buffer,
+                        * and pad it with zeroes.
+                        */
+                       memcpy(input_buffer, p + ivlen, len);
+                       memset(input_buffer + len, 0, buffer_size - len);
+
+                       /*
+                        * Attempt to allocate the output buffer.
+                        */
+                       output_buffer = (u_char *)malloc(buffer_size);
                        if (output_buffer == NULL) {
-                               (*ndo->ndo_warning)(ndo, "can't allocate memory for decryption buffer");
+                               free(input_buffer);
                                EVP_CIPHER_CTX_free(ctx);
-                               return -1;
+                               (*ndo->ndo_error)(ndo, "can't allocate memory for decryption buffer");
                        }
 
-                       EVP_Cipher(ctx, output_buffer, p + ivlen, len);
+                       EVP_Cipher(ctx, output_buffer, input_buffer, len);
+                       free(input_buffer);
                        EVP_CIPHER_CTX_free(ctx);
                        /*
                         * XXX - of course this is wrong, because buf is a
index 7181eb4..8a1a53a 100644 (file)
@@ -457,6 +457,10 @@ mfr_print(netdissect_options *ndo,
  */
 
     ND_TCHECK2(*p, 4); /* minimum frame header length */
+    if (length < 4) {
+        ND_PRINT((ndo, "Message too short (%u bytes)", length));
+        return length;
+    }
 
     if ((p[0] & MFR_BEC_MASK) == MFR_CTRL_FRAME && p[1] == 0) {
         ND_PRINT((ndo, "FRF.16 Control, Flags [%s], %s, length %u",
@@ -493,6 +497,11 @@ mfr_print(netdissect_options *ndo,
             switch (ie_type) {
 
             case MFR_CTRL_IE_MAGIC_NUM:
+                /* FRF.16.1 Section 3.4.3 Magic Number Information Element */
+                if (ie_len != 4) {
+                    ND_PRINT((ndo, "(invalid length)"));
+                    break;
+                }
                 ND_PRINT((ndo, "0x%08x", EXTRACT_32BITS(tptr)));
                 break;
 
index 11a6a93..c20d1e1 100644 (file)
@@ -68,8 +68,8 @@ hncp_print(netdissect_options *ndo,
 #define HNCP_EXTERNAL_CONNECTION   33
 #define HNCP_DELEGATED_PREFIX      34
 #define HNCP_PREFIX_POLICY         43
-#define HNCP_DHCPV4_DATA           37
-#define HNCP_DHCPV6_DATA           38
+#define HNCP_DHCPV4_DATA           37 /* This is correct, see RFC 7788 Errata ID 5113. */
+#define HNCP_DHCPV6_DATA           38 /* idem */
 #define HNCP_ASSIGNED_PREFIX       35
 #define HNCP_NODE_ADDRESS          36
 #define HNCP_DNS_DELEGATED_ZONE    39
@@ -158,10 +158,10 @@ is_ipv4_mapped_address(const u_char *addr)
 static const char *
 format_nid(const u_char *data)
 {
-    static char buf[4][11+5];
+    static char buf[4][sizeof("01:01:01:01")];
     static int i = 0;
     i = (i + 1) % 4;
-    snprintf(buf[i], 16, "%02x:%02x:%02x:%02x",
+    snprintf(buf[i], sizeof(buf[i]), "%02x:%02x:%02x:%02x",
              data[0], data[1], data[2], data[3]);
     return buf[i];
 }
@@ -169,10 +169,10 @@ format_nid(const u_char *data)
 static const char *
 format_256(const u_char *data)
 {
-    static char buf[4][64+5];
+    static char buf[4][sizeof("0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef")];
     static int i = 0;
     i = (i + 1) % 4;
-    snprintf(buf[i], 28, "%016" PRIx64 "%016" PRIx64 "%016" PRIx64 "%016" PRIx64,
+    snprintf(buf[i], sizeof(buf[i]), "%016" PRIx64 "%016" PRIx64 "%016" PRIx64 "%016" PRIx64,
          EXTRACT_64BITS(data),
          EXTRACT_64BITS(data + 8),
          EXTRACT_64BITS(data + 16),
@@ -229,6 +229,8 @@ print_prefix(netdissect_options *ndo, const u_char *prefix, u_int max_length)
         plenbytes += 1 + IPV4_MAPPED_HEADING_LEN;
     } else {
         plenbytes = decode_prefix6(ndo, prefix, max_length, buf, sizeof(buf));
+        if (plenbytes < 0)
+            return plenbytes;
     }
 
     ND_PRINT((ndo, "%s", buf));
index c33f83a..170d543 100644 (file)
@@ -400,7 +400,7 @@ icmp_print(netdissect_options *ndo, const u_char *bp, u_int plen, const u_char *
 
                        default:
                                (void)snprintf(buf, sizeof(buf),
-                                       "%s protocol %d port %d unreachable",
+                                       "%s protocol %u port %u unreachable",
                                        ipaddr_string(ndo, &oip->ip_dst),
                                        oip->ip_p, dport);
                                break;
@@ -506,7 +506,7 @@ icmp_print(netdissect_options *ndo, const u_char *bp, u_int plen, const u_char *
                        break;
 
                default:
-                       (void)snprintf(buf, sizeof(buf), "time exceeded-#%d",
+                       (void)snprintf(buf, sizeof(buf), "time exceeded-#%u",
                            dp->icmp_code);
                        break;
                }
@@ -515,11 +515,11 @@ icmp_print(netdissect_options *ndo, const u_char *bp, u_int plen, const u_char *
        case ICMP_PARAMPROB:
                if (dp->icmp_code)
                        (void)snprintf(buf, sizeof(buf),
-                           "parameter problem - code %d", dp->icmp_code);
+                           "parameter problem - code %u", dp->icmp_code);
                else {
                        ND_TCHECK(dp->icmp_pptr);
                        (void)snprintf(buf, sizeof(buf),
-                           "parameter problem - octet %d", dp->icmp_pptr);
+                           "parameter problem - octet %u", dp->icmp_pptr);
                }
                break;
 
@@ -557,13 +557,15 @@ icmp_print(netdissect_options *ndo, const u_char *bp, u_int plen, const u_char *
        }
        ND_PRINT((ndo, "ICMP %s, length %u", str, plen));
        if (ndo->ndo_vflag && !fragmented) { /* don't attempt checksumming if this is a frag */
-               uint16_t sum, icmp_sum;
-
                if (ND_TTEST2(*bp, plen)) {
+                       uint16_t sum;
+
                        vec[0].ptr = (const uint8_t *)(const void *)dp;
                        vec[0].len = plen;
                        sum = in_cksum(vec, 1);
                        if (sum != 0) {
+                               uint16_t icmp_sum;
+                               ND_TCHECK_16BITS(&dp->icmp_cksum);
                                icmp_sum = EXTRACT_16BITS(&dp->icmp_cksum);
                                ND_PRINT((ndo, " (wrong icmp cksum %x (->%x)!)",
                                             icmp_sum,
index 42fe19f..5cef0ef 100644 (file)
 #include "udp.h"
 #include "ah.h"
 
+static const char icmp6_tstr[] = " [|icmp6]";
+static const char rpl_tstr[] = " [|rpl]";
+static const char mldv2_tstr[] = " [|mldv2]";
+
 /*     NetBSD: icmp6.h,v 1.13 2000/08/03 16:30:37 itojun Exp   */
 /*     $KAME: icmp6.h,v 1.22 2000/08/03 15:25:16 jinmei Exp $  */
 
@@ -683,10 +687,11 @@ rpl_dio_printopt(netdissect_options *ndo,
                 }
                 opt = (const struct rpl_dio_genoption *)(((const char *)opt) + optlen);
                 length -= optlen;
+                ND_TCHECK(opt->rpl_dio_len);
         }
         return;
 trunc:
-       ND_PRINT((ndo," [|truncated]"));
+       ND_PRINT((ndo, "%s", rpl_tstr));
        return;
 }
 
@@ -715,7 +720,7 @@ rpl_dio_print(netdissect_options *ndo,
         }
        return;
 trunc:
-       ND_PRINT((ndo," [|truncated]"));
+       ND_PRINT((ndo, "%s", rpl_tstr));
        return;
 }
 
@@ -756,7 +761,7 @@ rpl_dao_print(netdissect_options *ndo,
        return;
 
 trunc:
-       ND_PRINT((ndo," [|truncated]"));
+       ND_PRINT((ndo, "%s", rpl_tstr));
        return;
 
 tooshort:
@@ -800,7 +805,7 @@ rpl_daoack_print(netdissect_options *ndo,
        return;
 
 trunc:
-       ND_PRINT((ndo," [|dao-truncated]"));
+       ND_PRINT((ndo, "%s", rpl_tstr));
        return;
 
 tooshort:
@@ -859,7 +864,7 @@ rpl_print(netdissect_options *ndo,
 
 #if 0
 trunc:
-       ND_PRINT((ndo," [|truncated]"));
+       ND_PRINT((ndo, "%s", rpl_tstr));
        return;
 #endif
 
@@ -1034,7 +1039,7 @@ icmp6_print(netdissect_options *ndo,
                        p = (const struct nd_router_advert *)dp;
                        ND_TCHECK(p->nd_ra_retransmit);
                        ND_PRINT((ndo,"\n\thop limit %u, Flags [%s]" \
-                                  ", pref %s, router lifetime %us, reachable time %us, retrans time %us",
+                                  ", pref %s, router lifetime %us, reachable time %ums, retrans timer %ums",
                                   (u_int)p->nd_ra_curhoplimit,
                                   bittok2str(icmp6_opt_ra_flag_values,"none",(p->nd_ra_flags_reserved)),
                                   get_rtpref(p->nd_ra_flags_reserved),
@@ -1157,7 +1162,7 @@ icmp6_print(netdissect_options *ndo,
                 ND_PRINT((ndo,", length %u", length));
        return;
 trunc:
-       ND_PRINT((ndo, "[|icmp6]"));
+       ND_PRINT((ndo, "%s", icmp6_tstr));
 }
 
 static const struct udphdr *
@@ -1381,8 +1386,8 @@ icmp6_opt_print(netdissect_options *ndo, const u_char *bp, int resid)
        }
        return;
 
- trunc:
-       ND_PRINT((ndo, "[ndp opt]"));
+trunc:
+       ND_PRINT((ndo, "%s", icmp6_tstr));
        return;
 #undef ECHECK
 }
@@ -1457,7 +1462,7 @@ mldv2_report_print(netdissect_options *ndo, const u_char *bp, u_int len)
     }
     return;
 trunc:
-    ND_PRINT((ndo,"[|icmp6]"));
+    ND_PRINT((ndo, "%s", mldv2_tstr));
     return;
 }
 
@@ -1523,7 +1528,7 @@ mldv2_query_print(netdissect_options *ndo, const u_char *bp, u_int len)
     ND_PRINT((ndo,"]"));
     return;
 trunc:
-    ND_PRINT((ndo,"[|icmp6]"));
+    ND_PRINT((ndo, "%s", mldv2_tstr));
     return;
 }
 
@@ -1810,7 +1815,7 @@ icmp6_nodeinfo_print(netdissect_options *ndo, u_int icmp6len, const u_char *bp,
        return;
 
 trunc:
-       ND_PRINT((ndo, "[|icmp6]"));
+       ND_PRINT((ndo, "%s", icmp6_tstr));
 }
 
 static void
@@ -1945,7 +1950,7 @@ icmp6_rrenum_print(netdissect_options *ndo, const u_char *bp, const u_char *ep)
        return;
 
 trunc:
-       ND_PRINT((ndo,"[|icmp6]"));
+       ND_PRINT((ndo, "%s", icmp6_tstr));
 }
 
 /*
index f71c145..89b0ffc 100644 (file)
@@ -7,16 +7,19 @@
 #include <netdissect-stdinc.h>
 
 #include "netdissect.h"
+#include "extract.h"
+
+static const char tstr[] = "[|ipnet]";
 
 typedef struct ipnet_hdr {
-       uint8_t         iph_version;
-       uint8_t         iph_family;
-       uint16_t        iph_htype;
-       uint32_t        iph_pktlen;
-       uint32_t        iph_ifindex;
-       uint32_t        iph_grifindex;
-       uint32_t        iph_zsrc;
-       uint32_t        iph_zdst;
+       nd_uint8_t      iph_version;
+       nd_uint8_t      iph_family;
+       nd_uint16_t     iph_htype;
+       nd_uint32_t     iph_pktlen;
+       nd_uint32_t     iph_ifindex;
+       nd_uint32_t     iph_grifindex;
+       nd_uint32_t     iph_zsrc;
+       nd_uint32_t     iph_zdst;
 } ipnet_hdr_t;
 
 #define        IPH_AF_INET     2               /* Matches Solaris's AF_INET */
@@ -36,21 +39,26 @@ ipnet_hdr_print(netdissect_options *ndo, const u_char *bp, u_int length)
        const ipnet_hdr_t *hdr;
        hdr = (const ipnet_hdr_t *)bp;
 
-       ND_PRINT((ndo, "%d > %d", hdr->iph_zsrc, hdr->iph_zdst));
+       ND_TCHECK(*hdr);
+       ND_PRINT((ndo, "%d > %d", EXTRACT_32BITS(hdr->iph_zsrc),
+                 EXTRACT_32BITS(hdr->iph_zdst)));
 
        if (!ndo->ndo_qflag) {
                ND_PRINT((ndo,", family %s (%d)",
                           tok2str(ipnet_values, "Unknown",
-                                  hdr->iph_family),
-                          hdr->iph_family));
+                                  EXTRACT_8BITS(&hdr->iph_family)),
+                          EXTRACT_8BITS(&hdr->iph_family)));
         } else {
                ND_PRINT((ndo,", %s",
                           tok2str(ipnet_values,
                                   "Unknown Ethertype (0x%04x)",
-                                  hdr->iph_family)));
+                                 EXTRACT_8BITS(&hdr->iph_family))));
         }
 
        ND_PRINT((ndo, ", length %u: ", length));
+       return;
+trunc:
+       ND_PRINT((ndo, " %s", tstr));
 }
 
 static void
@@ -58,10 +66,8 @@ ipnet_print(netdissect_options *ndo, const u_char *p, u_int length, u_int caplen
 {
        const ipnet_hdr_t *hdr;
 
-       if (caplen < sizeof(ipnet_hdr_t)) {
-               ND_PRINT((ndo, "[|ipnet]"));
-               return;
-       }
+       if (caplen < sizeof(ipnet_hdr_t))
+               goto trunc;
 
        if (ndo->ndo_eflag)
                ipnet_hdr_print(ndo, p, length);
@@ -71,7 +77,8 @@ ipnet_print(netdissect_options *ndo, const u_char *p, u_int length, u_int caplen
        hdr = (const ipnet_hdr_t *)p;
        p += sizeof(ipnet_hdr_t);
 
-       switch (hdr->iph_family) {
+       ND_TCHECK2(hdr->iph_family, 1);
+       switch (EXTRACT_8BITS(&hdr->iph_family)) {
 
        case IPH_AF_INET:
                ip_print(ndo, p, length);
@@ -90,6 +97,9 @@ ipnet_print(netdissect_options *ndo, const u_char *p, u_int length, u_int caplen
                        ND_DEFAULTPRINT(p, caplen);
                break;
        }
+       return;
+trunc:
+       ND_PRINT((ndo, " %s", tstr));
 }
 
 /*
index 04374b0..951c8a7 100644 (file)
@@ -1769,6 +1769,7 @@ ikev1_n_print(netdissect_options *ndo, u_char tpay _U_,
                    }
                case IPSECDOI_NTYPE_REPLAY_STATUS:
                        ND_PRINT((ndo," status=("));
+                       ND_TCHECK_32BITS(cp);
                        ND_PRINT((ndo,"replay detection %sabled",
                                  EXTRACT_32BITS(cp) ? "en" : "dis"));
                        ND_PRINT((ndo,")"));
index ff1de9c..a969895 100644 (file)
@@ -1354,6 +1354,11 @@ juniper_parse_header(netdissect_options *ndo,
                        lp->s,
                        l2info->cookie_len));
 
+            if (l2info->cookie_len > 8) {
+                ND_PRINT((ndo, " (invalid)"));
+                return 0;
+            }
+
             if (l2info->cookie_len > 0) {
                 ND_TCHECK2(p[0], l2info->cookie_len);
                 if (ndo->ndo_eflag)
index d70d434..7622bf3 100644 (file)
@@ -23,6 +23,8 @@
 
 /* \summary: Layer Two Tunneling Protocol (L2TP) printer */
 
+/* specification: RFC 2661 */
+
 #ifdef HAVE_CONFIG_H
 #include "config.h"
 #endif
@@ -143,7 +145,7 @@ static const struct tok l2tp_msgtype2str[] = {
 #define L2TP_AVP_PRIVATE_GRP_ID                37 /* Private Group ID */
 #define L2TP_AVP_RX_CONN_SPEED         38 /* (Rx) Connect Speed */
 #define L2TP_AVP_SEQ_REQUIRED          39 /* Sequencing Required */
-#define L2TP_AVP_PPP_DISCON_CC         46 /* PPP Disconnect Cause Code */
+#define L2TP_AVP_PPP_DISCON_CC         46 /* PPP Disconnect Cause Code - RFC 3145 */
 
 static const struct tok l2tp_avp2str[] = {
        { L2TP_AVP_MSGTYPE,             "MSGTYPE" },
@@ -282,15 +284,15 @@ print_octets(netdissect_options *ndo, const u_char *dat, u_int length)
 }
 
 static void
-print_16bits_val(netdissect_options *ndo, const uint16_t *dat)
+print_16bits_val(netdissect_options *ndo, const uint8_t *dat)
 {
        ND_PRINT((ndo, "%u", EXTRACT_16BITS(dat)));
 }
 
 static void
-print_32bits_val(netdissect_options *ndo, const uint32_t *dat)
+print_32bits_val(netdissect_options *ndo, const uint8_t *dat)
 {
-       ND_PRINT((ndo, "%lu", (u_long)EXTRACT_32BITS(dat)));
+       ND_PRINT((ndo, "%u", EXTRACT_32BITS(dat)));
 }
 
 /***********************************/
@@ -299,28 +301,24 @@ print_32bits_val(netdissect_options *ndo, const uint32_t *dat)
 static void
 l2tp_msgtype_print(netdissect_options *ndo, const u_char *dat, u_int length)
 {
-       const uint16_t *ptr = (const uint16_t *)dat;
-
        if (length < 2) {
                ND_PRINT((ndo, "AVP too short"));
                return;
        }
        ND_PRINT((ndo, "%s", tok2str(l2tp_msgtype2str, "MSGTYPE-#%u",
-           EXTRACT_16BITS(ptr))));
+           EXTRACT_16BITS(dat))));
 }
 
 static void
 l2tp_result_code_print(netdissect_options *ndo, const u_char *dat, u_int length)
 {
-       const uint16_t *ptr = (const uint16_t *)dat;
-
        /* Result Code */
        if (length < 2) {
                ND_PRINT((ndo, "AVP too short"));
                return;
        }
-       ND_PRINT((ndo, "%u", EXTRACT_16BITS(ptr)));
-       ptr++;
+       ND_PRINT((ndo, "%u", EXTRACT_16BITS(dat)));
+       dat += 2;
        length -= 2;
 
        /* Error Code (opt) */
@@ -330,19 +328,19 @@ l2tp_result_code_print(netdissect_options *ndo, const u_char *dat, u_int length)
                ND_PRINT((ndo, " AVP too short"));
                return;
        }
-       ND_PRINT((ndo, "/%u", EXTRACT_16BITS(ptr)));
-       ptr++;
+       ND_PRINT((ndo, "/%u", EXTRACT_16BITS(dat)));
+       dat += 2;
        length -= 2;
 
        /* Error Message (opt) */
        if (length == 0)
                return;
        ND_PRINT((ndo, " "));
-       print_string(ndo, (const u_char *)ptr, length);
+       print_string(ndo, dat, length);
 }
 
 static void
-l2tp_proto_ver_print(netdissect_options *ndo, const uint16_t *dat, u_int length)
+l2tp_proto_ver_print(netdissect_options *ndo, const u_char *dat, u_int length)
 {
        if (length < 2) {
                ND_PRINT((ndo, "AVP too short"));
@@ -355,16 +353,14 @@ l2tp_proto_ver_print(netdissect_options *ndo, const uint16_t *dat, u_int length)
 static void
 l2tp_framing_cap_print(netdissect_options *ndo, const u_char *dat, u_int length)
 {
-       const uint32_t *ptr = (const uint32_t *)dat;
-
        if (length < 4) {
                ND_PRINT((ndo, "AVP too short"));
                return;
        }
-       if (EXTRACT_32BITS(ptr) &  L2TP_FRAMING_CAP_ASYNC_MASK) {
+       if (EXTRACT_32BITS(dat) &  L2TP_FRAMING_CAP_ASYNC_MASK) {
                ND_PRINT((ndo, "A"));
        }
-       if (EXTRACT_32BITS(ptr) &  L2TP_FRAMING_CAP_SYNC_MASK) {
+       if (EXTRACT_32BITS(dat) &  L2TP_FRAMING_CAP_SYNC_MASK) {
                ND_PRINT((ndo, "S"));
        }
 }
@@ -372,16 +368,14 @@ l2tp_framing_cap_print(netdissect_options *ndo, const u_char *dat, u_int length)
 static void
 l2tp_bearer_cap_print(netdissect_options *ndo, const u_char *dat, u_int length)
 {
-       const uint32_t *ptr = (const uint32_t *)dat;
-
        if (length < 4) {
                ND_PRINT((ndo, "AVP too short"));
                return;
        }
-       if (EXTRACT_32BITS(ptr) &  L2TP_BEARER_CAP_ANALOG_MASK) {
+       if (EXTRACT_32BITS(dat) &  L2TP_BEARER_CAP_ANALOG_MASK) {
                ND_PRINT((ndo, "A"));
        }
-       if (EXTRACT_32BITS(ptr) &  L2TP_BEARER_CAP_DIGITAL_MASK) {
+       if (EXTRACT_32BITS(dat) &  L2TP_BEARER_CAP_DIGITAL_MASK) {
                ND_PRINT((ndo, "D"));
        }
 }
@@ -393,8 +387,8 @@ l2tp_q931_cc_print(netdissect_options *ndo, const u_char *dat, u_int length)
                ND_PRINT((ndo, "AVP too short"));
                return;
        }
-       print_16bits_val(ndo, (const uint16_t *)dat);
-       ND_PRINT((ndo, ", %02x", dat[2]));
+       print_16bits_val(ndo, dat);
+       ND_PRINT((ndo, ", %02x", EXTRACT_8BITS(dat + 2)));
        dat += 3;
        length -= 3;
        if (length != 0) {
@@ -406,16 +400,14 @@ l2tp_q931_cc_print(netdissect_options *ndo, const u_char *dat, u_int length)
 static void
 l2tp_bearer_type_print(netdissect_options *ndo, const u_char *dat, u_int length)
 {
-       const uint32_t *ptr = (const uint32_t *)dat;
-
        if (length < 4) {
                ND_PRINT((ndo, "AVP too short"));
                return;
        }
-       if (EXTRACT_32BITS(ptr) &  L2TP_BEARER_TYPE_ANALOG_MASK) {
+       if (EXTRACT_32BITS(dat) &  L2TP_BEARER_TYPE_ANALOG_MASK) {
                ND_PRINT((ndo, "A"));
        }
-       if (EXTRACT_32BITS(ptr) &  L2TP_BEARER_TYPE_DIGITAL_MASK) {
+       if (EXTRACT_32BITS(dat) &  L2TP_BEARER_TYPE_DIGITAL_MASK) {
                ND_PRINT((ndo, "D"));
        }
 }
@@ -423,16 +415,14 @@ l2tp_bearer_type_print(netdissect_options *ndo, const u_char *dat, u_int length)
 static void
 l2tp_framing_type_print(netdissect_options *ndo, const u_char *dat, u_int length)
 {
-       const uint32_t *ptr = (const uint32_t *)dat;
-
        if (length < 4) {
                ND_PRINT((ndo, "AVP too short"));
                return;
        }
-       if (EXTRACT_32BITS(ptr) &  L2TP_FRAMING_TYPE_ASYNC_MASK) {
+       if (EXTRACT_32BITS(dat) &  L2TP_FRAMING_TYPE_ASYNC_MASK) {
                ND_PRINT((ndo, "A"));
        }
-       if (EXTRACT_32BITS(ptr) &  L2TP_FRAMING_TYPE_SYNC_MASK) {
+       if (EXTRACT_32BITS(dat) &  L2TP_FRAMING_TYPE_SYNC_MASK) {
                ND_PRINT((ndo, "S"));
        }
 }
@@ -446,125 +436,109 @@ l2tp_packet_proc_delay_print(netdissect_options *ndo)
 static void
 l2tp_proxy_auth_type_print(netdissect_options *ndo, const u_char *dat, u_int length)
 {
-       const uint16_t *ptr = (const uint16_t *)dat;
-
        if (length < 2) {
                ND_PRINT((ndo, "AVP too short"));
                return;
        }
        ND_PRINT((ndo, "%s", tok2str(l2tp_authentype2str,
-                            "AuthType-#%u", EXTRACT_16BITS(ptr))));
+                            "AuthType-#%u", EXTRACT_16BITS(dat))));
 }
 
 static void
 l2tp_proxy_auth_id_print(netdissect_options *ndo, const u_char *dat, u_int length)
 {
-       const uint16_t *ptr = (const uint16_t *)dat;
-
        if (length < 2) {
                ND_PRINT((ndo, "AVP too short"));
                return;
        }
-       ND_PRINT((ndo, "%u", EXTRACT_16BITS(ptr) & L2TP_PROXY_AUTH_ID_MASK));
+       ND_PRINT((ndo, "%u", EXTRACT_16BITS(dat) & L2TP_PROXY_AUTH_ID_MASK));
 }
 
 static void
 l2tp_call_errors_print(netdissect_options *ndo, const u_char *dat, u_int length)
 {
-       const uint16_t *ptr = (const uint16_t *)dat;
-       uint16_t val_h, val_l;
+       uint32_t val;
 
        if (length < 2) {
                ND_PRINT((ndo, "AVP too short"));
                return;
        }
-       ptr++;          /* skip "Reserved" */
+       dat += 2;       /* skip "Reserved" */
        length -= 2;
 
        if (length < 4) {
                ND_PRINT((ndo, "AVP too short"));
                return;
        }
-       val_h = EXTRACT_16BITS(ptr); ptr++; length -= 2;
-       val_l = EXTRACT_16BITS(ptr); ptr++; length -= 2;
-       ND_PRINT((ndo, "CRCErr=%u ", (val_h<<16) + val_l));
+       val = EXTRACT_32BITS(dat); dat += 4; length -= 4;
+       ND_PRINT((ndo, "CRCErr=%u ", val));
 
        if (length < 4) {
                ND_PRINT((ndo, "AVP too short"));
                return;
        }
-       val_h = EXTRACT_16BITS(ptr); ptr++; length -= 2;
-       val_l = EXTRACT_16BITS(ptr); ptr++; length -= 2;
-       ND_PRINT((ndo, "FrameErr=%u ", (val_h<<16) + val_l));
+       val = EXTRACT_32BITS(dat); dat += 4; length -= 4;
+       ND_PRINT((ndo, "FrameErr=%u ", val));
 
        if (length < 4) {
                ND_PRINT((ndo, "AVP too short"));
                return;
        }
-       val_h = EXTRACT_16BITS(ptr); ptr++; length -= 2;
-       val_l = EXTRACT_16BITS(ptr); ptr++; length -= 2;
-       ND_PRINT((ndo, "HardOver=%u ", (val_h<<16) + val_l));
+       val = EXTRACT_32BITS(dat); dat += 4; length -= 4;
+       ND_PRINT((ndo, "HardOver=%u ", val));
 
        if (length < 4) {
                ND_PRINT((ndo, "AVP too short"));
                return;
        }
-       val_h = EXTRACT_16BITS(ptr); ptr++; length -= 2;
-       val_l = EXTRACT_16BITS(ptr); ptr++; length -= 2;
-       ND_PRINT((ndo, "BufOver=%u ", (val_h<<16) + val_l));
+       val = EXTRACT_32BITS(dat); dat += 4; length -= 4;
+       ND_PRINT((ndo, "BufOver=%u ", val));
 
        if (length < 4) {
                ND_PRINT((ndo, "AVP too short"));
                return;
        }
-       val_h = EXTRACT_16BITS(ptr); ptr++; length -= 2;
-       val_l = EXTRACT_16BITS(ptr); ptr++; length -= 2;
-       ND_PRINT((ndo, "Timeout=%u ", (val_h<<16) + val_l));
+       val = EXTRACT_32BITS(dat); dat += 4; length -= 4;
+       ND_PRINT((ndo, "Timeout=%u ", val));
 
        if (length < 4) {
                ND_PRINT((ndo, "AVP too short"));
                return;
        }
-       val_h = EXTRACT_16BITS(ptr); ptr++;
-       val_l = EXTRACT_16BITS(ptr); ptr++;
-       ND_PRINT((ndo, "AlignErr=%u ", (val_h<<16) + val_l));
+       val = EXTRACT_32BITS(dat); dat += 4; length -= 4;
+       ND_PRINT((ndo, "AlignErr=%u ", val));
 }
 
 static void
 l2tp_accm_print(netdissect_options *ndo, const u_char *dat, u_int length)
 {
-       const uint16_t *ptr = (const uint16_t *)dat;
-       uint16_t val_h, val_l;
+       uint32_t val;
 
        if (length < 2) {
                ND_PRINT((ndo, "AVP too short"));
                return;
        }
-       ptr++;          /* skip "Reserved" */
+       dat += 2;       /* skip "Reserved" */
        length -= 2;
 
        if (length < 4) {
                ND_PRINT((ndo, "AVP too short"));
                return;
        }
-       val_h = EXTRACT_16BITS(ptr); ptr++; length -= 2;
-       val_l = EXTRACT_16BITS(ptr); ptr++; length -= 2;
-       ND_PRINT((ndo, "send=%08x ", (val_h<<16) + val_l));
+       val = EXTRACT_32BITS(dat); dat += 4; length -= 4;
+       ND_PRINT((ndo, "send=%08x ", val));
 
        if (length < 4) {
                ND_PRINT((ndo, "AVP too short"));
                return;
        }
-       val_h = EXTRACT_16BITS(ptr); ptr++;
-       val_l = EXTRACT_16BITS(ptr); ptr++;
-       ND_PRINT((ndo, "recv=%08x ", (val_h<<16) + val_l));
+       val = EXTRACT_32BITS(dat); dat += 4; length -= 4;
+       ND_PRINT((ndo, "recv=%08x ", val));
 }
 
 static void
 l2tp_ppp_discon_cc_print(netdissect_options *ndo, const u_char *dat, u_int length)
 {
-       const uint16_t *ptr = (const uint16_t *)dat;
-
        if (length < 5) {
                ND_PRINT((ndo, "AVP too short"));
                return;
@@ -579,32 +553,27 @@ l2tp_ppp_discon_cc_print(netdissect_options *ndo, const u_char *dat, u_int lengt
        length -= 2;
        /* Direction */
        ND_PRINT((ndo, "%s", tok2str(l2tp_cc_direction2str,
-                            "Direction-#%u", EXTRACT_8BITS(ptr))));
-       ptr++;
+                            "Direction-#%u", EXTRACT_8BITS(dat))));
+       dat++;
        length--;
 
        if (length != 0) {
                ND_PRINT((ndo, " "));
-               print_string(ndo, (const u_char *)ptr, length);
+               print_string(ndo, (const u_char *)dat, length);
        }
 }
 
-static void
-l2tp_avp_print(netdissect_options *ndo, const u_char *dat, int length)
+static u_int
+l2tp_avp_print(netdissect_options *ndo, const u_char *dat, u_int length)
 {
        u_int len;
-       const uint16_t *ptr = (const uint16_t *)dat;
        uint16_t attr_type;
        int hidden = FALSE;
 
-       if (length <= 0) {
-               return;
-       }
-
        ND_PRINT((ndo, " "));
 
-       ND_TCHECK(*ptr);        /* Flags & Length */
-       len = EXTRACT_16BITS(ptr) & L2TP_AVP_HDR_LEN_MASK;
+       ND_TCHECK_16BITS(dat);  /* Flags & Length */
+       len = EXTRACT_16BITS(dat) & L2TP_AVP_HDR_LEN_MASK;
 
        /* If it is not long enough to contain the header, we'll give up. */
        if (len < 6)
@@ -617,7 +586,7 @@ l2tp_avp_print(netdissect_options *ndo, const u_char *dat, int length)
 
        /* If it goes past the end of the remaining length of the captured
           data, we'll give up. */
-       ND_TCHECK2(*ptr, len);
+       ND_TCHECK2(*dat, len);
 
        /*
         * After this point, we don't need to check whether we go past
@@ -625,26 +594,26 @@ l2tp_avp_print(netdissect_options *ndo, const u_char *dat, int length)
         * check whether we go past the end of the AVP.
         */
 
-       if (EXTRACT_16BITS(ptr) & L2TP_AVP_HDR_FLAG_MANDATORY) {
+       if (EXTRACT_16BITS(dat) & L2TP_AVP_HDR_FLAG_MANDATORY) {
                ND_PRINT((ndo, "*"));
        }
-       if (EXTRACT_16BITS(ptr) & L2TP_AVP_HDR_FLAG_HIDDEN) {
+       if (EXTRACT_16BITS(dat) & L2TP_AVP_HDR_FLAG_HIDDEN) {
                hidden = TRUE;
                ND_PRINT((ndo, "?"));
        }
-       ptr++;
+       dat += 2;
 
-       if (EXTRACT_16BITS(ptr)) {
+       if (EXTRACT_16BITS(dat)) {
                /* Vendor Specific Attribute */
-               ND_PRINT((ndo, "VENDOR%04x:", EXTRACT_16BITS(ptr))); ptr++;
-               ND_PRINT((ndo, "ATTR%04x", EXTRACT_16BITS(ptr))); ptr++;
+               ND_PRINT((ndo, "VENDOR%04x:", EXTRACT_16BITS(dat))); dat += 2;
+               ND_PRINT((ndo, "ATTR%04x", EXTRACT_16BITS(dat))); dat += 2;
                ND_PRINT((ndo, "("));
-               print_octets(ndo, (const u_char *)ptr, len-6);
+               print_octets(ndo, dat, len-6);
                ND_PRINT((ndo, ")"));
        } else {
                /* IETF-defined Attributes */
-               ptr++;
-               attr_type = EXTRACT_16BITS(ptr); ptr++;
+               dat += 2;
+               attr_type = EXTRACT_16BITS(dat); dat += 2;
                ND_PRINT((ndo, "%s", tok2str(l2tp_avp2str, "AVP-#%u", attr_type)));
                ND_PRINT((ndo, "("));
                if (hidden) {
@@ -652,26 +621,26 @@ l2tp_avp_print(netdissect_options *ndo, const u_char *dat, int length)
                } else {
                        switch (attr_type) {
                        case L2TP_AVP_MSGTYPE:
-                               l2tp_msgtype_print(ndo, (const u_char *)ptr, len-6);
+                               l2tp_msgtype_print(ndo, dat, len-6);
                                break;
                        case L2TP_AVP_RESULT_CODE:
-                               l2tp_result_code_print(ndo, (const u_char *)ptr, len-6);
+                               l2tp_result_code_print(ndo, dat, len-6);
                                break;
                        case L2TP_AVP_PROTO_VER:
-                               l2tp_proto_ver_print(ndo, ptr, len-6);
+                               l2tp_proto_ver_print(ndo, dat, len-6);
                                break;
                        case L2TP_AVP_FRAMING_CAP:
-                               l2tp_framing_cap_print(ndo, (const u_char *)ptr, len-6);
+                               l2tp_framing_cap_print(ndo, dat, len-6);
                                break;
                        case L2TP_AVP_BEARER_CAP:
-                               l2tp_bearer_cap_print(ndo, (const u_char *)ptr, len-6);
+                               l2tp_bearer_cap_print(ndo, dat, len-6);
                                break;
                        case L2TP_AVP_TIE_BREAKER:
                                if (len-6 < 8) {
                                        ND_PRINT((ndo, "AVP too short"));
                                        break;
                                }
-                               print_octets(ndo, (const u_char *)ptr, 8);
+                               print_octets(ndo, dat, 8);
                                break;
                        case L2TP_AVP_FIRM_VER:
                        case L2TP_AVP_ASSND_TUN_ID:
@@ -681,7 +650,7 @@ l2tp_avp_print(netdissect_options *ndo, const u_char *dat, int length)
                                        ND_PRINT((ndo, "AVP too short"));
                                        break;
                                }
-                               print_16bits_val(ndo, ptr);
+                               print_16bits_val(ndo, dat);
                                break;
                        case L2TP_AVP_HOST_NAME:
                        case L2TP_AVP_VENDOR_NAME:
@@ -690,7 +659,7 @@ l2tp_avp_print(netdissect_options *ndo, const u_char *dat, int length)
                        case L2TP_AVP_SUB_ADDRESS:
                        case L2TP_AVP_PROXY_AUTH_NAME:
                        case L2TP_AVP_PRIVATE_GRP_ID:
-                               print_string(ndo, (const u_char *)ptr, len-6);
+                               print_string(ndo, dat, len-6);
                                break;
                        case L2TP_AVP_CHALLENGE:
                        case L2TP_AVP_INI_RECV_LCP:
@@ -699,17 +668,17 @@ l2tp_avp_print(netdissect_options *ndo, const u_char *dat, int length)
                        case L2TP_AVP_PROXY_AUTH_CHAL:
                        case L2TP_AVP_PROXY_AUTH_RESP:
                        case L2TP_AVP_RANDOM_VECTOR:
-                               print_octets(ndo, (const u_char *)ptr, len-6);
+                               print_octets(ndo, dat, len-6);
                                break;
                        case L2TP_AVP_Q931_CC:
-                               l2tp_q931_cc_print(ndo, (const u_char *)ptr, len-6);
+                               l2tp_q931_cc_print(ndo, dat, len-6);
                                break;
                        case L2TP_AVP_CHALLENGE_RESP:
                                if (len-6 < 16) {
                                        ND_PRINT((ndo, "AVP too short"));
                                        break;
                                }
-                               print_octets(ndo, (const u_char *)ptr, 16);
+                               print_octets(ndo, dat, 16);
                                break;
                        case L2TP_AVP_CALL_SER_NUM:
                        case L2TP_AVP_MINIMUM_BPS:
@@ -721,33 +690,33 @@ l2tp_avp_print(netdissect_options *ndo, const u_char *dat, int length)
                                        ND_PRINT((ndo, "AVP too short"));
                                        break;
                                }
-                               print_32bits_val(ndo, (const uint32_t *)ptr);
+                               print_32bits_val(ndo, dat);
                                break;
                        case L2TP_AVP_BEARER_TYPE:
-                               l2tp_bearer_type_print(ndo, (const u_char *)ptr, len-6);
+                               l2tp_bearer_type_print(ndo, dat, len-6);
                                break;
                        case L2TP_AVP_FRAMING_TYPE:
-                               l2tp_framing_type_print(ndo, (const u_char *)ptr, len-6);
+                               l2tp_framing_type_print(ndo, dat, len-6);
                                break;
                        case L2TP_AVP_PACKET_PROC_DELAY:
                                l2tp_packet_proc_delay_print(ndo);
                                break;
                        case L2TP_AVP_PROXY_AUTH_TYPE:
-                               l2tp_proxy_auth_type_print(ndo, (const u_char *)ptr, len-6);
+                               l2tp_proxy_auth_type_print(ndo, dat, len-6);
                                break;
                        case L2TP_AVP_PROXY_AUTH_ID:
-                               l2tp_proxy_auth_id_print(ndo, (const u_char *)ptr, len-6);
+                               l2tp_proxy_auth_id_print(ndo, dat, len-6);
                                break;
                        case L2TP_AVP_CALL_ERRORS:
-                               l2tp_call_errors_print(ndo, (const u_char *)ptr, len-6);
+                               l2tp_call_errors_print(ndo, dat, len-6);
                                break;
                        case L2TP_AVP_ACCM:
-                               l2tp_accm_print(ndo, (const u_char *)ptr, len-6);
+                               l2tp_accm_print(ndo, dat, len-6);
                                break;
                        case L2TP_AVP_SEQ_REQUIRED:
                                break;  /* No Attribute Value */
                        case L2TP_AVP_PPP_DISCON_CC:
-                               l2tp_ppp_discon_cc_print(ndo, (const u_char *)ptr, len-6);
+                               l2tp_ppp_discon_cc_print(ndo, dat, len-6);
                                break;
                        default:
                                break;
@@ -756,11 +725,11 @@ l2tp_avp_print(netdissect_options *ndo, const u_char *dat, int length)
                ND_PRINT((ndo, ")"));
        }
 
-       l2tp_avp_print(ndo, dat+len, length-len);
-       return;
+       return (len);
 
  trunc:
        ND_PRINT((ndo, "|..."));
+       return (0);
 }
 
 
@@ -865,7 +834,22 @@ l2tp_print(netdissect_options *ndo, const u_char *dat, u_int length)
                if (length - cnt == 0) {
                        ND_PRINT((ndo, " ZLB"));
                } else {
-                       l2tp_avp_print(ndo, ptr, length - cnt);
+                       /*
+                        * Print AVPs.
+                        */
+                       while (length - cnt != 0) {
+                               u_int avp_length;
+
+                               avp_length = l2tp_avp_print(ndo, ptr, length - cnt);
+                               if (avp_length == 0) {
+                                       /*
+                                        * Truncated.
+                                        */
+                                       break;
+                               }
+                               cnt += avp_length;
+                               ptr += avp_length;
+                       }
                }
        } else {
                ND_PRINT((ndo, " {"));
index 2a3d1f9..e7f00c3 100644 (file)
@@ -29,6 +29,8 @@
 #include "l2vpn.h"
 #include "af.h"
 
+static const char tstr[] = " [|LDP]";
+
 /*
  * ldp common header
  *
@@ -210,7 +212,7 @@ static const struct tok ldp_fec_martini_ifparm_vccv_cv_values[] = {
     { 0, NULL}
 };
 
-static int ldp_pdu_print(netdissect_options *, register const u_char *);
+static u_int ldp_pdu_print(netdissect_options *, register const u_char *);
 
 /*
  * ldp tlv header
@@ -435,19 +437,24 @@ ldp_tlv_print(netdissect_options *ndo,
 
                 switch(vc_info_tlv_type) {
                 case LDP_FEC_MARTINI_IFPARM_MTU:
+                    ND_TCHECK_16BITS(tptr + 2);
                     ND_PRINT((ndo, ": %u", EXTRACT_16BITS(tptr+2)));
                     break;
 
                 case LDP_FEC_MARTINI_IFPARM_DESC:
                     ND_PRINT((ndo, ": "));
-                    for (idx = 2; idx < vc_info_tlv_len; idx++)
+                    for (idx = 2; idx < vc_info_tlv_len; idx++) {
+                        ND_TCHECK_8BITS(tptr + idx);
                         safeputchar(ndo, *(tptr + idx));
+                    }
                     break;
 
                 case LDP_FEC_MARTINI_IFPARM_VCCV:
+                    ND_TCHECK_8BITS(tptr + 2);
                     ND_PRINT((ndo, "\n\t\t  Control Channels (0x%02x) = [%s]",
                            *(tptr+2),
                            bittok2str(ldp_fec_martini_ifparm_vccv_cc_values, "none", *(tptr+2))));
+                    ND_TCHECK_8BITS(tptr + 3);
                     ND_PRINT((ndo, "\n\t\t  CV Types (0x%02x) = [%s]",
                            *(tptr+3),
                            bittok2str(ldp_fec_martini_ifparm_vccv_cv_values, "none", *(tptr+3))));
@@ -486,7 +493,7 @@ ldp_tlv_print(netdissect_options *ndo,
        break;
 
     case LDP_TLV_FT_SESSION:
-       TLV_TCHECK(8);
+       TLV_TCHECK(12);
        ft_flags = EXTRACT_16BITS(tptr);
        ND_PRINT((ndo, "\n\t      Flags: [%sReconnect, %sSave State, %sAll-Label Protection, %s Checkpoint, %sRe-Learn State]",
               ft_flags&0x8000 ? "" : "No ",
@@ -494,6 +501,7 @@ ldp_tlv_print(netdissect_options *ndo,
               ft_flags&0x4 ? "" : "No ",
               ft_flags&0x2 ? "Sequence Numbered Label" : "All Labels",
               ft_flags&0x1 ? "" : "Don't "));
+       /* 16 bits (FT Flags) + 16 bits (Reserved) */
        tptr+=4;
        ui = EXTRACT_32BITS(tptr);
        if (ui)
@@ -534,7 +542,7 @@ ldp_tlv_print(netdissect_options *ndo,
     return(tlv_len+4); /* Type & Length fields not included */
 
 trunc:
-    ND_PRINT((ndo, "\n\t\t packet exceeded snapshot"));
+    ND_PRINT((ndo, "%s", tstr));
     return 0;
 
 badtlv:
@@ -546,17 +554,23 @@ void
 ldp_print(netdissect_options *ndo,
           register const u_char *pptr, register u_int len)
 {
-    int processed;
+    u_int processed;
     while (len > (sizeof(struct ldp_common_header) + sizeof(struct ldp_msg_header))) {
         processed = ldp_pdu_print(ndo, pptr);
         if (processed == 0)
             return;
+        if (len < processed) {
+            ND_PRINT((ndo, " [remaining length %u < %u]", len, processed));
+            ND_PRINT((ndo, "%s", istr));
+            break;
+
+        }
         len -= processed;
         pptr += processed;
     }
 }
 
-static int
+static u_int
 ldp_pdu_print(netdissect_options *ndo,
               register const u_char *pptr)
 {
@@ -686,7 +700,7 @@ ldp_pdu_print(netdissect_options *ndo,
     }
     return pdu_len+4;
 trunc:
-    ND_PRINT((ndo, "\n\t\t packet exceeded snapshot"));
+    ND_PRINT((ndo, "%s", tstr));
     return 0;
 }
 
index 916a1d6..e836101 100644 (file)
@@ -31,6 +31,8 @@
 #include "addrtoname.h"
 #include "gmpls.h"
 
+static const char tstr[] = " [|LMP]";
+
 /*
  * LMP common header
  *
@@ -367,8 +369,9 @@ lmp_print_data_link_subobjs(netdissect_options *ndo, const u_char *obj_tptr,
     } bw;
 
     while (total_subobj_len > 0 && hexdump == FALSE ) {
-       subobj_type = EXTRACT_8BITS(obj_tptr+offset);
-       subobj_len  = EXTRACT_8BITS(obj_tptr+offset+1);
+       ND_TCHECK_16BITS(obj_tptr + offset);
+       subobj_type = EXTRACT_8BITS(obj_tptr + offset);
+       subobj_len  = EXTRACT_8BITS(obj_tptr + offset + 1);
        ND_PRINT((ndo, "\n\t    Subobject, Type: %s (%u), Length: %u",
                tok2str(lmp_data_link_subobj,
                        "Unknown",
@@ -389,24 +392,29 @@ lmp_print_data_link_subobjs(netdissect_options *ndo, const u_char *obj_tptr,
        }
        switch(subobj_type) {
        case INT_SWITCHING_TYPE_SUBOBJ:
+           ND_TCHECK_8BITS(obj_tptr + offset + 2);
            ND_PRINT((ndo, "\n\t      Switching Type: %s (%u)",
                tok2str(gmpls_switch_cap_values,
                        "Unknown",
-                       EXTRACT_8BITS(obj_tptr+offset+2)),
-               EXTRACT_8BITS(obj_tptr+offset+2)));
+                       EXTRACT_8BITS(obj_tptr + offset + 2)),
+                       EXTRACT_8BITS(obj_tptr + offset + 2)));
+           ND_TCHECK_8BITS(obj_tptr + offset + 3);
            ND_PRINT((ndo, "\n\t      Encoding Type: %s (%u)",
                tok2str(gmpls_encoding_values,
                        "Unknown",
-                       EXTRACT_8BITS(obj_tptr+offset+3)),
-               EXTRACT_8BITS(obj_tptr+offset+3)));
+                       EXTRACT_8BITS(obj_tptr + offset + 3)),
+                       EXTRACT_8BITS(obj_tptr + offset + 3)));
+           ND_TCHECK_32BITS(obj_tptr + offset + 4);
            bw.i = EXTRACT_32BITS(obj_tptr+offset+4);
            ND_PRINT((ndo, "\n\t      Min Reservable Bandwidth: %.3f Mbps",
                 bw.f*8/1000000));
+           ND_TCHECK_32BITS(obj_tptr + offset + 8);
            bw.i = EXTRACT_32BITS(obj_tptr+offset+8);
            ND_PRINT((ndo, "\n\t      Max Reservable Bandwidth: %.3f Mbps",
                 bw.f*8/1000000));
            break;
        case WAVELENGTH_SUBOBJ:
+           ND_TCHECK_32BITS(obj_tptr + offset + 4);
            ND_PRINT((ndo, "\n\t      Wavelength: %u",
                EXTRACT_32BITS(obj_tptr+offset+4)));
            break;
@@ -419,6 +427,8 @@ lmp_print_data_link_subobjs(netdissect_options *ndo, const u_char *obj_tptr,
        offset+=subobj_len;
     }
     return (hexdump);
+trunc:
+    return -1;
 }
 
 void
@@ -429,7 +439,7 @@ lmp_print(netdissect_options *ndo,
     const struct lmp_object_header *lmp_obj_header;
     const u_char *tptr,*obj_tptr;
     u_int tlen,lmp_obj_len,lmp_obj_ctype,obj_tlen;
-    int hexdump;
+    int hexdump, ret;
     u_int offset;
     u_int link_type;
 
@@ -731,7 +741,10 @@ lmp_print(netdissect_options *ndo,
                        ipaddr_string(ndo, obj_tptr+8),
                        EXTRACT_32BITS(obj_tptr+8)));
 
-               if (lmp_print_data_link_subobjs(ndo, obj_tptr, obj_tlen - 12, 12))
+               ret = lmp_print_data_link_subobjs(ndo, obj_tptr, obj_tlen - 12, 12);
+               if (ret == -1)
+                   goto trunc;
+               if (ret == TRUE)
                    hexdump=TRUE;
                break;
 
@@ -751,7 +764,10 @@ lmp_print(netdissect_options *ndo,
                        ip6addr_string(ndo, obj_tptr+20),
                        EXTRACT_32BITS(obj_tptr+20)));
 
-               if (lmp_print_data_link_subobjs(ndo, obj_tptr, obj_tlen - 36, 36))
+               ret = lmp_print_data_link_subobjs(ndo, obj_tptr, obj_tlen - 36, 36);
+               if (ret == -1)
+                   goto trunc;
+               if (ret == TRUE)
                    hexdump=TRUE;
                break;
 
@@ -771,7 +787,10 @@ lmp_print(netdissect_options *ndo,
                        EXTRACT_32BITS(obj_tptr+8),
                        EXTRACT_32BITS(obj_tptr+8)));
 
-               if (lmp_print_data_link_subobjs(ndo, obj_tptr, obj_tlen - 12, 12))
+               ret = lmp_print_data_link_subobjs(ndo, obj_tptr, obj_tlen - 12, 12);
+               if (ret == -1)
+                   goto trunc;
+               if (ret == TRUE)
                    hexdump=TRUE;
                break;
 
@@ -1012,7 +1031,7 @@ lmp_print(netdissect_options *ndo,
                                  EXTRACT_8BITS(obj_tptr))));
 
                ND_PRINT((ndo, "\n\t  UNI Version: %u",
-                      EXTRACT_8BITS(obj_tptr+1)));
+                      EXTRACT_8BITS(obj_tptr + 1)));
 
                break;
 
@@ -1034,28 +1053,28 @@ lmp_print(netdissect_options *ndo,
                    ND_PRINT((ndo, "\n\t Signal Type: %s (%u)",
                           tok2str(lmp_sd_service_config_cpsa_signal_type_sdh_values,
                                   "Unknown",
-                                  EXTRACT_8BITS(obj_tptr+1)),
-                          EXTRACT_8BITS(obj_tptr+1)));
+                                  EXTRACT_8BITS(obj_tptr + 1)),
+                                  EXTRACT_8BITS(obj_tptr + 1)));
                    break;
 
                case LMP_SD_SERVICE_CONFIG_CPSA_LINK_TYPE_SONET:
                    ND_PRINT((ndo, "\n\t Signal Type: %s (%u)",
                           tok2str(lmp_sd_service_config_cpsa_signal_type_sonet_values,
                                   "Unknown",
-                                  EXTRACT_8BITS(obj_tptr+1)),
-                          EXTRACT_8BITS(obj_tptr+1)));
+                                  EXTRACT_8BITS(obj_tptr + 1)),
+                                  EXTRACT_8BITS(obj_tptr + 1)));
                    break;
                }
 
                ND_PRINT((ndo, "\n\t Transparency: %s",
                       bittok2str(lmp_obj_service_config_cpsa_tp_flag_values,
                                  "none",
-                                 EXTRACT_8BITS(obj_tptr+2))));
+                                 EXTRACT_8BITS(obj_tptr + 2))));
 
                ND_PRINT((ndo, "\n\t Contiguous Concatenation Types: %s",
                       bittok2str(lmp_obj_service_config_cpsa_cct_flag_values,
                                  "none",
-                                 EXTRACT_8BITS(obj_tptr+3))));
+                                 EXTRACT_8BITS(obj_tptr + 3))));
 
                ND_PRINT((ndo, "\n\t Minimum NCC: %u",
                       EXTRACT_16BITS(obj_tptr+4)));
@@ -1091,7 +1110,7 @@ lmp_print(netdissect_options *ndo,
                       bittok2str(
                           lmp_obj_service_config_nsa_tcm_flag_values,
                           "none",
-                          EXTRACT_8BITS(obj_tptr+7))));
+                          EXTRACT_8BITS(obj_tptr + 7))));
 
                break;
 
@@ -1105,7 +1124,7 @@ lmp_print(netdissect_options *ndo,
                       bittok2str(
                           lmp_obj_service_config_nsa_network_diversity_flag_values,
                           "none",
-                          EXTRACT_8BITS(obj_tptr+3))));
+                          EXTRACT_8BITS(obj_tptr + 3))));
                break;
 
            default:
@@ -1129,7 +1148,7 @@ lmp_print(netdissect_options *ndo,
     }
     return;
 trunc:
-    ND_PRINT((ndo, "\n\t\t packet exceeded snapshot"));
+    ND_PRINT((ndo, "%s", tstr));
 }
 /*
  * Local Variables:
index e752a59..2118a96 100644 (file)
@@ -1568,8 +1568,8 @@ interp_reply(netdissect_options *ndo,
                                                tok2str(nfsv3_writemodes,
                                                        NULL, EXTRACT_32BITS(&dp[1]))));
                                }
-                               return;
                        }
+                       return;
                } else {
                        if (parseattrstat(ndo, dp, ndo->ndo_vflag, v3) != 0)
                                return;
@@ -1655,8 +1655,8 @@ interp_reply(netdissect_options *ndo,
                                ND_PRINT((ndo, " dir:"));
                                if (!(dp = parse_wcc_data(ndo, dp, ndo->ndo_vflag)))
                                        break;
-                               return;
                        }
+                       return;
                } else {
                        if (parsestatus(ndo, dp, &er) != NULL)
                                return;
index 043adc2..0b80981 100644 (file)
@@ -132,11 +132,9 @@ trunc:
 /* Print a TCP segment worth of OpenFlow messages presuming the segment begins
  * on a message boundary. */
 void
-openflow_print(netdissect_options *ndo, const u_char *cp, const u_int len)
+openflow_print(netdissect_options *ndo, const u_char *cp, const u_int len _U_)
 {
-       const u_char *ep = cp + len;
-
        ND_PRINT((ndo, ": OpenFlow"));
-       while (cp < ep)
-               cp = of_header_body_print(ndo, cp, ep);
+       while (cp < ndo->ndo_snapend)
+               cp = of_header_body_print(ndo, cp, ndo->ndo_snapend);
 }
index db4231b..4c09912 100644 (file)
@@ -706,7 +706,7 @@ ospf_print_lsa(netdissect_options *ndo,
                while ((const u_char *)lp < ls_end) {
                        register uint32_t ul;
 
-                       ND_TCHECK(*lp);
+                       ND_TCHECK_32BITS(lp);
                        ul = EXTRACT_32BITS(lp);
                         topology = (ul & SLA_MASK_TOS) >> SLA_SHIFT_TOS;
                        ND_PRINT((ndo, "\n\t\ttopology %s (%u) metric %d",
@@ -723,7 +723,7 @@ ospf_print_lsa(netdissect_options *ndo,
                while ((const u_char *)lp < ls_end) {
                        register uint32_t ul;
 
-                       ND_TCHECK(*lp);
+                       ND_TCHECK_32BITS(lp);
                        ul = EXTRACT_32BITS(lp);
                         topology = (ul & SLA_MASK_TOS) >> SLA_SHIFT_TOS;
                        ND_PRINT((ndo, "\n\t\ttopology %s (%u) metric %d",
index a5ac305..66ab2f7 100644 (file)
@@ -389,8 +389,7 @@ ospf6_print_lshdr(netdissect_options *ndo,
 {
        if ((const u_char *)(lshp + 1) > dataend)
                goto trunc;
-       ND_TCHECK(lshp->ls_type);
-       ND_TCHECK(lshp->ls_seq);
+       ND_TCHECK(lshp->ls_length);     /* last field of struct lsa6_hdr */
 
        ND_PRINT((ndo, "\n\t  Advertising Router %s, seq 0x%08x, age %us, length %u",
                ipaddr_string(ndo, &lshp->ls_router),
index 72cd1b8..66b7582 100644 (file)
@@ -68,6 +68,7 @@ ppi_print(netdissect_options *ndo,
        }
 
        hdr = (const ppi_header_t *)p;
+       ND_TCHECK_16BITS(&hdr->ppi_len);
        len = EXTRACT_LE_16BITS(&hdr->ppi_len);
        if (caplen < len) {
                /*
@@ -81,6 +82,7 @@ ppi_print(netdissect_options *ndo,
                ND_PRINT((ndo, "[|ppi]"));
                return (len);
        }
+       ND_TCHECK_32BITS(&hdr->ppi_dlt);
        dlt = EXTRACT_LE_32BITS(&hdr->ppi_dlt);
 
        if (ndo->ndo_eflag)
@@ -104,6 +106,8 @@ ppi_print(netdissect_options *ndo,
                hdrlen = 0;
        }
        return (len + hdrlen);
+trunc:
+       return (caplen);
 }
 
 /*
index 93b4b65..438761e 100644 (file)
@@ -499,6 +499,7 @@ rsvp_intserv_print(netdissect_options *ndo,
 
     if (obj_tlen < 4)
         return 0;
+    ND_TCHECK_8BITS(tptr);
     parameter_id = *(tptr);
     ND_TCHECK2(*(tptr + 2), 2);
     parameter_length = EXTRACT_16BITS(tptr+2)<<2; /* convert wordcount to bytecount */
@@ -1554,6 +1555,7 @@ rsvp_obj_print(netdissect_options *ndo,
         case RSVP_OBJ_CLASSTYPE_OLD: /* fall through */
             switch(rsvp_obj_ctype) {
             case RSVP_CTYPE_1:
+                ND_TCHECK_32BITS(obj_tptr);
                 ND_PRINT((ndo, "%s  CT: %u",
                        ident,
                        EXTRACT_32BITS(obj_tptr) & 0x7));
index 77c51ec..bf2af0c 100644 (file)
@@ -694,7 +694,7 @@ rx_cache_insert(netdissect_options *ndo,
        UNALIGNED_MEMCPY(&rxent->client, &ip->ip_src, sizeof(uint32_t));
        UNALIGNED_MEMCPY(&rxent->server, &ip->ip_dst, sizeof(uint32_t));
        rxent->dport = dport;
-       rxent->serviceId = EXTRACT_32BITS(&rxh->serviceId);
+       rxent->serviceId = EXTRACT_16BITS(&rxh->serviceId);
        rxent->opcode = EXTRACT_32BITS(bp + sizeof(struct rx_header));
 }
 
@@ -725,7 +725,7 @@ rx_cache_find(const struct rx_header *rxh, const struct ip *ip, int sport,
                if (rxent->callnum == EXTRACT_32BITS(&rxh->callNumber) &&
                    rxent->client.s_addr == clip &&
                    rxent->server.s_addr == sip &&
-                   rxent->serviceId == EXTRACT_32BITS(&rxh->serviceId) &&
+                   rxent->serviceId == EXTRACT_16BITS(&rxh->serviceId) &&
                    rxent->dport == sport) {
 
                        /* We got a match! */
@@ -1019,6 +1019,7 @@ fs_print(netdissect_options *ndo,
                        }
                        if (j == 0)
                                ND_PRINT((ndo, " <none!>"));
+                       break;
                }
                case 65537:     /* Fetch data 64 */
                        FIDOUT();
@@ -1279,6 +1280,7 @@ cb_print(netdissect_options *ndo,
                                bp += sizeof(int32_t);
                                tok2str(cb_types, "type %d", t);
                        }
+                       break;
                }
                case 214: {
                        ND_PRINT((ndo, " afsuuid"));
@@ -1740,6 +1742,7 @@ vldb_reply_print(netdissect_options *ndo,
                        INTOUT();
                        ND_PRINT((ndo, " nextindex"));
                        INTOUT();
+                       /*FALLTHROUGH*/
                case 503:       /* Get entry by id */
                case 504:       /* Get entry by name */
                {       unsigned long nservers, j;
@@ -1789,6 +1792,7 @@ vldb_reply_print(netdissect_options *ndo,
                        INTOUT();
                        ND_PRINT((ndo, " nextindex"));
                        INTOUT();
+                       /*FALLTHROUGH*/
                case 518:       /* Get entry by ID N */
                case 519:       /* Get entry by name N */
                {       unsigned long nservers, j;
index 37a41b5..dcaf28e 100644 (file)
@@ -881,6 +881,14 @@ sflow_print(netdissect_options *ndo,
     tptr = pptr;
     tlen = len;
     sflow_datagram = (const struct sflow_datagram_t *)pptr;
+    if (len < sizeof(struct sflow_datagram_t)) {
+        ND_TCHECK(sflow_datagram->version);
+        ND_PRINT((ndo, "sFlowv%u", EXTRACT_32BITS(sflow_datagram->version)));
+        ND_PRINT((ndo, " [length %u < %zu]",
+                  len, sizeof(struct sflow_datagram_t)));
+        ND_PRINT((ndo, " (invalid)"));
+        return;
+    }
     ND_TCHECK(*sflow_datagram);
 
     /*
@@ -916,6 +924,8 @@ sflow_print(netdissect_options *ndo,
 
     /* skip Common header */
     tptr += sizeof(const struct sflow_datagram_t);
+
+    if(tlen <= sizeof(const struct sflow_datagram_t)) goto trunc;
     tlen -= sizeof(const struct sflow_datagram_t);
 
     while (nsamples > 0 && tlen > 0) {
index a02077b..301c86c 100644 (file)
@@ -52,8 +52,8 @@ static const char tstr[] = "[|slip]";
 static u_int lastlen[2][256];
 static u_int lastconn = 255;
 
-static void sliplink_print(netdissect_options *, const u_char *, const struct ip *, u_int);
-static void compressed_sl_print(netdissect_options *, const u_char *, const struct ip *, u_int, int);
+static int sliplink_print(netdissect_options *, const u_char *, const struct ip *, u_int);
+static int compressed_sl_print(netdissect_options *, const u_char *, const struct ip *, u_int, int);
 
 u_int
 sl_if_print(netdissect_options *ndo,
@@ -74,7 +74,10 @@ sl_if_print(netdissect_options *ndo,
        ip = (const struct ip *)(p + SLIP_HDRLEN);
 
        if (ndo->ndo_eflag)
-               sliplink_print(ndo, p, ip, length);
+               if (sliplink_print(ndo, p, ip, length) == -1) {
+                       ND_PRINT((ndo, "%s", tstr));
+                       return (caplen + SLIP_HDRLEN);
+       }
 
        if (caplen < 1 || length < 1) {
                ND_PRINT((ndo, "%s", tstr));
@@ -122,7 +125,7 @@ sl_bsdos_if_print(netdissect_options *ndo,
        return (SLIP_HDRLEN);
 }
 
-static void
+static int
 sliplink_print(netdissect_options *ndo,
                register const u_char *p, register const struct ip *ip,
                register u_int length)
@@ -153,7 +156,7 @@ sliplink_print(netdissect_options *ndo,
                for (i = SLX_CHDR; i < SLX_CHDR + CHDR_LEN - 1; ++i)
                        ND_PRINT((ndo, "%02x.", p[i]));
                ND_PRINT((ndo, "%02x: ", p[SLX_CHDR + CHDR_LEN - 1]));
-               return;
+               return 0;
        }
        switch (p[SLX_CHDR] & 0xf0) {
 
@@ -171,9 +174,11 @@ sliplink_print(netdissect_options *ndo,
                ND_PRINT((ndo, "utcp %d: ", lastconn));
                if (dir == -1) {
                        /* Direction is bogus, don't use it */
-                       return;
+                       return 0;
                }
+               ND_TCHECK(*ip);
                hlen = IP_HL(ip);
+               ND_TCHECK(*((const struct tcphdr *)&((const int *)ip)[hlen]));
                hlen += TH_OFF((const struct tcphdr *)&((const int *)ip)[hlen]);
                lastlen[dir][lastconn] = length - (hlen << 2);
                break;
@@ -181,15 +186,19 @@ sliplink_print(netdissect_options *ndo,
        default:
                if (dir == -1) {
                        /* Direction is bogus, don't use it */
-                       return;
+                       return 0;
                }
                if (p[SLX_CHDR] & TYPE_COMPRESSED_TCP) {
-                       compressed_sl_print(ndo, &p[SLX_CHDR], ip,
-                           length, dir);
+                       if (compressed_sl_print(ndo, &p[SLX_CHDR], ip,
+                                               length, dir) == -1)
+                               goto trunc;
                        ND_PRINT((ndo, ": "));
                } else
                        ND_PRINT((ndo, "slip-%d!: ", p[SLX_CHDR]));
        }
+       return 0;
+trunc:
+       return -1;
 }
 
 static const u_char *
@@ -223,7 +232,7 @@ print_sl_winchange(netdissect_options *ndo,
        return (cp);
 }
 
-static void
+static int
 compressed_sl_print(netdissect_options *ndo,
                     const u_char *chdr, const struct ip *ip,
                     u_int length, int dir)
@@ -269,8 +278,13 @@ compressed_sl_print(netdissect_options *ndo,
         * 'cp - chdr' is the length of the compressed header.
         * 'length - hlen' is the amount of data in the packet.
         */
+       ND_TCHECK(*ip);
        hlen = IP_HL(ip);
+       ND_TCHECK(*((const struct tcphdr *)&((const int32_t *)ip)[hlen]));
        hlen += TH_OFF((const struct tcphdr *)&((const int32_t *)ip)[hlen]);
        lastlen[dir][lastconn] = length - (hlen << 2);
        ND_PRINT((ndo, " %d (%ld)", lastlen[dir][lastconn], (long)(cp - chdr)));
+       return 0;
+trunc:
+       return -1;
 }
index 6148569..9bc5d20 100644 (file)
@@ -198,6 +198,7 @@ sll_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h, const u_char
        u_int caplen = h->caplen;
        u_int length = h->len;
        register const struct sll_header *sllp;
+       u_short hatype;
        u_short ether_type;
        int llc_hdrlen;
        u_int hdrlen;
@@ -225,6 +226,16 @@ sll_if_print(netdissect_options *ndo, const struct pcap_pkthdr *h, const u_char
        p += SLL_HDR_LEN;
        hdrlen = SLL_HDR_LEN;
 
+       hatype = EXTRACT_16BITS(&sllp->sll_hatype);
+       switch (hatype) {
+
+       case 803:
+               /*
+                * This is an packet with a radiotap header;
+                * just dissect the payload as such.
+                */
+               return (SLL_HDR_LEN + ieee802_11_radio_print(ndo, p, length, caplen));
+       }
        ether_type = EXTRACT_16BITS(&sllp->sll_protocol);
 
 recurse:
index 723b9a0..944b8d2 100644 (file)
@@ -371,16 +371,21 @@ print_trans(netdissect_options *ndo,
     ND_PRINT((ndo, "smb_bcc=%u\n", bcc));
     if (bcc > 0) {
        smb_fdata(ndo, data1 + 2, f2, maxbuf - (paramlen + datalen), unicodestr);
-
-       if (strcmp((const char *)(data1 + 2), "\\MAILSLOT\\BROWSE") == 0) {
+#define MAILSLOT_BROWSE_STR "\\MAILSLOT\\BROWSE"
+       ND_TCHECK2(*(data1 + 2), strlen(MAILSLOT_BROWSE_STR) + 1);
+       if (strcmp((const char *)(data1 + 2), MAILSLOT_BROWSE_STR) == 0) {
            print_browse(ndo, param, paramlen, data, datalen);
            return;
        }
+#undef MAILSLOT_BROWSE_STR
 
-       if (strcmp((const char *)(data1 + 2), "\\PIPE\\LANMAN") == 0) {
+#define PIPE_LANMAN_STR "\\PIPE\\LANMAN"
+       ND_TCHECK2(*(data1 + 2), strlen(PIPE_LANMAN_STR) + 1);
+       if (strcmp((const char *)(data1 + 2), PIPE_LANMAN_STR) == 0) {
            print_ipc(ndo, param, paramlen, data, datalen);
            return;
        }
+#undef PIPE_LANMAN_STR
 
        if (paramlen)
            smb_fdata(ndo, param, f3, min(param + paramlen, maxbuf), unicodestr);
@@ -940,7 +945,9 @@ nbt_tcp_print(netdissect_options *ndo,
     if (caplen < 4)
        goto trunc;
     maxbuf = data + caplen;
+    ND_TCHECK_8BITS(data);
     type = data[0];
+    ND_TCHECK_16BITS(data + 2);
     nbt_len = EXTRACT_16BITS(data + 2);
     length -= 4;
     caplen -= 4;
index e0d0531..b80a2f2 100644 (file)
@@ -267,11 +267,11 @@ tcp_print(netdissect_options *ndo,
                         if (rev) {
                                 UNALIGNED_MEMCPY(&tha.src, dst, sizeof ip6->ip6_dst);
                                 UNALIGNED_MEMCPY(&tha.dst, src, sizeof ip6->ip6_src);
-                                tha.port = dport << 16 | sport;
+                                tha.port = ((u_int)dport) << 16 | sport;
                         } else {
                                 UNALIGNED_MEMCPY(&tha.dst, dst, sizeof ip6->ip6_dst);
                                 UNALIGNED_MEMCPY(&tha.src, src, sizeof ip6->ip6_src);
-                                tha.port = sport << 16 | dport;
+                                tha.port = ((u_int)sport) << 16 | dport;
                         }
 
                         for (th = &tcp_seq_hash[tha.port % TSEQ_HASHSIZE];
@@ -318,11 +318,11 @@ tcp_print(netdissect_options *ndo,
                         if (rev) {
                                 UNALIGNED_MEMCPY(&tha.src, &ip->ip_dst, sizeof ip->ip_dst);
                                 UNALIGNED_MEMCPY(&tha.dst, &ip->ip_src, sizeof ip->ip_src);
-                                tha.port = dport << 16 | sport;
+                                tha.port = ((u_int)dport) << 16 | sport;
                         } else {
                                 UNALIGNED_MEMCPY(&tha.dst, &ip->ip_dst, sizeof ip->ip_dst);
                                 UNALIGNED_MEMCPY(&tha.src, &ip->ip_src, sizeof ip->ip_src);
-                                tha.port = sport << 16 | dport;
+                                tha.port = ((u_int)sport) << 16 | dport;
                         }
 
                         for (th = &tcp_seq_hash[tha.port % TSEQ_HASHSIZE];
@@ -714,6 +714,12 @@ tcp_print(netdissect_options *ndo,
                 rtsp_print(ndo, bp, length);
         } else if (length > 2 &&
                  (IS_SRC_OR_DST_PORT(NAMESERVER_PORT))) {
+                /* domain_print() assumes it does not have to prepend a space before its
+                 * own output to separate it from the output of the calling function. This
+                 * works well with udp_print(), but requires a small prop here.
+                 */
+                ND_PRINT((ndo, " "));
+
                 /*
                  * TCP DNS query has 2byte length at the head.
                  * XXX packet could be unaligned, it can go strange
index d8ba426..a397667 100644 (file)
@@ -142,17 +142,21 @@ vrrp_print(netdissect_options *ndo,
 
                        vec[0].ptr = bp;
                        vec[0].len = len;
-                       if (in_cksum(vec, 1))
+                       if (in_cksum(vec, 1)) {
+                               ND_TCHECK_16BITS(&bp[6]);
                                ND_PRINT((ndo, ", (bad vrrp cksum %x)",
                                        EXTRACT_16BITS(&bp[6])));
+                       }
                }
 
                if (version == 3 && ND_TTEST2(bp[0], len)) {
                        uint16_t cksum = nextproto4_cksum(ndo, (const struct ip *)bp2, bp,
                                len, len, IPPROTO_VRRP);
-                       if (cksum)
+                       if (cksum) {
+                               ND_TCHECK_16BITS(&bp[6]);
                                ND_PRINT((ndo, ", (bad vrrp cksum %x)",
                                        EXTRACT_16BITS(&bp[6])));
+                       }
                }
 
                ND_PRINT((ndo, ", addrs"));
index d153cc1..d69c409 100644 (file)
@@ -241,7 +241,7 @@ vtp_print (netdissect_options *ndo,
         */
 
        tptr += 4;
-       while (tptr < (pptr+length)) {
+       while ((unsigned)(tptr - pptr) < length) {
 
            ND_TCHECK_8BITS(tptr);
            len = *tptr;
index c0df48d..f90170b 100644 (file)
@@ -203,7 +203,7 @@ wb_id(netdissect_options *ndo,
        len -= sizeof(*io) * nid;
        io = (const struct id_off *)(id + 1);
        cp = (const char *)(io + nid);
-       if (ND_TTEST2(cp, len)) {
+       if (ND_TTEST2(*cp, len)) {
                ND_PRINT((ndo, "\""));
                fn_print(ndo, (const u_char *)cp, (const u_char *)cp + len);
                ND_PRINT((ndo, "\""));
index 2091afb..204e345 100644 (file)
@@ -130,7 +130,7 @@ signature_verify(netdissect_options *ndo, const u_char *pptr, u_int plen,
     /*
      * Do we have all the packet data to be checked?
      */
-    if (!ND_TTEST2(pptr, plen)) {
+    if (!ND_TTEST2(*pptr, plen)) {
         /* No. */
         return (CANT_CHECK_SIGNATURE);
     }
@@ -138,7 +138,7 @@ signature_verify(netdissect_options *ndo, const u_char *pptr, u_int plen,
     /*
      * Do we have the entire signature to check?
      */
-    if (!ND_TTEST2(sig_ptr, sizeof(sig))) {
+    if (!ND_TTEST2(*sig_ptr, sizeof(sig))) {
         /* No. */
         return (CANT_CHECK_SIGNATURE);
     }
index fc9b3cc..525635c 100644 (file)
--- a/smbutil.c
+++ b/smbutil.c
@@ -478,12 +478,13 @@ smb_fdata1(netdissect_options *ndo,
 
        case 'P':
          {
-           int l = atoi(fmt + 1);
+           int l = atoi(fmt + 1);          
+           if(l <= 0) goto trunc;  /* actually error in fmt string */
            ND_TCHECK2(buf[0], l);
            buf += l;
            fmt++;
            while (isdigit((unsigned char)*fmt))
-               fmt++;
+             fmt++;
            break;
          }
        case 'r':
@@ -797,17 +798,33 @@ smb_fdata(netdissect_options *ndo,
           int unicodestr)
 {
     static int depth = 0;
+    const u_char *buf_start = buf;
     char s[128];
     char *p;
 
     while (*fmt) {
        switch (*fmt) {
        case '*':
+           /*
+            * List of multiple instances of something described by the
+            * remainder of the string (which may itself include a list
+            * of multiple instances of something, so we recurse).
+            */
            fmt++;
            while (buf < maxbuf) {
                const u_char *buf2;
                depth++;
-               buf2 = smb_fdata(ndo, buf, fmt, maxbuf, unicodestr);
+               /*
+                * In order to avoid stack exhaustion recurse at most 10
+                * levels; that "should not happen", as no SMB structure
+                * should be nested *that* deeply, and we thus shouldn't
+                * have format strings with that level of nesting.
+                */
+               if (depth == 10) {
+                       ND_PRINT((ndo, "(too many nested levels, not recursing)"));
+                       buf2 = buf;
+               } else
+                       buf2 = smb_fdata(ndo, buf, fmt, maxbuf, unicodestr);
                depth--;
                if (buf2 == NULL)
                    return(NULL);
@@ -818,22 +835,35 @@ smb_fdata(netdissect_options *ndo,
            return(buf);
 
        case '|':
+           /*
+            * Just do a bounds check.
+            */
            fmt++;
            if (buf >= maxbuf)
                return(buf);
            break;
 
        case '%':
+           /*
+            * XXX - unused?
+            */
            fmt++;
            buf = maxbuf;
            break;
 
        case '#':
+           /*
+            * Done?
+            */
            fmt++;
            return(buf);
            break;
 
        case '[':
+           /*
+            * Format of an item, enclosed in square brackets; dissect
+            * the item with smb_fdata1().
+            */
            fmt++;
            if (buf >= maxbuf)
                return(buf);
@@ -847,11 +877,15 @@ smb_fdata(netdissect_options *ndo,
            s[p - fmt] = '\0';
            fmt = p + 1;
            buf = smb_fdata1(ndo, buf, s, maxbuf, unicodestr);
-           if (buf == NULL)
+           if(buf < buf_start || buf == NULL) {
                return(NULL);
+           }
            break;
 
        default:
+           /*
+            * Not a formatting character, so just print it.
+            */
            ND_PRINT((ndo, "%c", *fmt));
            fmt++;
            break;
index 081e5d1..5a2b1e2 100644 (file)
@@ -441,7 +441,7 @@ terminal rather than to a file or pipe.
 .PD
 Set the time stamp type for the capture to \fItstamp_type\fP.  The names
 to use for the time stamp types are given in
-.BR pcap-tstamp (@MAN_MISC_INFO@);
+.BR \%pcap-tstamp (@MAN_MISC_INFO@);
 not all the types listed there will necessarily be valid for any given
 interface.
 .TP
@@ -1878,8 +1878,8 @@ The `*' on the request
 indicates that XO (`exactly once') was \fInot\fP set.
 
 .SH "SEE ALSO"
-stty(1), pcap(3PCAP), bpf(4), nit(4P), pcap-savefile(@MAN_FILE_FORMATS@),
-pcap-filter(@MAN_MISC_INFO@), pcap-tstamp(@MAN_MISC_INFO@)
+stty(1), pcap(3PCAP), bpf(4), nit(4P), \%pcap-savefile(@MAN_FILE_FORMATS@),
+\%pcap-filter(@MAN_MISC_INFO@), \%pcap-tstamp(@MAN_MISC_INFO@)
 .LP
 .RS
 .I http://www.iana.org/assignments/media-types/application/vnd.tcpdump.pcap
@@ -1898,7 +1898,7 @@ It is currently being maintained by tcpdump.org.
 The current version is available via http:
 .LP
 .RS
-.I http://www.tcpdump.org/
+.I https://www.tcpdump.org/
 .RE
 .LP
 The original distribution is available via anonymous ftp:
index d9c7f7a..043bda1 100644 (file)
--- a/tcpdump.c
+++ b/tcpdump.c
@@ -607,11 +607,10 @@ droproot(const char *username, const char *chroot_dir)
 #ifdef HAVE_LIBCAP_NG
                {
                        int ret = capng_change_id(pw->pw_uid, pw->pw_gid, CAPNG_NO_FLAG);
-                       if (ret < 0) {
-                               fprintf(stderr, "error : ret %d\n", ret);
-                       } else {
+                       if (ret < 0)
+                               error("capng_change_id(): return %d\n", ret);
+                       else
                                fprintf(stderr, "dropped privs to %s\n", username);
-                       }
                }
 #else
                if (initgroups(pw->pw_name, pw->pw_gid) != 0 ||
@@ -700,13 +699,15 @@ static char *
 get_next_file(FILE *VFile, char *ptr)
 {
        char *ret;
+       size_t len;
 
        ret = fgets(ptr, PATH_MAX, VFile);
        if (!ret)
                return NULL;
 
-       if (ptr[strlen(ptr) - 1] == '\n')
-               ptr[strlen(ptr) - 1] = '\0';
+       len = strlen (ptr);
+       if (len > 0 && ptr[len - 1] == '\n')
+               ptr[len - 1] = '\0';
 
        return ret;
 }
@@ -1023,6 +1024,10 @@ open_interface(const char *device, netdissect_options *ndo, char *ebuf)
                if (status < 0)
                        error("%s: Can't set time stamp type: %s",
                              device, pcap_statustostr(status));
+               else if (status > 0)
+                       warning("When trying to set timestamp type '%s' on %s: %s",
+                               pcap_tstamp_type_val_to_name(jflag), device,
+                               pcap_statustostr(status));
        }
 #endif
        status = pcap_activate(pc);
diff --git a/tests/SMBLIST b/tests/SMBLIST
new file mode 100644 (file)
index 0000000..10085d2
--- /dev/null
@@ -0,0 +1,12 @@
+# bad packets from Otto Airamo and Antti Levomäki
+nbns-valgrind          nbns-valgrind.pcap              nbns-valgrind.out       -vvv -e
+
+smb_print_trans-oobr1  smb_print_trans-oobr1.pcapng    smb_print_trans-oobr1.out       -vv -c4
+# bad packets from Philippe Antoine
+smb_print_trans-oobr2  smb_print_trans-oobr2.pcap      smb_print_trans-oobr2.out       -vv -c1
+
+# CVE-2018-10105 bad packets from Luis Rocha
+cve-2018-10105_smbprint-readofsize1      cve-2018-10105_smbprint-readofsize1.pcap cve-2018-10105_smbprint-readofsize1.out -vvv
+cve-2018-10105_smbutil_withoutasan       cve-2018-10105_smbutil_withoutasan.pcap  cve-2018-10105_smbutil_withoutasan.out -vvv
+
+
index bc35a7e..eb3052a 100644 (file)
@@ -26,8 +26,8 @@ bgp_infloop-v         bgp-infinite-loop.pcap          bgp_infloop-v.out       -v
 bgp-aigp       bgp-aigp.pcap   bgp-aigp.out    -v
 bgp-large-community bgp-large-community.pcap bgp-large-community.out -v
 
-# EAP tests
-eapon1         eapon1.pcap             eapon1.out
+# EAP tests. eapon1.pcap has NBT packets mixed in, eapon2.pcap removes them.
+eapon2         eapon2.pcap             eapon2.out
 
 # ESP tests
 esp0           02-sunrise-sunset-esp.pcap      esp0.out
@@ -198,6 +198,7 @@ of10_s4810-vvvv     of10_s4810.pcap         of10_s4810-vvvv.out     -vvvv
 of10_pf5240-vv of10_pf5240.pcap        of10_pf5240-vv.out      -vv
 of10_7050q-v   of10_7050q.pcap         of10_7050q-v.out        -v
 of10_7050sx_bsn-vv     of10_7050sx_bsn.pcap            of10_7050sx_bsn-vv.out  -vv
+of10_7050sx_bsn-oobr   of10_7050sx_bsn-oobr.pcap       of10_7050sx_bsn-oobr.out        -v
 
 # GeoNetworking and CALM FAST tests
 geonet-calm-fast       geonet_and_calm_fast.pcap       geonet_and_calm_fast.out        -vv
@@ -358,9 +359,9 @@ lisp_ipv6_eid               lisp_ipv6.pcap          lisp_ipv6.out           -v
 pcap-invalid-version-1 pcap-invalid-version-1.pcap pcap-invalid-version-1.out
 pcap-invalid-version-2 pcap-invalid-version-2.pcap pcap-invalid-version-2.out
 
-# pcap-ng invalid version (first: version = 0.1 ; second: version = 1.1)
-pcap-ng-invalid-vers-1 pcap-ng-invalid-vers-1.pcap pcap-ng-invalid-vers-1.out
-pcap-ng-invalid-vers-2 pcap-ng-invalid-vers-2.pcap pcap-ng-invalid-vers-2.out
+# pcapng invalid version (first: version = 0.1 ; second: version = 1.1)
+pcapng-invalid-vers-1 pcapng-invalid-vers-1.pcapng pcapng-invalid-vers-1.out
+pcapng-invalid-vers-2 pcapng-invalid-vers-2.pcapng pcapng-invalid-vers-2.out
 
 # NSH over VxLAN-GPE
 nsh-over-vxlan-gpe     nsh-over-vxlan-gpe.pcap nsh-over-vxlan-gpe.out
@@ -468,8 +469,6 @@ hoobr_nfs_xid_map_enter hoobr_nfs_xid_map_enter.pcap    hoobr_nfs_xid_map_enter.
 # bad packets from Wilfried Kirsch
 slip-bad-direction     slip-bad-direction.pcap         slip-bad-direction.out  -ve
 
-# bad packets from Otto Airamo and Antti Levomäki
-nbns-valgrind          nbns-valgrind.pcap              nbns-valgrind.out       -vvv -e
 arp-oobr               arp-oobr.pcap                   arp-oobr.out    -vvv -e
 icmp-cksum-oobr-1      icmp-cksum-oobr-1.pcap          icmp-cksum-oobr-1.out   -vvv -e
 icmp-cksum-oobr-2      icmp-cksum-oobr-2.pcap          icmp-cksum-oobr-2.out   -vvv -e
@@ -551,13 +550,18 @@ radius_attr_asan  radius_attr_asan.pcap           radius_attr_asan.out    -v
 ospf6_decode_v3_asan   ospf6_decode_v3_asan.pcap       ospf6_decode_v3_asan.out -v
 ip_ts_opts_asan                ip_ts_opts_asan.pcap            ip_ts_opts_asan.out     -v
 isakmpv1-attr-oobr     isakmpv1-attr-oobr.pcap         isakmpv1-attr-oobr.out  -v
-# The case below depends on the bug in print-hncp.c, which at the time of
-# discovery had codepoints for DHCPv6-Data and DHCPv4-Data swapped around.
-# After the bugfix the output will be different because of the different
-# code path and will not test the vulnerability unless modified respectively.
+isakmp-ikev1_n_print-oobr isakmp-ikev1_n_print-oobr.pcap isakmp-ikev1_n_print-oobr.out -v -c3
+ldp-ldp_tlv_print-oobr ldp-ldp_tlv_print-oobr.pcap ldp-ldp_tlv_print-oobr.out -v -c1
+icmp-icmp_print-oobr-1 icmp-icmp_print-oobr-1.pcap icmp-icmp_print-oobr-1.out -v -c3
+icmp-icmp_print-oobr-2 icmp-icmp_print-oobr-2.pcap icmp-icmp_print-oobr-2.out -v -c3
+rsvp-rsvp_obj_print-oobr rsvp-rsvp_obj_print-oobr.pcap rsvp-rsvp_obj_print-oobr.out -v -c3
+vrrp-vrrp_print-oobr vrrp-vrrp_print-oobr.pcap vrrp-vrrp_print-oobr.out -v -c3
+vrrp-vrrp_print-oobr-2 vrrp-vrrp_print-oobr-2.pcap vrrp-vrrp_print-oobr-2.out -v
+bgp-bgp_capabilities_print-oobr-1 bgp-bgp_capabilities_print-oobr-1.pcap bgp-bgp_capabilities_print-oobr-1.out -v -c1
+bgp-bgp_capabilities_print-oobr-2 bgp-bgp_capabilities_print-oobr-2.pcap bgp-bgp_capabilities_print-oobr-2.out -v -c1
+lmp-lmp_print_data_link_subobjs-oobr lmp-lmp_print_data_link_subobjs-oobr.pcap lmp-lmp_print_data_link_subobjs-oobr.out -v -c2
 # The .pcap file is truncated after the 1st packet.
 hncp_dhcpv6data-oobr   hncp_dhcpv6data-oobr.pcap       hncp_dhcpv6data-oobr.out -v -c1
-# Same comments apply to the case below.
 hncp_dhcpv4data-oobr   hncp_dhcpv4data-oobr.pcap       hncp_dhcpv4data-oobr.out -v -c1
 vqp-oobr               vqp-oobr.pcap                   vqp-oobr.out            -v -c1
 bgp_pmsi_tunnel-oobr   bgp_pmsi_tunnel-oobr.pcap       bgp_pmsi_tunnel-oobr.out -v -c1
@@ -576,6 +580,10 @@ olsr-oobr-1                olsr-oobr-1.pcap                olsr-oobr-1.out -v
 olsr-oobr-2            olsr-oobr-2.pcap                olsr-oobr-2.out -v
 ikev1_id_ipv6_addr_subnet-oobr ikev1_id_ipv6_addr_subnet-oobr.pcap     ikev1_id_ipv6_addr_subnet-oobr.out      -v
 isakmp-various-oobr    isakmp-various-oobr.pcap        isakmp-various-oobr.out -v
+aoe-oobr-1             aoe-oobr-1.pcap                 aoe-oobr-1.out  -v -c1
+frf16_magic_ie-oobr    frf16_magic_ie-oobr.pcap        frf16_magic_ie-oobr.out -v -c1
+rx_serviceid_oobr      rx_serviceid_oobr.pcap          rx_serviceid_oobr.out -c3
+bgp_mp_reach_nlri-oobr bgp_mp_reach_nlri-oobr.pcap     bgp_mp_reach_nlri-oobr.out -v -c1
 
 # bad packets from Katie Holly
 mlppp-oobr             mlppp-oobr.pcap                 mlppp-oobr.out
@@ -586,6 +594,16 @@ icmp6_nodeinfo_oobr        icmp6_nodeinfo_oobr.pcap        icmp6_nodeinfo_oobr.out
 
 # bad packets from Henri Salo
 rx_ubik-oobr           rx_ubik-oobr.pcap               rx_ubik-oobr.out -c1
+babel_update_oobr      babel_update_oobr.pcap  babel_update_oobr.out   -c 52
+
+# bad packets from Junjie Wang
+ospf6_print_lshdr-oobr ospf6_print_lshdr-oobr.pcapng   ospf6_print_lshdr-oobr.out      -vv -c15
+rpl-dao-oobr           rpl-dao-oobr.pcapng             rpl-dao-oobr.out                -vv -c1
+hncp_prefix-oobr       hncp_prefix-oobr.pcapng         hncp_prefix-oobr.out            -vvv
+
+# bad packets from Ryan Ackroyd
+ieee802.11_meshhdr-oobr        ieee802.11_meshhdr-oobr.pcap    ieee802.11_meshhdr-oobr.out     -H -c1
+dccp_options-oobr      dccp_options-oobr.pcap          dccp_options-oobr.out           -vv -c8
 
 # RTP tests
 # fuzzed pcap
@@ -603,3 +621,23 @@ nfs-seg-fault-1  nfs-seg-fault-1.pcap  nfs-seg-fault-1.out
 dns-zlip-1             dns-zlip-1.pcap         dns-zlip-1.out
 dns-zlip-2             dns-zlip-2.pcap         dns-zlip-2.out
 dns-zlip-3             dns-zlip-3.pcap         dns-zlip-3.out
+
+# CVE-2019-15120
+kh-addrfail-001         kh-addrfail-001.pcap    kh-addrfail-001.out
+kh-addrfail-002         kh-addrfail-002.pcap    kh-addrfail-002.out
+kh-addrfail-003         kh-addrfail-003.pcap    kh-addrfail-003.out
+kh-addrfail-004         kh-addrfail-004.pcap    kh-addrfail-004.out
+kh-addrfail-005         kh-addrfail-005.pcap    kh-addrfail-005.out
+kh-addrfail-006         kh-addrfail-006.pcap    kh-addrfail-006.out
+kh-addrfail-007         kh-addrfail-007.pcap    kh-addrfail-007.out
+kh-addrfail-008         kh-addrfail-008.pcap    kh-addrfail-008.out
+kh-addrfail-009         kh-addrfail-009.pcap    kh-addrfail-009.out
+kh-addrfail-010         kh-addrfail-010.pcap    kh-addrfail-010.out
+kh-addrfail-011         kh-addrfail-011.pcap    kh-addrfail-011.out
+kh-tcpdump-001          kh-tcpdump-001.pcap     kh-tcpdump-001.out
+kh-tcpdump-002          kh-tcpdump-002.pcap     kh-tcpdump-002.out
+
+# CVE-2018-10105 bad packets from Luis Rocha
+cve-2018-10105-segv-sflowprint           cve-2018-10105-segv-sflowprint.pcapng    cve-2018-10105-segv-sflowprint.out -v
+
+
index 7026624..425abaa 100755 (executable)
@@ -1,6 +1,17 @@
 #!/usr/bin/env perl
 
-system("mkdir -p NEW DIFF");
+$TCPDUMP = "./tcpdump";
+if ($^O eq 'MSWin32') {
+    $TCPDUMP = "windump";
+}
+if($ENV{TCPDUMP_BIN}) {
+    $TCPDUMP = $ENV{TCPDUMP_BIN};
+}
+
+use File::Basename;
+use POSIX qw( WEXITSTATUS WIFEXITED);
+
+system("mkdir -p tests/NEW tests/DIFF");
 
 if(@ARGV != 4) {
   print "Usage: TESTonce name input output options\n";
@@ -13,39 +24,121 @@ $output=$ARGV[2];
 $options=$ARGV[3];
 
 my $r;
+my $debug = 0; # change to suit.
+
+$outputbase = basename($output);
+my $coredump = false;
+my $status = 0;
+my $linecount = 0;
+my $rawstderrlog = "tests/NEW/${outputbase}.raw.stderr";
+my $stderrlog = "tests/NEW/${outputbase}.stderr";
+my $diffstat = 0;
+my $errdiffstat = 0;
+my $cmd;
 
 if ($^O eq 'MSWin32') {
-    $r = system "..\\windump -n -t -r $input $options 2>NUL | sed 's/\\r//' | tee NEW/$output | diff $output - >DIFF/$output.diff";
+    $r = system ".\\${TCPDUMP} -t -n -r $input $options 2>NUL | sed 's/\\r//' | tee tests/NEW/${outputbase} | diff $output - >tests/DIFF/${outputbase}.diff";
     # need to do same as below for Cygwin.
 }
 else {
     # we used to do this as a nice pipeline, but the problem is that $r fails to
     # to be set properly if the tcpdump core dumps.
-    $r = system "../tcpdump 2>/dev/null -n -t -r $input $options >NEW/$output";
+    $cmd = "$TCPDUMP 2>${rawstderrlog} -t -n -r $input $options >tests/NEW/${outputbase}";
+    print "CMD: $cmd\n" if $debug;
+    $r = system $cmd;
+    if($r == -1) {
+        # failed to start due to error.
+        $status = $!;
+    }
     if($r != 0) {
-        # this means tcpdump failed.
-        open(OUTPUT, ">>"."NEW/$output") || die "fail to open $output\n";
-        printf OUTPUT "EXIT CODE %08x\n", $r;
+        $coredump = false;
+        $status = 0;
+        # this means tcpdump failed, which however, might be expected.
+        open(OUTPUT, ">>"."tests/NEW/${outputbase}") || die "fail to open ${outputbase}\n";
+        if( $r & 128 ) {
+            $coredump = $r & 127;
+        }
+        if( WIFEXITED($r)) {
+            $status = WEXITSTATUS($r);
+        }
+
+        if($coredump || $status) {
+            printf OUTPUT "\nEXIT CODE %08x: dump:%d code: %d\n", $r, $coredump, $status;
+        } else {
+            printf OUTPUT "\nEXIT CODE %08x\n", $r;
+        }
         close(OUTPUT);
-        $r = 0;
+        $r = 0;  # clear the error so that the diff will occur.
+    }
+    print "RUNNING DIFF after ${r}\n" if $debug;
+
+    # always run diff.
+    $cmd = "cat tests/NEW/${outputbase} | diff $output - >tests/DIFF/${outputbase}.diff";
+    print "RUNNING: $cmd\n" if $debug;
+    $r = system $cmd;
+    if(WIFEXITED($r)) {
+        $diffstat = WEXITSTATUS($r);
     }
+
+    #system("/bin/sh");
+
+    # process the file, sanitize "reading from" line, and count lines
+    $linecount = 0;
+    open(ERRORRAW, "<" . $rawstderrlog);
+    open(ERROROUT, ">" . $stderrlog);
+    while(<ERRORRAW>) {
+        next if /^\s*$/;  # blank lines are boring
+        if(/^(reading from file )(.*)(,.*)$/) {
+            my $filename = basename($2);
+            print ERROROUT "${1}${filename}${3}\n";
+            next;
+        }
+        print ERROROUT;
+        $linecount++;
+    }
+    close(ERROROUT);
+    close(ERRORRAW);
+
+    if ( -f "$output.stderr" ) {
+        $nr = system "cat $stderrlog | diff $output.stderr - >tests/DIFF/$outputbase.stderr.diff";
+        if($r == 0) {
+            $r = $nr;
+        }
+        $errdiffstat = WEXITSTATUS($nr);
+    } else {
+        $errdiffstat = "-"
+    }
+
     if($r == 0) {
-        $r = system "cat NEW/$output | diff $output - >DIFF/$output.diff";
+        if($linecount == 0 && $status == 0) {
+            print "UNLINK: ${stderrlog}\n" if $debug;
+            unlink($stderrlog) unless $debug;
+        } else {
+            $errdiffstat = "+";
+        }
     }
-    #print sprintf("END: %08x\n", $r);
+
+    print sprintf("END: %08x\n", $r) if $debug;
 }
 
 if($r == 0) {
-  printf "    %-35s: passed\n", $name;
-  unlink "DIFF/$output.diff";
-  exit 0;
+    my $stderrlog="";
+    if($linecount > 0 && $errdiffstat != "-") {
+        $stderrlog=sprintf("-- %d lines extra in stderr", $linecount);
+    }
+    if(!defined($ENV{"SKIPPASSED"})) {
+        printf "    %-35s: passed%s\n", $name, $stderrlog;
+    }
+    unlink "tests/DIFF/$outputbase.diff" unless $debug;
+    exit 0;
 }
-printf "    %-35s: TEST FAILED", $name;
-open FOUT, '>>failure-outputs.txt';
-printf FOUT "Failed test: $name\n\n";
+# must have failed!
+printf "    %-35s: TEST FAILED(exit core=%d/diffstat=%d,%d/r=%d)", $name, $coredump, $diffstat, $errdiffstat, $r;
+open FOUT, '>>tests/failure-outputs.txt';
+printf FOUT "\nFailed test: $name\n\n";
 close FOUT;
-if(-f "DIFF/$output.diff") {
-    system "cat DIFF/$output.diff >> failure-outputs.txt";
+if(-f "tests/DIFF/$outputbase.diff") {
+    system "cat tests/DIFF/$outputbase.diff >> tests/failure-outputs.txt";
 }
 
 if($r == -1) {
index 6449082..a7529a5 100755 (executable)
@@ -1,26 +1,43 @@
 #!/bin/sh
 
-mkdir -p NEW
-mkdir -p DIFF
-passed=0
-failed=0
-cat /dev/null > failure-outputs.txt
+TZ=GMT0; export TZ
+srcdir=${SRCDIR-..}
+
+# make it absolute for later use.
+pwd
+srcdir=`cd $srcdir && pwd`
+
+# this should be run from the compiled build directory,
+# with srcdir= set to wherever the source code is.
+# not from the tests directory.
+echo RUNNING from ${srcdir}
+
+passedfile=`pwd`/tests/.passed
+failedfile=`pwd`/tests/.failed
+failureoutput=`pwd`/tests/failure-outputs.txt
+mkdir -p tests/NEW
+mkdir -p tests/DIFF
+cat /dev/null > ${failureoutput}
 
 runComplexTests()
 {
-  for i in *.sh
+  for i in ${srcdir}/tests/*.sh
   do
-    case $i in TEST*.sh) continue;; esac
-    sh ./$i
+    case $i in
+        ${srcdir}/tests/TEST*.sh) continue;;
+        ${srcdir}/tests/\*.sh) continue;;
+    esac
+    : echo Running $i
+    (sh $i ${srcdir})
   done
+  passed=`cat ${passedfile}`
+  failed=`cat ${failedfile}`
 }
 
 runSimpleTests()
 {
-  passed=`cat .passed`
-  failed=`cat .failed`
   only=$1
-  cat TESTLIST | while read name input output options
+  cat ${srcdir}/tests/TESTLIST | while read name input output options
   do
     case $name in
       \#*) continue;;
@@ -28,23 +45,34 @@ runSimpleTests()
     esac
     rm -f core
     [ "$only" != "" -a "$name" != "$only" ] && continue
-    if ./TESTonce $name $input $output "$options"
+    SRCDIR=${srcdir}
+    export SRCDIR
+    # I hate shells with their stupid, useless subshells.
+    passed=`cat ${passedfile}`
+    failed=`cat ${failedfile}`
+    (
+    if ${srcdir}/tests/TESTonce $name ${srcdir}/tests/$input ${srcdir}/tests/$output "$options" 
     then
       passed=`expr $passed + 1`
-      echo $passed >.passed
+      echo $passed >${passedfile}
     else
       failed=`expr $failed + 1`
-      echo $failed >.failed
+      echo $failed >${failedfile}
     fi
+    if [ -d tests/COREFILES ]; then
+        if [ -f core ]; then mv core tests/COREFILES/$name.core; fi
+    fi)
     [ "$only" != "" -a "$name" = "$only" ] && break
   done
   # I hate shells with their stupid, useless subshells.
-  passed=`cat .passed`
-  failed=`cat .failed`
+  passed=`cat ${passedfile}`
+  failed=`cat ${failedfile}`
 }
 
-echo $passed >.passed
-echo $failed >.failed
+passed=0
+failed=0
+echo $passed >${passedfile}
+echo $failed >${failedfile}
 if [ $# -eq 0 ]
 then
   runComplexTests
@@ -62,8 +90,9 @@ echo '------------------------------------------------'
 printf "%4u tests failed\n" $failed
 printf "%4u tests passed\n" $passed
 echo
-echo
-cat failure-outputs.txt
+if [ -z "$SKIPPASSED" ]; then
+    cat ${failureoutput}
+fi
 echo
 echo
 exit $failed
diff --git a/tests/aoe-oobr-1.out b/tests/aoe-oobr-1.out
new file mode 100644 (file)
index 0000000..a959283
--- /dev/null
@@ -0,0 +1,3 @@
+AoE length 18, Ver 1, Flags: [Response, MBZ-0x02, MBZ-0x01]
+       Major: 0x40f6, Minor: 0x02, Command: Reserve/Release, Tag: 0x01010101
+       RCmd: Set reserve list, NMacs: 1 [|aoe]
diff --git a/tests/aoe-oobr-1.pcap b/tests/aoe-oobr-1.pcap
new file mode 100644 (file)
index 0000000..ce06c21
Binary files /dev/null and b/tests/aoe-oobr-1.pcap differ
index f773974..e076962 100644 (file)
Binary files a/tests/arp-too-long-tha.pcap and b/tests/arp-too-long-tha.pcap differ
diff --git a/tests/babel_update_oobr.out b/tests/babel_update_oobr.out
new file mode 100644 (file)
index 0000000..03fb9dd
--- /dev/null
@@ -0,0 +1,66 @@
+IP 10.0.0.1.88 > 0.234.154.214.24074:  v4 be KDC_REQUEST: ^O^O^O^O^O^O^O^O^O^DM-2M-!M-1M-1M-1M-1M-1M-1M-1M-1M-,.M-0^Vn [|kerberos]
+IP 10.0.0.1 > 0.234.154.214: ip-proto-17
+IP 10.0.0.1.88 > 0.234.154.179.24191:  v4 be KDC_REQUEST: ^O^O^O^O^O^DM-2 .*^C@>M-z}M-uM-tM-+M-_M-{S^PM-=OM-^Y [|kerberos]
+58:5e:0a:02:f4:0a > 02:8e:00:50:6a:e1, ethertype Unknown (0xb104), length 3892667167: 
+       0x0000:  020f 0f0f 0f0f 0f0f 0f0f 04b2 a1b1 b1b1  ................
+       0x0010:  b1b1 b1b1 b158 5e0a 02f4 0ab1 0402 0f0f  .....X^.........
+       0x0020:  ff80 0f0f 0f0f 0f00 80a1 00b2 b2b2 b20d  ................
+       0x0030:  0d3a 3400 0001 00                        .:4....
+IP 6.3.218.255.6379 > 0.1.31.99.639: Flags [S.UW], seq 2751463404:2751463426, ack 1006637056, win 45746, urg 25778, length 22: RESP [|RESP]
+IP 6.3.208.255.6379 > 0.1.31.99.639: Flags [S.UW], seq 2751463404:2751463426, ack 1006640128, win 45746, urg 25778, length 22: RESP "M-2M-2M-2M-2M-2M-7dM-2M-2M-2M-2M-2" [|RESP]
+IP 208.21.10.1.654 > 31.99.100.232.80:  aodv rrep 34  prefix 4 hops 11
+       dst 237.34.38.84 dseq 32203525 src 232.11.2.0 67108864 ms
+       ext 0 0
+IP 10.0.0.1.88 > 0.234.154.214.24074:  v4 be KDC_REQUEST: ^O^O^O^O^O^O^O^O^O^DM-WM-WM-WM-WM-WM-WM-W.@ 680min  [|kerberos]
+IP 10.0.253.1.88 > 0.234.154.214.24073:  v4 be KDC_REQUEST: .M-^?M-^?^AM-^@M-^?M-^@M-V@M-WM-WM-sM-WM-WM-WM-WM-W 880min ^VM-^H [|kerberos]
+IP 10.0.0.1.88 > 0.234.154.214.24074:  v4 be KDC_REQUEST: ^O^O^O^O^O7M-^@M-^?.d^O^O^O^O^O^O^O^O^O^O^O^O@^VM-^H [|kerberos]
+IP 10.0.0.1.88 > 0.234.154.214.24073:  v4 be KDC_REQUEST: .M-^?M-^?^AM-^@M-^?M-^@M-V@M-WM-WM-sM-WM-WM-WM-WM-W 880min ^VM-^H [|kerberos]
+IP 10.0.0.1.88 > 0.234.154.214.24074:  v4 be KDC_REQUEST: ^O^O^O^O^O7M-^@M-^?.d^O^O^O^O^O^O^O^O^O^O^O^O@^VM-^H [|kerberos]
+IP 10.0.0.1.88 > 0.234.154.214.24074:  v4 be KDC_REQUEST: ^O^O^O^O.^DM-2M-!^BM-W^CM-!^B@^D 0min ^P.^VM-^H [|kerberos]
+IP 10.0.242.1.88 > 0.234.154.214.24074:  v4 be KDC_REQUEST: ^O^O'^O^O@@.@^Qjp^J@ 1070min .X^^J^B [|kerberos]
+IP 10.0.0.1.88 > 0.234.154.214.24074:  v4 be KDC_REQUEST: ^O^O^O^O^O^U.@^O^D^O^O^O^O^O^O^O^O^O^O^O^O [|kerberos]
+IP 10.0.222.1.88 > 0.234.154.214.24074:  v4 be KDC_REQUEST: ^O^O^O^O^O^DM-2 .M-g^C@>M-y}M-uM-tM-+M-` 680min  [|kerberos]
+01:01:ed:83:e3:ff > 02:8e:00:50:6d:e1, ethertype Unknown (0x0700), length 3892672031: 
+       0x0000:  4508 8834 d940 4000 4011 4a70 0a00 0001  E..4.@@.@.Jp....
+       0x0010:  00ea 9ad6 0058 5e0a 02f4 0ab1 0402 0f0f  .....X^.........
+       0x0020:  0f0f 0f0f 0f0f 0f04 b2a1 b1b1 b1b1 b1b1  ................
+       0x0030:  b1b1 b100 b016 6e                        ......n
+IP 10.0.0.1.88 > 0.234.154.214.24074:  v4 be KDC_REQUEST: ^O^O^O^O^O^U.@ ^D^R^O^O^O^O^O^O^O^O^O^O^O [|kerberos]
+IP 10.0.255.127.88 > 0.234.154.214.24074:  v4 be KDC_REQUEST: ^O^O^O^O^O^DM-2 .M-g^C@>M-z}M-uM-tM-^\M-`^VM-^?^?M-=OM-^Y [|kerberos]
+IP 10.0.0.1.88 > 0.234.154.214.24074:  v4 be KDC_REQUEST: ^O^O^O.^B^O^O^O^O^DM-2M-!M-1M-1M-1M-1M-1M-1M-1M-1M-1M-^@M-0^VM-^H [|kerberos]
+IP 10.0.0.1.88 > 0.234.154.214.24074:  v4 be KDC_REQUEST: ^O^O^O^O^O7M-^@M-^?M-^@^D^O^O^O^O^O^P.M-^?M-^?^O^O^O@^VM-^H [|kerberos]
+IP 10.0.0.1.88 > 0.234.154.214.24074:  v4 be KDC_REQUEST: ^O^O^O^O.^DM-#M-^?M-^?d^O^O^O^O^O^O^O^O^O^O^O^O@^VM-^H [|kerberos]
+IP 0.0.1.0 > 234.154.214.0: ip-proto-106
+IP 10.0.0.1.88 > 0.234.154.214.24074:  v4 be KDC_REQUEST: ^O^O^O^O^O7M-^@M-^?M-^@^D^O^O^O^O^O^P.M-^?M-^?^O^O^O@^VM-^H [|kerberos]
+IP 10.0.0.1.88 > 0.234.154.214.24074:  v4 be KDC_REQUEST: ^O^O^O^O.^DM-^@M-^?M-^?M-^?^CM-!^B@^D 0min ^P.^VM-^H [|kerberos]
+IP 10.0.0.1.88 > 0.234.154.214.24074:  v4 be KDC_REQUEST: ^O^O^O^O^O^O^O^O^O^DM-WM-WM-WM-WM-WM-WM-W.@ 680min  [|kerberos]
+IP 10.0.253.1.8280 > 0.234.154.214.24073: UDP, bad length 60652 > 32792
+IP 10.0.0.1.88 > 0.234.154.214.24074:  v4 be KDC_REQUEST: ^O^O^O^O^O7M-^@M-^?.d^O^O^O^O^O^O^O^O^O^O^O^O@^VM-^H [|kerberos]
+IP 10.0.0.1.88 > 0.234.154.214.24074:  v4 be KDC_REQUEST: ^O^O^O^O.^DM-2M-!^BM-W^CM-!^B@^D 0min ^P.^VM-^H [|kerberos]
+IP 10.0.0.1.88 > 0.234.154.214.24074:  v4 be KDC_REQUEST: ^O^O'^O^O@@.@^Qjp^J@ 1070min .X^^J^B [|kerberos]
+IP 10.0.0.1.88 > 0.234.154.214.24074:  v4 le APPL_REQUEST_MUTUAL: (unknown)
+01:00:01:00:00:00 > 02:8e:00:50:6a:e1, ethertype Unknown (0x08e8), length 3892667167: 
+       0x0000:  4408 8034 d92b 4000 4011 3b70 0a00 0001  D..4.+@.@.;p....
+       0x0010:  00ea 9ad6 0058 5e0a 02f4 0ab1 0402 ffff  .....X^.........
+       0x0020:  ff7f 80ff 80d6 00c3 0880 34d9 4040 0040  ..........4.@@.@
+       0x0030:  114a 700a 0016 88                        .Jp....
+IP 10.0.0.1.88 > 0.234.154.214.24074:  v4 be KDC_REQUEST: .M-oM-^?M-^?@M-^?M-^@M-V M-WM-WM-WM-WM-WM-WM-WM-W 0min ^VM-^H [|kerberos]
+IP 10.0.0.1.88 > 0.234.154.210.24073:  v4 be KDC_REQUEST: .M-^?M-^?^AM-^@M-^?M-^@M-V@M-WM-WM-sM-WM-WM-WM-WM-W 880min ^VM-^H [|kerberos]
+IP 10.0.0.1.88 > 0.234.154.214.24074:  v4 be KDC_REQUEST: ^O^O^O^O^O7M-^@M-^?.d^O^O^O^O^O^O^O^O^O^O^O^O@^VM-^H [|kerberos]
+IP 10.0.0.1.88 > 0.234.154.214.24074:  v4 be KDC_REQUEST: ^O^O^O^O.^DM-2M-!^BM-WM-^?M-!^B^O^O^P@M-^?M-^?^O^O^O [|kerberos]
+IP 10.0.0.1.88 > 0.234.154.214.24074:  v4 be KDC_REQUEST: ^O^O^O^O.^DM-#M-^?M-^?d^O^O^O^O^O^O^O^O^O^O^O^O@^VM-^H [|kerberos]
+IP 10.0.0.1.88 > 0.234.154.214.24074:  v4 be KDC_REQUEST: ^O^O^O^O.^DM-2M-!^BM-W^CM-!^B@^D 0min ^P.^VM-^H [|kerberos]
+IP 10.0.0.1.88 > 0.234.154.214.24074: 
+IP 10.0.0.1.88 > 0.234.154.214.24074:  v4 be KDC_REQUEST: ^O^O^O^O.^DM-^@M-^?M-^?M-^?^CM-!^B@^D 0min ^P.^VM-^H [|kerberos]
+IP 10.0.0.1.88 > 0.234.154.214.24074: 
+IP 10.0.253.1.88 > 0.234.154.214.24073:  v4 be KDC_REQUEST: .M-^?M-^?^AM-^@M-^?M-^@M-V@M-WM-WM-sM-WM-WM-WM-WM-W 880min ^VM-^H [|kerberos]
+IP 10.0.0.1.88 > 0.234.154.214.24074:  v4 be KDC_REQUEST: ^O^O^O^O^O7M-^@M-^?.d^O^O^O^O^O^O^O^O^O^O^O^O@^VM-^H [|kerberos]
+IP 10.0.0.1.88 > 0.234.154.214.24074:  v4 be KDC_REQUEST: ^O^O^O^O.^DM-2M-!^BM-W^CM-!^B@^D 0min ^P.^VM-^H [|kerberos]
+IP 10.0.0.1.88 > 0.234.154.214.24074:  v4 be KDC_REQUEST: ^O^O'^O^O@@.@^Qjp^J@ 1070min .X^^J^B [|kerberos]
+IP 64.0.0.1.88 > 0.234.154.214.24074:  v4 le APPL_REQUEST_MUTUAL: (unknown)
+IP 10.0.0.1.88 > 0.234.154.214.24074:  v4 be KDC_REQUEST: M-^?M-^?M-^?^?M-^@M-^?M-^@M-V.M-C^HM-^@4M-Y@@@@^QJp^J [|kerberos]
+IP 10.0.0.1.88 > 0.234.154.214.24074:  v4 be KDC_REQUEST: .M-oM-^?M-^?@M-^?M-^@M-V 75min ^O^O^O^O^O^O^O^O.^VM-^H [|kerberos]
+IP 10.0.0.1.88 > 0.234.154.214.24074:  v4 be KDC_REQUEST: ^O^O^O^O.^DM-2M-!^BM-W^CM-!^B@^D 0min ^P.^VM-^H [|kerberos]
+IP 10.0.0.1.88 > 0.234.154.214.24074:  v4 be KDC_REQUEST: ^O^O^O^O^O7M-^@M-^?M-^@^D^O^O^O^O^O^P.M-^?M-^?^O^O^O@^VM-^H [|kerberos]
+IP 10.0.0.1.88 > 0.234.154.214.24074:  v4 be KDC_REQUEST: ^O^O^O^O.^DM-^@M-^?M-^?M-^?^CM-!^B@^D 0min ^P.^VM-^H [|kerberos]
+IP 208.21.42.58.6697 > 110.228.104.254.30952: babel 2 (2056) (invalid)
diff --git a/tests/babel_update_oobr.pcap b/tests/babel_update_oobr.pcap
new file mode 100644 (file)
index 0000000..2406c04
Binary files /dev/null and b/tests/babel_update_oobr.pcap differ
diff --git a/tests/bgp-bgp_capabilities_print-oobr-1.out b/tests/bgp-bgp_capabilities_print-oobr-1.out
new file mode 100644 (file)
index 0000000..48cd19d
--- /dev/null
@@ -0,0 +1,27 @@
+IP (tos 0x1f,CE, ttl 254, id 38671, offset 0, flags [+, DF, rsvd], proto TCP (6), length 4135, bad cksum 200 (->1fdd)!)
+    226.219.0.0.179 > 16.233.34.0.100: Flags [SPUE], seq 347537408:347541483, win 511, urg 65535, options [eol], length 4075: BGP [|BGP]
+       Open Message (1), length: 59
+         Version 255, my AS 65528, Holdtime 4324s, ID 144.8.32.4
+         Optional parameters, length: 29
+           Option Unknown (0), length: 0
+             no decoder for option 0
+           Option Capabilities Advertisement (2), length: 8
+             Graceful Restart (64), length: 0
+               Restart Flags: [none], Restart Time 0s
+             Unknown (0), length: 0
+               no decoder for Capability 0
+             32-Bit AS Number (65), length: 4
+                4 Byte AS 2
+           Option Unknown (0), length: 2
+             no decoder for option 0
+           Option Capabilities Advertisement (2), length: 2
+             Unknown (232), length: 3
+               no decoder for Capability 232
+               0x0000:  0207 04
+           Option Capabilities Advertisement (2), length: 7
+             Multiple Routes to a Destination (4), length: 0
+               no decoder for Capability 4
+             Unknown (8), length: 0
+               no decoder for Capability 8
+             Route Refresh (Cisco) (128), length: 0
+             Graceful Restart (64), length: 0[|BGP]
diff --git a/tests/bgp-bgp_capabilities_print-oobr-1.pcap b/tests/bgp-bgp_capabilities_print-oobr-1.pcap
new file mode 100644 (file)
index 0000000..61a5351
Binary files /dev/null and b/tests/bgp-bgp_capabilities_print-oobr-1.pcap differ
diff --git a/tests/bgp-bgp_capabilities_print-oobr-2.out b/tests/bgp-bgp_capabilities_print-oobr-2.out
new file mode 100644 (file)
index 0000000..21de6f9
--- /dev/null
@@ -0,0 +1,26 @@
+IP (tos 0x1f,CE, ttl 254, id 38671, offset 0, flags [+, DF, rsvd], proto TCP (6), length 4135, bad cksum 200 (->1fdd)!)
+    226.219.0.0.179 > 16.233.34.0.100: Flags [SPUE], seq 347537408:347541483, win 511, urg 65535, options [eol], length 4075: BGP [|BGP]
+       Open Message (1), length: 59
+         Version 255, my AS 65528, Holdtime 4324s, ID 144.8.32.4
+         Optional parameters, length: 29
+           Option Unknown (0), length: 0
+             no decoder for option 0
+           Option Capabilities Advertisement (2), length: 8
+             Graceful Restart (64), length: 0
+               Restart Flags: [none], Restart Time 0s
+             Unknown (0), length: 0
+               no decoder for Capability 0
+             32-Bit AS Number (65), length: 4
+                4 Byte AS 2
+           Option Unknown (0), length: 2
+             no decoder for option 0
+           Option Capabilities Advertisement (2), length: 2
+             Unknown (232), length: 3
+               no decoder for Capability 232
+               0x0000:  0207 04
+           Option Capabilities Advertisement (2), length: 7
+             Multiple Routes to a Destination (4), length: 0
+               no decoder for Capability 4
+             Unknown (8), length: 0
+               no decoder for Capability 8
+             Multiprotocol Extensions (1), length: 0[|BGP]
diff --git a/tests/bgp-bgp_capabilities_print-oobr-2.pcap b/tests/bgp-bgp_capabilities_print-oobr-2.pcap
new file mode 100644 (file)
index 0000000..5c2e1d2
Binary files /dev/null and b/tests/bgp-bgp_capabilities_print-oobr-2.pcap differ
diff --git a/tests/bgp_mp_reach_nlri-oobr.out b/tests/bgp_mp_reach_nlri-oobr.out
new file mode 100644 (file)
index 0000000..df68625
--- /dev/null
@@ -0,0 +1,277 @@
+IP (tos 0xff,CE, ttl 254, id 32783, offset 0, flags [rsvd], proto TCP (6), length 65535, bad cksum 8e15 (->5bbf)!)
+    241.0.128.39.179 > 239.0.0.1.0: Flags [none], seq 4144029695:4144095150, win 65535, options [eol], length 65455: BGP [|BGP]
+       Update Message (2), length: 45
+         Withdrawn routes: 3 bytes
+         Attribute Set (128), length: 32768, Flags [OTPE+f]: [|BGP] [|BGP]
+       Update Message (2), length: 45
+         Withdrawn routes: 3 bytes
+         Attribute Set (128), length: 7, Flags [OTPE+f]: 
+           Origin AS: 0
+             Multi-Protocol Reach NLRI (14), length: 227, Flags [T+6]: 
+           AFI: NSAP (3), SAFI: labeled VPN Unicast (128)
+           nexthop: invalid len, nh-length: 1, no SNPA
+             RD: unknown RD format, 00.0000.0000.0d00.0000.0000.00/91, label:15 (bottom)
+           (illegal prefix length)
+             Multi-Protocol Reach NLRI (14), length: 227, Flags [T+6]: 
+           AFI: NSAP (3), SAFI: labeled VPN Unicast (128)
+           nexthop: RD: unknown RD format, 05.0000.0000.0000.0000.000d.0000, nh-length: 21, no SNPA
+           (illegal prefix length)
+             Unknown Attribute (0), length: 0
+           no Attribute 0 decoder
+             Unknown Attribute (0), length: 0
+           no Attribute 0 decoder
+             Unknown Attribute (0), length: 0
+           no Attribute 0 decoder
+             Unknown Attribute (0), length: 0
+           no Attribute 0 decoder
+             Unknown Attribute (0), length: 0
+           no Attribute 0 decoder
+             Unknown Attribute (80), length: 0
+           no Attribute 80 decoder
+             Unknown Attribute (157), length: 161, Flags [P+d]: 
+           no Attribute 157 decoder
+           0x0000:  0280 fdff ffff ffff ffff ffff ffff ffff
+           0x0010:  ffff ff00 2d02 0003 f1ff 7bc3 b2ff 8000
+           0x0020:  0700 0000 df00 c123 0000 0000 00a1 0200
+           0x0030:  9eff ffff ffff ffff ffff ffff ffff ff94
+           0x0040:  9494 2d02 0003 f1ff 7bc3 b2ff 8000 0700
+           0x0050:  0000 0046 0ee3 0003 8015 00b3 0000 f700
+           0x0060:  dfee 0500 0000 0000 0000 0000 0000 0000
+           0x0070:  0000 0000 0000 0000 0000 0000 0000 0000
+           0x0080:  0000 de00 0000 0000 0000 0000 0000 0001
+           0x0090:  0000 0000 0000 0000 0000 0000 0000 0000
+           0x00a0:  00
+             Unknown Attribute (0), length: 0
+           no Attribute 0 decoder
+             Unknown Attribute (0), length: 0
+           no Attribute 0 decoder
+             Unknown Attribute (0), length: 0
+           no Attribute 0 decoder
+             Unknown Attribute (0), length: 0
+           no Attribute 0 decoder
+             Unknown Attribute (0), length: 0
+           no Attribute 0 decoder
+             Unknown Attribute (0), length: 0
+           no Attribute 0 decoder
+             Unknown Attribute (0), length: 0
+           no Attribute 0 decoder
+             Unknown Attribute (0), length: 0
+           no Attribute 0 decoder
+             Unknown Attribute (0), length: 0
+           no Attribute 0 decoder
+             Unknown Attribute (0), length: 0
+           no Attribute 0 decoder
+             Unknown Attribute (0), length: 0
+           no Attribute 0 decoder
+             Unknown Attribute (0), length: 0
+           no Attribute 0 decoder
+             Unknown Attribute (0), length: 0
+           no Attribute 0 decoder
+             Unknown Attribute (0), length: 140
+           no Attribute 0 decoder
+           0x0000:  0000 0000 0000 0080 27ef 0000 0100 c600
+           0x0010:  007f f3f9 8900 0107 07d4 2d9d a102 80fd
+           0x0020:  ecff ff04 00ff 4000 0000 ffff ffff ffff
+           0x0030:  002d 0200 03f1 ff7b c3b2 ff80 0007 434c
+           0x0040:  4945 4e54 0000 00df 00c1 2300 0000 0000
+           0x0050:  ff00 0000 ff00 0000 04ff ffff ffff ffff
+           0x0060:  ffff ffff 002d 0200 03f1 ff7b c3b2 ff80
+           0x0070:  0007 0000 0000 460e e300 0380 1500 b300
+           0x0080:  00f7 00df ee35 0000 0500 0000
+             Unknown Attribute (0), length: 0
+           no Attribute 0 decoder
+             Unknown Attribute (0), length: 0
+           no Attribute 0 decoder[|BGP] [|BGP]
+       Update Message (2), length: 45
+         Withdrawn routes: 3 bytes
+         Attribute Set (128), length: 7, Flags [OTPE+f]: 
+           Origin AS: 223
+             Unknown Attribute (193), length: 35
+           no Attribute 193 decoder
+           0x0000:  0000 0000 00a1 0200 9eff ffff ffff fffc
+           0x0010:  ffff ffff ffff ffff ff00 2d02 0003 f1ff
+           0x0020:  7bc3 b2
+             Attribute Set (128), length: 7, Flags [OTPE+f]: 
+           Origin AS: 0
+             Multi-Protocol Reach NLRI (14), length: 227, Flags [T+6]: 
+           AFI: NSAP (3), SAFI: labeled VPN Unicast (128)
+           nexthop: RD: unknown RD format, 05.0000.0000.0000.0000.000d.0000, nh-length: 21, no SNPA
+           (illegal prefix length)
+             Unknown Attribute (0), length: 0
+           no Attribute 0 decoder
+             Unknown Attribute (0), length: 0
+           no Attribute 0 decoder
+             Unknown Attribute (0), length: 0
+           no Attribute 0 decoder
+             Unknown Attribute (0), length: 0
+           no Attribute 0 decoder
+             Unknown Attribute (0), length: 0
+           no Attribute 0 decoder
+             Unknown Attribute (80), length: 0
+           no Attribute 80 decoder
+             Unknown Attribute (157), length: 161, Flags [P+d]: 
+           no Attribute 157 decoder
+           0x0000:  0280 fdff ffff ffff ffff ffff ffff ffff
+           0x0010:  ffff ff00 2d02 0003 f1ff 7bc3 b2ff 8000
+           0x0020:  0700 0000 df00 c123 0000 0000 00a1 0200
+           0x0030:  9eff ffff ffff ffff ffff ffff ffff ff94
+           0x0040:  9494 2d02 0003 f1ff 7bc3 b2ff 8000 0700
+           0x0050:  0000 0046 0ee3 0003 8015 00b3 0000 f700
+           0x0060:  dfee 0500 0000 0000 0000 0000 0000 0000
+           0x0070:  0000 0000 0000 0000 0000 0000 0000 0000
+           0x0080:  0000 de00 0000 0000 0000 0000 0000 0001
+           0x0090:  0000 0000 0000 0000 0000 0000 0000 0000
+           0x00a0:  00
+             Unknown Attribute (0), length: 0
+           no Attribute 0 decoder
+             Unknown Attribute (0), length: 0
+           no Attribute 0 decoder
+             Unknown Attribute (0), length: 0
+           no Attribute 0 decoder
+             Unknown Attribute (0), length: 0
+           no Attribute 0 decoder
+             Unknown Attribute (0), length: 0
+           no Attribute 0 decoder
+             Unknown Attribute (0), length: 0
+           no Attribute 0 decoder
+             Unknown Attribute (0), length: 0
+           no Attribute 0 decoder
+             Unknown Attribute (0), length: 0
+           no Attribute 0 decoder
+             Unknown Attribute (0), length: 0
+           no Attribute 0 decoder
+             Unknown Attribute (0), length: 0
+           no Attribute 0 decoder
+             Unknown Attribute (0), length: 0
+           no Attribute 0 decoder
+             Unknown Attribute (0), length: 0
+           no Attribute 0 decoder
+             Unknown Attribute (0), length: 0
+           no Attribute 0 decoder
+             Unknown Attribute (0), length: 140
+           no Attribute 0 decoder
+           0x0000:  0000 0000 0000 0080 27ef 0000 0100 c600
+           0x0010:  007f f3f9 8900 0107 07d4 2d9d a102 80fd
+           0x0020:  ecff ff04 00ff 4000 0000 ffff ffff ffff
+           0x0030:  002d 0200 03f1 ff7b c3b2 ff80 0007 434c
+           0x0040:  4945 4e54 0000 00df 00c1 2300 0000 0000
+           0x0050:  ff00 0000 ff00 0000 04ff ffff ffff ffff
+           0x0060:  ffff ffff 002d 0200 03f1 ff7b c3b2 ff80
+           0x0070:  0007 0000 0000 460e e300 0380 1500 b300
+           0x0080:  00f7 00df ee35 0000 0500 0000
+             Unknown Attribute (0), length: 0
+           no Attribute 0 decoder
+             Unknown Attribute (0), length: 0
+           no Attribute 0 decoder[|BGP] [|BGP]
+       Update Message (2), length: 45
+         Withdrawn routes: 3 bytes
+         Attribute Set (128), length: 7, Flags [OTPE+f]: 
+           Origin AS: 223
+             Unknown Attribute (193), length: 35
+           no Attribute 193 decoder
+           0x0000:  0000 0000 00a1 0200 0aff ffff ffff ffff
+           0x0010:  ffff ffff ffff ffff ff00 2d02 0003 f1ff
+           0x0020:  7bc3 b2
+             Unknown Attribute (241), length: 255, Flags [+3]: 
+           no Attribute 241 decoder
+           0x0000:  7bc3 b2ff 8000 0700 0000 0046 0ee3 0003
+           0x0010:  8001 00b3 0000 f700 dfee 0500 0000 0000
+           0x0020:  0000 0000 0d00 0000 0000 0000 0000 0000
+           0x0030:  0000 0000 0000 00ff 8000 0700 0000 0046
+           0x0040:  0ee3 0003 8015 00cd 0000 f700 dfee 0500
+           0x0050:  0000 0000 0000 0000 1b00 0000 fff5 0000
+           0x0060:  0000 0000 0000 0000 0000 0000 0000 0000
+           0x0070:  0000 0000 0000 0000 5000 2d9d a102 80fd
+           0x0080:  ffff ffff ffff ffff ffff ffff ffff ffff
+           0x0090:  002d 0200 03f1 ff7b c3b2 ff80 0007 0000
+           0x00a0:  00df 00c1 2300 0000 0000 a102 009e ffff
+           0x00b0:  ffff ffff ffff ffff ffff ffff 9494 942d
+           0x00c0:  0200 03f1 ff7b c3b2 ff80 0007 0000 0000
+           0x00d0:  460e e300 0380 1500 b300 00f7 00df ee05
+           0x00e0:  0000 0000 0000 0000 0000 0000 0000 0000
+           0x00f0:  0000 0000 0000 0000 0000 0000 0000 00
+             Unknown Attribute (0), length: 0, Flags [OTE+e]: 
+           no Attribute 0 decoder
+             Unknown Attribute (0), length: 0
+           no Attribute 0 decoder
+             Unknown Attribute (0), length: 0
+           no Attribute 0 decoder
+             Unknown Attribute (0), length: 0
+           no Attribute 0 decoder
+             Unknown Attribute (0), length: 0, Flags [+1]: 
+           no Attribute 0 decoder
+             Unknown Attribute (0), length: 0
+           no Attribute 0 decoder
+             Unknown Attribute (0), length: 0
+           no Attribute 0 decoder
+             Unknown Attribute (0), length: 0
+           no Attribute 0 decoder
+             Unknown Attribute (0), length: 0
+           no Attribute 0 decoder
+             Unknown Attribute (0), length: 0
+           no Attribute 0 decoder
+             Unknown Attribute (0), length: 0
+           no Attribute 0 decoder
+             Unknown Attribute (0), length: 0
+           no Attribute 0 decoder
+             Unknown Attribute (0), length: 0
+           no Attribute 0 decoder
+             Unknown Attribute (0), length: 0
+           no Attribute 0 decoder
+             Unknown Attribute (0), length: 0
+           no Attribute 0 decoder
+             Unknown Attribute (0), length: 0
+           no Attribute 0 decoder
+             Unknown Attribute (0), length: 0
+           no Attribute 0 decoder
+             Unknown Attribute (0), length: 0
+           no Attribute 0 decoder
+             Unknown Attribute (0), length: 0
+           no Attribute 0 decoder
+             Unknown Attribute (0), length: 0
+           no Attribute 0 decoder
+             Unknown Attribute (0), length: 0
+           no Attribute 0 decoder
+             Unknown Attribute (0), length: 0
+           no Attribute 0 decoder
+             Unknown Attribute (0), length: 0
+           no Attribute 0 decoder
+             Unknown Attribute (0), length: 140
+           no Attribute 0 decoder
+           0x0000:  0000 0000 0000 0080 27ef 0000 0100 c600
+           0x0010:  007f f3f9 8900 0107 07d4 2d9d a102 80fd
+           0x0020:  ecff ff04 00ff 4000 0000 ffff ffff ffff
+           0x0030:  002d 0200 03f1 ff7b c3b2 ff80 0007 434c
+           0x0040:  4945 4e54 0000 00df 00c1 2300 0000 0000
+           0x0050:  ff00 0000 ff00 0000 04ff ffff ffff ffff
+           0x0060:  ffff ffff 002d 0200 03f1 ff7b c3b2 ff80
+           0x0070:  0007 0000 0000 460e e300 0380 1500 b300
+           0x0080:  00f7 00df ee35 0000 0500 0000
+             Unknown Attribute (0), length: 0
+           no Attribute 0 decoder
+             Unknown Attribute (0), length: 0
+           no Attribute 0 decoder[|BGP] [|BGP]
+       Update Message (2), length: 45
+         Withdrawn routes: 3 bytes
+         Unknown Attribute (241), length: 255, Flags [+3]: [|BGP] [|BGP]
+       Update Message (2), length: 45
+         Withdrawn routes: 3 bytes
+         Attribute Set (128), length: 7, Flags [OTPE+f]: 
+           Origin AS: 223
+             Unknown Attribute (193), length: 35
+           no Attribute 193 decoder
+           0x0000:  0000 0000 00a1 0200 9eff ffff ffff ffff
+           0x0010:  ffff ffff ffff ff94 9494 2d02 0003 f1ff
+           0x0020:  7bc3 b2
+             Attribute Set (128), length: 7, Flags [OTPE+f]: 
+           Origin AS: 0
+             Multi-Protocol Reach NLRI (14), length: 227, Flags [T+6]: 
+           AFI: NSAP (3), SAFI: labeled VPN Unicast (128)
+           nexthop: RD: unknown RD format, 05.0000.0000.0000.0000.0000.0000, nh-length: 21, no SNPA
+           (illegal prefix length)
+             Attribute Set (128), length: 7, Flags [OTPE+f]: 
+           Origin AS: 0
+             Multi-Protocol Reach NLRI (14), length: 227, Flags [T+6]: 
+           AFI: NSAP (3), SAFI: labeled VPN Unicast (128)
+           nexthop: RD: unknown RD format, 35.0000.0500.0000.0000.0000.0000, nh-length: 21, no SNPA
+           (illegal prefix length)[|BGP]
diff --git a/tests/bgp_mp_reach_nlri-oobr.pcap b/tests/bgp_mp_reach_nlri-oobr.pcap
new file mode 100644 (file)
index 0000000..dc0b57f
Binary files /dev/null and b/tests/bgp_mp_reach_nlri-oobr.pcap differ
index 16a2855..558e660 100755 (executable)
@@ -1,42 +1,52 @@
 #!/bin/sh
 
+srcdir=${1-..}
+: echo crypto.sh using ${srcdir} from `pwd`
+
+SRCDIR=$srcdir
+export SRCDIR
+
+testdir=${srcdir}/tests
+
 exitcode=0
+passedfile=tests/.passed
+failedfile=tests/.failed
+passed=`cat ${passedfile}`
+failed=`cat ${failedfile}`
 
 # Only attempt OpenSSL-specific tests when compiled with the library.
 
-if grep '^#define HAVE_LIBCRYPTO 1$' ../config.h >/dev/null
+if grep '^#define HAVE_LIBCRYPTO 1$' config.h >/dev/null
 then
-       passed=`cat .passed`
-       failed=`cat .failed`
-       if ./TESTonce esp1 02-sunrise-sunset-esp.pcap esp1.out '-E "0x12345678@192.1.2.45 3des-cbc-hmac96:0x4043434545464649494a4a4c4c4f4f515152525454575758"'
+       if ${testdir}/TESTonce esp1 ${testdir}/02-sunrise-sunset-esp.pcap ${testdir}/esp1.out '-E "0x12345678@192.1.2.45 3des-cbc-hmac96:0x4043434545464649494a4a4c4c4f4f515152525454575758"'
        then
                passed=`expr $passed + 1`
-               echo $passed >.passed
+               echo $passed >${passedfile}
        else
                failed=`expr $failed + 1`
-               echo $failed >.failed
+               echo $failed >${failedfile}
                exitcode=1
        fi
-       if ./TESTonce esp2 08-sunrise-sunset-esp2.pcap esp2.out '-E "0x12345678@192.1.2.45 3des-cbc-hmac96:0x43434545464649494a4a4c4c4f4f51515252545457575840,0xabcdabcd@192.0.1.1 3des-cbc-hmac96:0x434545464649494a4a4c4c4f4f5151525254545757584043"'
+       if ${testdir}//TESTonce esp2 ${testdir}/08-sunrise-sunset-esp2.pcap ${testdir}/esp2.out '-E "0x12345678@192.1.2.45 3des-cbc-hmac96:0x43434545464649494a4a4c4c4f4f51515252545457575840,0xabcdabcd@192.0.1.1 3des-cbc-hmac96:0x434545464649494a4a4c4c4f4f5151525254545757584043"'
        then
                passed=`expr $passed + 1`
-               echo $passed >.passed
+               echo $passed >${passedfile}
        else
                failed=`expr $failed + 1`
-               echo $failed >.failed
+               echo $failed >${failedfile}
                exitcode=1
        fi
-       if ./TESTonce esp3 02-sunrise-sunset-esp.pcap esp1.out '-E "3des-cbc-hmac96:0x4043434545464649494a4a4c4c4f4f515152525454575758"'
+       if ${testdir}/TESTonce esp3 ${testdir}/02-sunrise-sunset-esp.pcap ${testdir}/esp1.out '-E "3des-cbc-hmac96:0x4043434545464649494a4a4c4c4f4f515152525454575758"'
        then
                passed=`expr $passed + 1`
-               echo $passed >.passed
+               echo $passed >${passedfile}
        else
                failed=`expr $failed + 1`
-               echo $failed >.failed
+               echo $failed >${failedfile}
                exitcode=1
        fi
        # Reading the secret(s) from a file does not work with Capsicum.
-       if grep '^#define HAVE_CAPSICUM 1$' ../config.h >/dev/null
+       if grep '^#define HAVE_CAPSICUM 1$' config.h >/dev/null
        then
                FORMAT='    %-35s: TEST SKIPPED (compiled w/Capsicum)\n'
                printf "$FORMAT" esp4
@@ -45,68 +55,68 @@ then
                printf "$FORMAT" ikev2pI2
                printf "$FORMAT" isakmp4
        else
-               if ./TESTonce esp4 08-sunrise-sunset-esp2.pcap esp2.out '-E "file esp-secrets.txt"'
+               if ${testdir}/TESTonce esp4 ${testdir}/08-sunrise-sunset-esp2.pcap ${testdir}/esp4.out '-E "file '${testdir}'/esp-secrets.txt"'
                then
                        passed=`expr $passed + 1`
-                       echo $passed >.passed
+                       echo $passed >${passedfile}
                else
                        failed=`expr $failed + 1`
-                       echo $failed >.failed
+                       echo $failed >${failedfile}
                        exitcode=1
                fi
-               if ./TESTonce esp5 08-sunrise-sunset-aes.pcap esp5.out '-E "file esp-secrets.txt"'
+               if ${testdir}/TESTonce esp5 ${testdir}/08-sunrise-sunset-aes.pcap ${testdir}/esp5.out '-E "file '${testdir}'/esp-secrets.txt"'
                then
                        passed=`expr $passed + 1`
-                       echo $passed >.passed
+                       echo $passed >${passedfile}
                else
                        failed=`expr $failed + 1`
-                       echo $failed >.failed
+                       echo $failed >${failedfile}
                        exitcode=1
                fi
-               if ./TESTonce espudp1 espudp1.pcap espudp1.out '-nnnn -E "file esp-secrets.txt"'
+               if ${testdir}/TESTonce espudp1 ${testdir}/espudp1.pcap ${testdir}/espudp1.out '-nnnn -E "file '${testdir}'/esp-secrets.txt"'
                then
                        passed=`expr $passed + 1`
-                       echo $passed >.passed
+                       echo $passed >${passedfile}
                else
                        failed=`expr $failed + 1`
-                       echo $failed >.failed
+                       echo $failed >${failedfile}
                        exitcode=1
                fi
-               if ./TESTonce ikev2pI2 ikev2pI2.pcap ikev2pI2.out '-E "file ikev2pI2-secrets.txt" -v -v -v -v'
+               if ${testdir}/TESTonce ikev2pI2 ${testdir}/ikev2pI2.pcap ${testdir}/ikev2pI2.out '-E "file '${testdir}'/ikev2pI2-secrets.txt" -v -v -v -v'
                then
                        passed=`expr $passed + 1`
-                       echo $passed >.passed
+                       echo $passed >${passedfile}
                else
                        failed=`expr $failed + 1`
-                       echo $failed >.failed
+                       echo $failed >${failedfile}
                        exitcode=1
                fi
-               if ./TESTonce isakmp4 isakmp4500.pcap isakmp4.out '-E "file esp-secrets.txt"'
+               if ${testdir}/TESTonce isakmp4 ${testdir}/isakmp4500.pcap ${testdir}/isakmp4.out '-E "file '${testdir}'/esp-secrets.txt"'
                then
                        passed=`expr $passed + 1`
-                       echo $passed >.passed
+                       echo $passed >${passedfile}
                else
                        failed=`expr $failed + 1`
-                       echo $failed >.failed
+                       echo $failed >${failedfile}
                        exitcode=1
                fi
        fi
-       if ./TESTonce bgp-as-path-oobr-ssl bgp-as-path-oobr.pcap bgp-as-path-oobr-ssl.out '-vvv -e'
+       if ${testdir}/TESTonce bgp-as-path-oobr-ssl ${testdir}/bgp-as-path-oobr.pcap ${testdir}/bgp-as-path-oobr-ssl.out '-vvv -e'
        then
                passed=`expr $passed + 1`
-               echo $passed >.passed
+               echo $passed >${passedfile}
        else
                failed=`expr $failed + 1`
-               echo $failed >.failed
+               echo $failed >${failedfile}
                exitcode=1
        fi
-       if ./TESTonce bgp-aigp-oobr-ssl bgp-aigp-oobr.pcap bgp-aigp-oobr-ssl.out '-vvv -e'
+       if ${testdir}/TESTonce bgp-aigp-oobr-ssl ${testdir}/bgp-aigp-oobr.pcap ${testdir}/bgp-aigp-oobr-ssl.out '-vvv -e'
        then
                passed=`expr $passed + 1`
-               echo $passed >.passed
+               echo $passed >${passedfile}
        else
                failed=`expr $failed + 1`
-               echo $failed >.failed
+               echo $failed >${failedfile}
                exitcode=1
        fi
        FORMAT='    %-35s: TEST SKIPPED (compiled w/OpenSSL)\n'
@@ -124,22 +134,22 @@ else
        printf "$FORMAT" isakmp4
        printf "$FORMAT" bgp-as-path-oobr-ssl
        printf "$FORMAT" bgp-aigp-oobr-ssl
-       if ./TESTonce bgp-as-path-oobr-nossl bgp-as-path-oobr.pcap bgp-as-path-oobr-nossl.out '-vvv -e'
+       if ${testdir}/TESTonce bgp-as-path-oobr-nossl ${testdir}/bgp-as-path-oobr.pcap ${testdir}/bgp-as-path-oobr-nossl.out '-vvv -e'
        then
                passed=`expr $passed + 1`
-               echo $passed >.passed
+               echo $passed >${passedfile}
        else
                failed=`expr $failed + 1`
-               echo $failed >.failed
+               echo $failed >${failedfile}
                exitcode=1
        fi
-       if ./TESTonce bgp-aigp-oobr-nossl bgp-aigp-oobr.pcap bgp-aigp-oobr-nossl.out '-vvv -e'
+       if ${testdir}/TESTonce bgp-aigp-oobr-nossl ${testdir}/bgp-aigp-oobr.pcap ${testdir}/bgp-aigp-oobr-nossl.out '-vvv -e'
        then
                passed=`expr $passed + 1`
-               echo $passed >.passed
+               echo $passed >${passedfile}
        else
                failed=`expr $failed + 1`
-               echo $failed >.failed
+               echo $failed >${failedfile}
                exitcode=1
        fi
 fi
diff --git a/tests/cve-2018-10105-segv-sflowprint.out b/tests/cve-2018-10105-segv-sflowprint.out
new file mode 100644 (file)
index 0000000..7285f24
--- /dev/null
@@ -0,0 +1,2 @@
+IP (tos 0x0, ttl 64, id 60790, offset 0, flags [none], proto UDP (17), length 896, bad cksum 72f3 (->72f7)!)
+    10.0.0.250.3895 > 10.1.2.5.6343: sFlowv5 [length 8 < 28] (invalid)
diff --git a/tests/cve-2018-10105-segv-sflowprint.pcapng b/tests/cve-2018-10105-segv-sflowprint.pcapng
new file mode 100644 (file)
index 0000000..60b2869
Binary files /dev/null and b/tests/cve-2018-10105-segv-sflowprint.pcapng differ
diff --git a/tests/cve-2018-10105_smbprint-readofsize1.out b/tests/cve-2018-10105_smbprint-readofsize1.out
new file mode 100644 (file)
index 0000000..81729eb
--- /dev/null
@@ -0,0 +1,8 @@
+IP 192.168.56.55.445 > 192.168.56.119.49199: Flags [P.], seq 4267808374:4267808462, ack 628292694, win 63102, length 88 SMB PACKET: SMBtrans2 (REPLY)
+
+IP 192.168.56.119.49199 > 192.168.56.55.445: Flags [P.], seq 1:75, ack 88, win 254, length 74 SMB PACKET: SMBtrans2 (REQUEST)
+
+IP 192.168.56.55.445 > 192.168.56.119.49199: Flags [P.], seq 88:168, ack 75, win 62978, length 80 SMB PACKET: SMBtrans2 (REPLY)
+
+IP 192.168.56.119.49199 > 192.168.56.55.445: Flags [P.], seq 75:151, ack 168, win 253, length 76 SMB PACKET: SMBtrans2 (REQUEST)
+
diff --git a/tests/cve-2018-10105_smbprint-readofsize1.pcap b/tests/cve-2018-10105_smbprint-readofsize1.pcap
new file mode 100644 (file)
index 0000000..984bc3a
Binary files /dev/null and b/tests/cve-2018-10105_smbprint-readofsize1.pcap differ
diff --git a/tests/cve-2018-10105_smbutil_withoutasan.out b/tests/cve-2018-10105_smbutil_withoutasan.out
new file mode 100644 (file)
index 0000000..3a2ad23
--- /dev/null
@@ -0,0 +1,101 @@
+IP (tos 0x0, ttl 128, id 376, offset 0, flags [DF], proto TCP (6), length 128)
+    192.168.56.55.445 > 192.168.56.119.49199: Flags [P.], cksum 0x3e2f (incorrect -> 0x3d49), seq 4267808374:4267808462, ack 628292694, win 63102, length 88 
+SMB PACKET: SMBtrans2 (REPLY)
+SMB Command   =  0x32
+Error class   =  0x0
+Error code    =  0 (0x0)
+Flags1        =  0xFF
+Flags2        =  0x7
+Tree ID       =  2048 (0x800)
+Proc ID       =  2848 (0xb20)
+UID           =  4098 (0x1002)
+MID           =  1616 (0x650)
+Word Count    =  10 (0xa)
+TRANSACT2_OPEN param_length=2 data_length=24
+TotParam=2 (0x2)
+TotData=24 (0x18)
+Res1=0x0
+ParamCnt=2 (0x2)
+ParamOff=56 (0x38)
+ParamDisp0 (0x0)
+DataCnt=24 (0x18)
+DataOff=60 (0x3c)
+DataDisp=0 (0x0)
+SetupCnt=0 (0x0)
+smb_bcc=29
+Handle=0 (0x0)
+Attrib=Data=
+Data: (24 bytes)
+[000] 00 00 0B 00 00 00 00 00  00 00 00 00 00 00 00 00  \0x00\0x00\0x0b\0x00\0x00\0x00\0x00\0x00 \0x00\0x00\0x00\0x00\0x00\0x00\0x00\0x00
+[010] 01 00 00 00 00 00 00 00                           \0x01\0x00\0x00\0x00\0x00\0x00\0x00\0x00 
+
+IP 192.168.56.119.49199 > 192.168.56.55.445: Flags [P.], seq 1:75, ack 88, win 254, length 74 SMB PACKET: SMBtrans2 (REQUEST)
+
+IP (tos 0x0, ttl 128, id 632, offset 0, flags [DF], proto TCP (6), length 114)
+    192.168.56.119.49199 > 192.168.56.55.445: Flags [P.], cksum 0x2437 (correct), seq 1:75, ack 88, win 254, length 74 
+SMB PACKET: SMBtrans2 (REQUEST)
+SMB Command   =  0x32
+Error class   =  0x0
+Error code    =  0 (0x0)
+Flags1        =  0x18
+Flags2        =  0x7
+Tree ID       =  2048 (0x800)
+Proc ID       =  2848 (0xb20)
+UID           =  4098 (0x1002)
+MID           =  1632 (0x660)
+Word Count    =  15 (0xf)
+TRANSACT2_QFSINFO param_length=2 data_length=0
+TotParam=2 (0x2)
+TotData=0 (0x0)
+MaxParam=0 (0x0)
+MaxData=560 (0x230)
+MaxSetup=0 (0x0)
+Flags=0x0
+TimeOut=0 (0x0)
+Res1=0x0
+ParamCnt=2 (0x2)
+ParamOff=68 (0x44)
+DataCnt=0 (0x0)
+DataOff=0 (0x0)
+SetupCnt=1 (0x1)
+smb_bcc=5
+InfoLevel=261 (0x105)
+
+
+IP (tos 0x0, ttl 128, id 377, offset 0, flags [DF], proto TCP (6), length 120)
+    192.168.56.55.445 > 192.168.56.119.49199: Flags [P.], cksum 0xf1fb (incorrect -> 0x1559), seq 88:168, ack 75, win 63028, length 80 
+SMB PACKET: SMBtrans2 (REPLY)
+SMB Command   =  0x32
+Error class   =  0x0
+Error code    =  0 (0x0)
+Flags1        =  0x98
+Flags2        =  0x7
+Tree ID       =  0 (0x0)
+Proc ID       =  0 (0x0)
+UID           =  0 (0x0)
+MID           =  0 (0x0)
+Word Count    =  11 (0xb)
+TRANSACT2_QFSINFO param_length=0 data_length=20
+TotParam=0 (0x0)
+TotData=0 (0x0)
+Res1=0x0
+ParamCnt=0 (0x0)
+ParamOff=56 (0x38)
+ParamDisp0 (0x0)
+DataCnt=20 (0x14)
+DataOff=56 (0x38)
+DataDisp=0 (0x0)
+SetupCnt=0 (0x0)
+smb_bcc=65280
+Capabilities=0x700FF
+MaxFileLen=255 (0xff)
+VolNameLen=4278190088
+Volume=...
+data:
+[000] FF 00 07 00 FF 00 00 00  08 00 00 FF FF FF FF 00  \0xff\0x00\0x07\0x00\0xff\0x00\0x00\0x00 \0x08\0x00\0x00\0xff\0xff\0xff\0xff\0x00
+[010] 46 00 53 00                                       F\0x00S\0x00 
+
+
+IP (tos 0x0, ttl 128, id 633, offset 0, flags [DF], proto TCP (6), length 116)
+    192.168.56.119.49199 > 192.168.56.55.445: Flags [P.], cksum 0x2253 (incorrect -> 0x229b), seq 75:151, ack 168, win 253, length 76 SMB-over-TCP packet:(raw data or continuation?)
+
diff --git a/tests/cve-2018-10105_smbutil_withoutasan.pcap b/tests/cve-2018-10105_smbutil_withoutasan.pcap
new file mode 100644 (file)
index 0000000..3b29577
Binary files /dev/null and b/tests/cve-2018-10105_smbutil_withoutasan.pcap differ
index 3658c19..3c8da0f 100644 (file)
@@ -1,3 +1,4 @@
 IP6 truncated-ip6 - 26325 bytes missing!(class 0x76, flowlabel 0x76767, hlim 103, next-header Mobility (135) payload length: 26470) 6767:6767:6767:6767:6767:6767:6767:6767 > 6767:6767:6767:6767:6767:6767:6767:6705: mobility: BU seq#=26471 HL lifetime=105884(type-0x67: len=103)[|MOBILITY]
 IP6 truncated-ip6 - 26325 bytes missing!(class 0x76, flowlabel 0x76767, hlim 103, next-header Mobility (135) payload length: 26470) 6767:6767:6767:6767:6767:6767:6767:6767 > 6767:6767:4f67:6767:6767:6767:6767:6767: (header length 8 is too small for type 6)[|MOBILITY]
-EXIT CODE 00000100
+
+EXIT CODE 00000100: dump:0 code: 1
diff --git a/tests/cve2015-0261-ipv6.out.stderr b/tests/cve2015-0261-ipv6.out.stderr
new file mode 100644 (file)
index 0000000..7b04def
--- /dev/null
@@ -0,0 +1,2 @@
+reading from file cve2015-0261-ipv6.pcap, link-type SLIP (SLIP)
+tcpdump: pcap_loop: invalid packet capture length 268463617, bigger than snaplen of 65535
diff --git a/tests/dccp_options-oobr.out b/tests/dccp_options-oobr.out
new file mode 100644 (file)
index 0000000..8ca46ef
--- /dev/null
@@ -0,0 +1,19 @@
+IP (tos 0x0, ttl 64, id 65312, offset 0, flags [DF], proto DCCP (33), length 52)
+    139.133.209.176.39420 > 139.133.209.65.5001: DCCP (CCVal 0, CsCov 0, cksum 0xaaf3 (incorrect -> 0x8bf3)) DCCP-Request (service=-189888898) seq 8 <nop, nop, nop, nop, change_l ack_ratio 2, change_r ccid 2, change_l ccid 2>
+IP (tos 0x0, ttl 64, id 0, offset 0, flags [DF], proto DCCP (33), length 68)
+    139.133.209.65.5001 > 139.133.209.176.39420: DCCP (CCVal 0, CsCov 0, ) DCCP-Response (service=0) (ack=38464816766) seq 1960341146 <nop, nop, change_l ack_ratio 2, [|dccp]>
+IP (tos 0x0, ttl 64, id 65313, offset 0, flags [DF], proto DCCP (33), length 56)
+    139.133.209.176.39420 > 139.133.209.65.5001: DCCP (CCVal 0, CsCov 0, cksum 0xf53a (incorrect -> 0xf551)) DCCP-Ack (ack=1960341146) seq 38464816767 <nop, confirm_r ack_ratio 2, ack_vector0 0xe9, timestamp_echo [optlen != 6 or 8 or 10]>
+IP (tos 0x0, ttl 64, id 65314, offset 0, flags [DF], proto DCCP (33), length 152)
+    139.133.209.176.46076 > 139.133.209.65.48009: DCCP (CCVal 0, CsCov 6, ) DCCP-DataAck (ack=1960341146) seq 38464816768 <nop, nop, ack_vector0 0x00, elapsed_time 1249, ndp_count 1>
+IP (tos 0x0, ttl 64, id 3176, offset 0, flags [DF], proto DCCP (33), length 52)
+    139.133.209.65.5001 > 139.133.209.176.39420: DCCP (CCVal 0, CsCov 0, cksum 0xfc63 (correct)) DCCP-Ack (ack=38464816768) seq 1960341147 <nop, ack_vector0 0x01, elapsed_time 1>
+IP (tos 0x0, ttl 64, id 65315, offset 0, flags [DF], proto DCCP (33), length 148)
+    139.133.209.176.39420 > 139.133.209.65.5001: DCCP (CCVal 0, CsCov 6, ) DCCP-DataAck (ack=1960341147) seq 38464816769 <nop, ack_vector0 0x00, elapsed_time 84>
+IP (tos 0x0, ttl 64, id 3177, offset 0, flags [DF], proto DCCP (33), length 52)
+    139.133.209.65.5001 > 139.133.209.176.39420: DCCP (CCVal 0, CsCov 0, cksum 0x0165 (correct)) DCCP-Ack (ack=38464816769) seq 1960341148 <nop, nop, ack_vector0 0x00, ndp_count 1>
+00:07:00:42:00:00 > 00:14:22:59:55:51 Null Information, send seq 0, rcv seq 0, Flags [Command], length 148
+       0x0000:  0000 0000 1422 5955 5100 07e9 bd5d 1f08  ....."YUQ....]..
+       0x0010:  0045 0000 34ff 2040 0040 2181 8b8b 85d1  .E..4..@.@!.....
+       0x0020:  b08b 85d1 4199 fc13 8908 00aa f320 0000  ....A...........
+       0x0030:  08f4 ae86 7e00 0000                      ....~...
diff --git a/tests/dccp_options-oobr.pcap b/tests/dccp_options-oobr.pcap
new file mode 100644 (file)
index 0000000..65deded
Binary files /dev/null and b/tests/dccp_options-oobr.pcap differ
index ce12748..21fc1cc 100644 (file)
@@ -1 +1 @@
-IP 10.0.0.1.1024 > 146.84.28.88.53: 60777 Type49159 (Class 49168)? <BAD PTR>[|domain]
+IP 10.0.0.1.1024 > 146.84.28.88.53: domain [length 0 < 12] (invalid)
index dbabefb..21fc1cc 100644 (file)
@@ -1 +1 @@
-IP 10.0.0.1.1024 > 146.84.28.88.53: 18992 Type49164 (Class 49168)? <BAD PTR>[|domain]
+IP 10.0.0.1.1024 > 146.84.28.88.53: domain [length 0 < 12] (invalid)
index beb1730..21fc1cc 100644 (file)
@@ -1 +1 @@
-IP 10.0.0.1.1024 > 146.84.28.88.53: 65483 Type49164 (Class 49164)? thisleetostringwillcrashyourlittlenameserverforsurehahahahahah.<BAD PTR>[|domain]
+IP 10.0.0.1.1024 > 146.84.28.88.53: domain [length 0 < 12] (invalid)
diff --git a/tests/eapon2.out b/tests/eapon2.out
new file mode 100644 (file)
index 0000000..0b7e8d9
--- /dev/null
@@ -0,0 +1,61 @@
+ARP, Request who-has 192.168.1.1 tell 192.168.1.249, length 28
+ARP, Reply 192.168.1.1 is-at 00:0d:88:4f:25:91, length 46
+IP 192.168.1.249.68 > 192.168.1.1.67: BOOTP/DHCP, Request from 00:04:23:57:a5:7a, length 300
+EAP packet (0) v1, len 5
+IP 0.0.0.0.68 > 255.255.255.255.67: BOOTP/DHCP, Request from 00:04:23:57:a5:7a, length 300
+IP 0.0.0.0.68 > 255.255.255.255.67: BOOTP/DHCP, Request from 00:04:23:57:a5:7a, length 300
+EAPOL start (1) v1, len 0
+EAP packet (0) v1, len 5
+EAP packet (0) v1, len 45
+EAP packet (0) v1, len 20
+EAP packet (0) v1, len 76
+EAP packet (0) v1, len 80
+EAP packet (0) v1, len 28
+EAP packet (0) v1, len 4
+EAPOL key (3) v1, len 57
+EAPOL key (3) v1, len 44
+IP 0.0.0.0.68 > 255.255.255.255.67: BOOTP/DHCP, Request from 00:04:23:57:a5:7a, length 300
+IP 0.0.0.0.68 > 255.255.255.255.67: BOOTP/DHCP, Request from 00:04:23:57:a5:7a, length 300
+IP 0.0.0.0.68 > 255.255.255.255.67: BOOTP/DHCP, Request from 00:04:23:57:a5:7a, length 300
+EAPOL start (1) v1, len 0
+EAP packet (0) v1, len 5
+EAP packet (0) v1, len 45
+EAP packet (0) v1, len 20
+EAP packet (0) v1, len 76
+EAP packet (0) v1, len 80
+EAP packet (0) v1, len 28
+EAP packet (0) v1, len 4
+EAPOL key (3) v1, len 57
+EAPOL key (3) v1, len 44
+ARP, Request who-has 169.254.67.194 tell 169.254.67.194, length 28
+ARP, Request who-has 169.254.67.194 tell 169.254.67.194, length 28
+ARP, Request who-has 169.254.67.194 tell 169.254.67.194, length 28
+IP 169.254.67.194.4299 > 239.255.255.250.1900: UDP, length 133
+IP 169.254.67.194 > 224.0.0.22: igmp v3 report, 1 group record(s)
+IP 169.254.67.194 > 224.0.0.22: igmp v3 report, 1 group record(s)
+IP 0.0.0.0.68 > 255.255.255.255.67: BOOTP/DHCP, Request from 00:04:23:57:a5:7a, length 300
+IP 169.254.67.194.4299 > 239.255.255.250.1900: UDP, length 133
+EAPOL start (1) v1, len 0
+EAP packet (0) v1, len 5
+EAP packet (0) v1, len 45
+EAP packet (0) v1, len 20
+EAP packet (0) v1, len 76
+EAP packet (0) v1, len 80
+EAP packet (0) v1, len 28
+EAP packet (0) v1, len 4
+EAPOL key (3) v1, len 57
+EAPOL key (3) v1, len 44
+IP 0.0.0.0.68 > 255.255.255.255.67: BOOTP/DHCP, Request from 00:04:23:57:a5:7a, length 300
+IP 169.254.67.194.4299 > 239.255.255.250.1900: UDP, length 133
+IP 0.0.0.0.68 > 255.255.255.255.67: BOOTP/DHCP, Request from 00:04:23:57:a5:7a, length 300
+IP 0.0.0.0.68 > 255.255.255.255.67: BOOTP/DHCP, Request from 00:04:23:57:a5:7a, length 300
+EAPOL start (1) v1, len 0
+EAP packet (0) v1, len 5
+EAP packet (0) v1, len 45
+EAP packet (0) v1, len 20
+EAP packet (0) v1, len 76
+EAP packet (0) v1, len 80
+EAP packet (0) v1, len 28
+EAP packet (0) v1, len 4
+EAPOL key (3) v1, len 57
+EAPOL key (3) v1, len 44
diff --git a/tests/eapon2.pcap b/tests/eapon2.pcap
new file mode 100644 (file)
index 0000000..97719f2
Binary files /dev/null and b/tests/eapon2.pcap differ
diff --git a/tests/esp4.out b/tests/esp4.out
new file mode 100644 (file)
index 0000000..a829c8e
--- /dev/null
@@ -0,0 +1,8 @@
+IP 192.1.2.23 > 192.1.2.45: ESP(spi=0x12345678,seq=0x1), length 172: IP 192.1.2.23 > 192.0.1.1: ESP(spi=0xabcdabcd,seq=0x1), length 116: IP 192.0.2.1 > 192.0.1.1: ICMP echo request, id 28416, seq 1280, length 64 (ipip-proto-4) (ipip-proto-4)
+IP 192.1.2.23 > 192.1.2.45: ESP(spi=0x12345678,seq=0x2), length 172: IP 192.1.2.23 > 192.0.1.1: ESP(spi=0xabcdabcd,seq=0x2), length 116: IP 192.0.2.1 > 192.0.1.1: ICMP echo request, id 28416, seq 1536, length 64 (ipip-proto-4) (ipip-proto-4)
+IP 192.1.2.23 > 192.1.2.45: ESP(spi=0x12345678,seq=0x3), length 172: IP 192.1.2.23 > 192.0.1.1: ESP(spi=0xabcdabcd,seq=0x3), length 116: IP 192.0.2.1 > 192.0.1.1: ICMP echo request, id 28416, seq 1792, length 64 (ipip-proto-4) (ipip-proto-4)
+IP 192.1.2.23 > 192.1.2.45: ESP(spi=0x12345678,seq=0x4), length 172: IP 192.1.2.23 > 192.0.1.1: ESP(spi=0xabcdabcd,seq=0x4), length 116: IP 192.0.2.1 > 192.0.1.1: ICMP echo request, id 28416, seq 2048, length 64 (ipip-proto-4) (ipip-proto-4)
+IP 192.1.2.23 > 192.1.2.45: ESP(spi=0x12345678,seq=0x5), length 172: IP 192.1.2.23 > 192.0.1.1: ESP(spi=0xabcdabcd,seq=0x5), length 116: IP 192.0.2.1 > 192.0.1.1: ICMP echo request, id 28416, seq 2304, length 64 (ipip-proto-4) (ipip-proto-4)
+IP 192.1.2.23 > 192.1.2.45: ESP(spi=0x12345678,seq=0x6), length 172: IP 192.1.2.23 > 192.0.1.1: ESP(spi=0xabcdabcd,seq=0x6), length 116: IP 192.0.2.1 > 192.0.1.1: ICMP echo request, id 28416, seq 2560, length 64 (ipip-proto-4) (ipip-proto-4)
+IP 192.1.2.23 > 192.1.2.45: ESP(spi=0x12345678,seq=0x7), length 172: IP 192.1.2.23 > 192.0.1.1: ESP(spi=0xabcdabcd,seq=0x7), length 116: IP 192.0.2.1 > 192.0.1.1: ICMP echo request, id 28416, seq 2816, length 64 (ipip-proto-4) (ipip-proto-4)
+IP 192.1.2.23 > 192.1.2.45: ESP(spi=0x12345678,seq=0x8), length 172: IP 192.1.2.23 > 192.0.1.1: ESP(spi=0xabcdabcd,seq=0x8), length 116: IP 192.0.2.1 > 192.0.1.1: ICMP echo request, id 28416, seq 3072, length 64 (ipip-proto-4) (ipip-proto-4)
diff --git a/tests/frf16_magic_ie-oobr.out b/tests/frf16_magic_ie-oobr.out
new file mode 100644 (file)
index 0000000..dc12ee5
--- /dev/null
@@ -0,0 +1,2 @@
+FRF.16 Control, Flags [Begin, End, Control], Unknown Message (0x00), length 3714318497
+       IE Magic Number (3), length 3: (invalid length)[|mfr]
diff --git a/tests/frf16_magic_ie-oobr.pcap b/tests/frf16_magic_ie-oobr.pcap
new file mode 100644 (file)
index 0000000..85202fb
Binary files /dev/null and b/tests/frf16_magic_ie-oobr.pcap differ
diff --git a/tests/hncp_prefix-oobr.out b/tests/hncp_prefix-oobr.out
new file mode 100644 (file)
index 0000000..1908b89
--- /dev/null
@@ -0,0 +1,48 @@
+IP6 (class 0xc0, hlim 1, next-header UDP (17) payload length: 436) fe80::b299:28ff:ffc8:d646.6696 > ff02::59:0:0:1:6.6696: [bad udp cksum 0x2997 -> 0xbbd2!] babel 2 (424)
+       Hello seqno 58134 interval 4.00s sub-unknown-0x08 sub-pad1 sub-pad1 sub-unknown-0x04 sub-unknown-0x30 sub-diversity 2-2 (bogus) sub-diversity 2-2 (bogus) sub-diversity 2-48 (bogus) (invalid)
+       Unknown message type 48
+       Unknown message type 223
+       Pad 1
+       Unknown message type 51
+       Pad 1
+       Pad 1
+       Pad 1
+       HMAC  (invalid)
+IP6 (hlim 57, next-header UDP (17) payload length: 332) fe80::218:f3ff:ffa9:914e.8231 > fe80::21e:64ff:fe23:4d34.8231: [bad udp cksum 0xbd4b -> 0x0e98!] hncp (324)
+       Node endpoint (12) NID: 31:da:78:d2 EPID: 03000000
+       Node state (312) NID: 31:da:78:d2 seqno: 19 160.105s hash: 800088c8e0714638
+               Peer (16) Peer-NID: 61:69:ed:63 Peer-EPID: 01000000 Local-EPID: 01000000
+               HNCP-Version (22) M: 0 P: 4 H: 4 L: 4 User-agent: hnetd/cac971d
+               External-Connection (52)
+                       Reserved: type=0 (4)
+                       Reserved: type=0 (4)
+                       Reserved: type=0 (4)
+                       Reserved: type=0 (4)
+                       Reserved: type=0 (4)
+                       Reserved: type=0 (4)
+                       Reserved: type=0 (4)
+                       Reserved: type=0 (4)
+                       Reserved: type=0 (4)
+                       Reserved: type=0 (4)
+                       Reserved: type=0 (4)
+                       Unassigned: type=510 (4)
+               Assigned-Prefix (18) EPID: 03000000 Prty: 2 Prefix: fd1f:f88c:e200::/44
+                        (invalid)
+               Assigned-Prefix (25) EPID: 01000001 Prty: 0 Prefix: ::/0
+                       Reserved: type=0 (4)
+                       Reserved: type=0 (4)
+                       [|hncp]
+               Assigned-Prefix (25) EPID: 03000000 Prty: 2 Prefix: 10.0.101.0/24
+               Node-Address (24) EPID: 01000000 IP Address: ::2100:0:ffff:a00:6302
+               Node-Address (24) EPID: 01000000 IP Address: fd1f:f88c:e207::f3ff
+               [|hncp]
+IP6 (hlim 64, next-header UDP (17) payload length: 564) fe80::218:f3ff:fea9:914e.8231 > fe80::21e:64ff:fe23:4d34.8231: [bad udp cksum 0xe65a -> 0x7725!] hncp (556)
+       Node endpoint (12) NID: 31:10:00:00 EPID: 00000000
+       Node state (544) NID: 61:69:ed:63 seqno: 12 969.699s hash: 011fffa1da966148
+               Peer (16) Peer-NID: 31:da:78:d2 Peer-EPID: 01000000 Local-EPID: 01000000
+               Future use: type=64031 (22)
+               External-Connection (23)
+                       Delegated-Prefix (19) VLSO: 0.599s PLSO: 0.299s Prefix: fd1f:f88c:e207::/48
+               Assigned-Prefix (143) EPID: 8b8b8b8b Prty: 11 Prefix:   (invalid)
+               Private use: type=768 (4)
+               [|hncp]
diff --git a/tests/hncp_prefix-oobr.pcapng b/tests/hncp_prefix-oobr.pcapng
new file mode 100644 (file)
index 0000000..9c4c016
Binary files /dev/null and b/tests/hncp_prefix-oobr.pcapng differ
diff --git a/tests/icmp-icmp_print-oobr-1.out b/tests/icmp-icmp_print-oobr-1.out
new file mode 100644 (file)
index 0000000..20874b3
--- /dev/null
@@ -0,0 +1,7 @@
+IP (tos 0x4, ttl 64, id 3584, offset 0, flags [none], proto ICMP (1), length 23, bad cksum a (->1e0f)!)
+    22.3.2.0 > 54.209.0.0: ICMP type-#49, length 3[|icmp]
+IP (tos 0x4, ttl 64, id 32512, offset 0, flags [none], proto VRRP (112), length 31, bad cksum 82 (->db96)!)
+    22.3.211.0 > 54.209.0.0: vrrp 22.3.211.0 > 54.209.0.0: VRRPv3, Advertisement, (ttl 64), vrid 128, prio 69[|vrrp]
+c0:05:ff:ff:40:9d > 00:0c:02:49:96:7e, ethertype Unknown (0xf1ff), length 65570: 
+       0x0000:  4404 0020 0e00 0000 4070 000a 1603 0200  D.......@p......
+       0x0010:  36d1 0000 3180 bc                        6...1..
diff --git a/tests/icmp-icmp_print-oobr-1.pcap b/tests/icmp-icmp_print-oobr-1.pcap
new file mode 100644 (file)
index 0000000..86827df
Binary files /dev/null and b/tests/icmp-icmp_print-oobr-1.pcap differ
diff --git a/tests/icmp-icmp_print-oobr-2.out b/tests/icmp-icmp_print-oobr-2.out
new file mode 100644 (file)
index 0000000..70250da
--- /dev/null
@@ -0,0 +1,5 @@
+IP truncated-ip - 39 bytes missing! (tos 0x7f,CE, ttl 254, id 40208, offset 0, flags [none], proto VRRP (112), length 68, options (unknown 69 [bad length 83]), bad cksum 9b15 (->b774)!)
+    250.219.91.20 > 209.150.251.64: vrrp 250.219.91.20 > 209.150.251.64: VRRPv2, Advertisement, (ttl 254)[|vrrp]
+[|fr]
+IP (tos 0x7f,CE, ttl 254, id 40208, offset 0, flags [none], proto ICMP (1), length 30, options (unknown 201 [bad length 255]), bad cksum 101 (->6470)!)
+    1.241.1.250 > 219.91.15.170: ICMP type-#255, length 2[|icmp]
diff --git a/tests/icmp-icmp_print-oobr-2.pcap b/tests/icmp-icmp_print-oobr-2.pcap
new file mode 100644 (file)
index 0000000..515ac92
Binary files /dev/null and b/tests/icmp-icmp_print-oobr-2.pcap differ
index 0e0d97c..889b1c8 100644 (file)
@@ -1,2 +1,2 @@
-IP6 (class 0x50, flowlabel 0x0002c, hlim 0, next-header ICMPv6 (58) payload length: 7168) 4f:f829:c:1a1a:1a1a:1a1a:1a37:0 > 16:0:400:0:64fb:9303:f293:8200: ICMP6, mobile router advertisement, length 7168, id 0x9393[|icmp6]
+IP6 (class 0x50, flowlabel 0x0002c, hlim 0, next-header ICMPv6 (58) payload length: 7168) 4f:f829:c:1a1a:1a1a:1a1a:1a37:0 > 16:0:400:0:64fb:9303:f293:8200: ICMP6, mobile router advertisement, length 7168, id 0x9393 [|icmp6]
 [|ether]
index 0856ea2..19db749 100644 (file)
@@ -1 +1 @@
-IP6 a072:7f00:1:7f00:1:e01a:17:6785 > c903::a002:8018:fe30:0:204: ICMP6, who-are-you reply[|icmp6], length 4
+IP6 a072:7f00:1:7f00:1:e01a:17:6785 > c903::a002:8018:fe30:0:204: ICMP6, who-are-you reply [|icmp6], length 4
index bb7775e..66bdcc1 100644 (file)
@@ -1,5 +1,5 @@
 IP6 (hlim 255, next-header ICMPv6 (58) payload length: 176) fe80::b299:28ff:fec8:d66c > ff02::1: [icmp6 sum ok] ICMP6, router advertisement, length 176
-       hop limit 64, Flags [home agent], pref medium, router lifetime 15s, reachable time 0s, retrans time 0s
+       hop limit 64, Flags [home agent], pref medium, router lifetime 15s, reachable time 0ms, retrans timer 0ms
          prefix info option (3), length 32 (4): 2222:3333:4444:5555:6600::/72, Flags [onlink, auto], valid time 2592000s, pref. time 604800s
            0x0000:  48c0 0027 8d00 0009 3a80 0000 0000 2222
            0x0010:  3333 4444 5555 6600 0000 0000 0000
index 2b7cf09..edcffb1 100644 (file)
@@ -1,5 +1,5 @@
 IP6 (hlim 255, next-header ICMPv6 (58) payload length: 120) fe80::16cf:92ff:fe87:23d6 > ff02::1: [icmp6 sum ok] ICMP6, router advertisement, length 120
-       hop limit 0, Flags [managed, other stateful], pref medium, router lifetime 0s, reachable time 0s, retrans time 0s
+       hop limit 0, Flags [managed, other stateful], pref medium, router lifetime 0s, reachable time 0ms, retrans timer 0ms
          source link-address option (1), length 8 (1): 14:cf:92:87:23:d6
          mtu option (5), length 8 (1):  1500
          prefix info option (3), length 32 (4): fd8d:4fb3:5b2e::/64, Flags [onlink, auto], valid time 7200s, pref. time 1800s
@@ -7,7 +7,7 @@ IP6 (hlim 255, next-header ICMPv6 (58) payload length: 120) fe80::16cf:92ff:fe87
          rdnss option (25), length 24 (3):  lifetime 1800s, addr: fd8d:4fb3:5b2e::1
          dnssl option (31), length 16 (2):  lifetime 1800s, domain(s): lan.
 IP6 (hlim 255, next-header ICMPv6 (58) payload length: 120) fe80::16cf:92ff:fe87:23d6 > ff02::1: [icmp6 sum ok] ICMP6, router advertisement, length 120
-       hop limit 0, Flags [managed, other stateful], pref medium, router lifetime 0s, reachable time 0s, retrans time 0s
+       hop limit 0, Flags [managed, other stateful], pref medium, router lifetime 0s, reachable time 0ms, retrans timer 0ms
          source link-address option (1), length 8 (1): 14:cf:92:87:23:d6
          mtu option (5), length 8 (1):  1500
          prefix info option (3), length 32 (4): fd8d:4fb3:5b2e::/64, Flags [onlink, auto], valid time 7200s, pref. time 1800s
diff --git a/tests/ieee802.11_meshhdr-oobr.out b/tests/ieee802.11_meshhdr-oobr.out
new file mode 100644 (file)
index 0000000..6b3ab3f
--- /dev/null
@@ -0,0 +1 @@
+3472328296059908144us tsft 24.0 Mb/s 12334 MHz Turbo 48dBm noise [|802.11][|802.11]
diff --git a/tests/ieee802.11_meshhdr-oobr.pcap b/tests/ieee802.11_meshhdr-oobr.pcap
new file mode 100644 (file)
index 0000000..48445d7
Binary files /dev/null and b/tests/ieee802.11_meshhdr-oobr.pcap differ
diff --git a/tests/isakmp-ikev1_n_print-oobr.out b/tests/isakmp-ikev1_n_print-oobr.out
new file mode 100644 (file)
index 0000000..edbd190
--- /dev/null
@@ -0,0 +1,8 @@
+IP (tos 0x12,ECT(0), ttl 17, id 47119, offset 0, flags [+, DF, rsvd], proto UDP (17), length 296, bad cksum 1ff (->327b)!)
+    80.236.128.20.500 > 12.251.0.45.49152: isakmp 2.12 msgid 10101010: child_sa  ikev2_auth[V]:
+    (n: doi=0 proto=128 type=#24577) [|#126] (len mismatch: isakmp 4278190080/ip 268)
+IP (tos 0x12,ECT(0), ttl 17, id 21263, offset 72, flags [+, DF, rsvd], proto unknown (40), length 296, bad cksum fbff (->9847)!)
+    80.0.128.20 > 12.251.0.45: ip-proto-40
+IP (tos 0x15,ECT(1), ttl 17, id 21263, offset 0, flags [+, DF, rsvd], proto UDP (17), length 296, bad cksum 1ff (->9864)!)
+    80.0.128.20.500 > 12.251.0.45.49152: isakmp 2.12 msgid 1010100b: child_sa  ikev2_auth[V]:
+    (n: doi=ipsec proto=#16 type=REPLAY-STATUS spi=04 status=( [|n]) (len mismatch: isakmp 620756992/ip 268)
diff --git a/tests/isakmp-ikev1_n_print-oobr.pcap b/tests/isakmp-ikev1_n_print-oobr.pcap
new file mode 100644 (file)
index 0000000..026724b
Binary files /dev/null and b/tests/isakmp-ikev1_n_print-oobr.pcap differ
index d19b4a8..44b4894 100755 (executable)
@@ -7,20 +7,27 @@
 exitcode=0
 test_name=isis-seg-fault-1-v
 
-if [ ! -f ../Makefile ]
+srcdir=${1-..}
+: echo $0 using ${srcdir}
+
+testdir=${srcdir}/tests
+passedfile=tests/.passed
+failedfile=tests/.failed
+passed=`cat ${passedfile}`
+failed=`cat ${failedfile}`
+
+if [ ! -f Makefile ]
 then
        printf '    %-35s: TEST SKIPPED (no Makefile)\n' $test_name
-elif grep '^CC = .*gcc' ../Makefile >/dev/null
+elif grep '^CC = .*gcc' Makefile >/dev/null
 then
-       passed=`cat .passed`
-       failed=`cat .failed`
-       if ./TESTonce $test_name isis-seg-fault-1.pcap isis-seg-fault-1-v.out '-v'
+       if ${testdir}/TESTonce $test_name ${testdir}/isis-seg-fault-1.pcap ${testdir}/isis-seg-fault-1-v.out '-v'
        then
                passed=`expr $passed + 1`
-               echo $passed >.passed
+               echo $passed >${passedfile}
        else
                failed=`expr $failed + 1`
-               echo $failed >.failed
+               echo $failed >${failedfile}
                exitcode=1
        fi
 else
index ea88636..2b96647 100644 (file)
Binary files a/tests/juniper_header-heapoverflow.pcap and b/tests/juniper_header-heapoverflow.pcap differ
index 9cb884d..a1a28fc 100644 (file)
@@ -1,2 +1,3 @@
 IP6, wrong link-layer encapsulation 
-EXIT CODE 00000100
+
+EXIT CODE 00000100: dump:0 code: 1
diff --git a/tests/kday1.out.stderr b/tests/kday1.out.stderr
new file mode 100644 (file)
index 0000000..ab22332
--- /dev/null
@@ -0,0 +1,2 @@
+reading from file kday1.pcap, link-type EN10MB (Ethernet)
+tcpdump: pcap_loop: invalid packet capture length 138952731, bigger than snaplen of 65535
index ccbaae9..df791fe 100644 (file)
@@ -19,4 +19,5 @@ IP (tos 0x0, ttl 64, id 63178, offset 0, flags [DF], proto TCP (6), length 52, b
 IP (tos 0x0, ttl 64, id 36752, offset 0, flags [DF], proto TCP (6), length 399, bad cksum a46b (->a474)!)
     204.0.55.10.323 > 204.9.54.80.55936: Flags [P.], cksum 0xc9b6 (incorrect -> 0x8900), seq 3589495407:3589495754, ack 370428050, win 1040, options [nop,nop,TS val 2364757411 ecr 3084508609], length 347
        RPKI-RTRv177 (unknown)
-EXIT CODE 00000100
+
+EXIT CODE 00000100: dump:0 code: 1
diff --git a/tests/kday2.out.stderr b/tests/kday2.out.stderr
new file mode 100644 (file)
index 0000000..b4402a9
--- /dev/null
@@ -0,0 +1,2 @@
+reading from file kday2.pcap, link-type EN10MB (Ethernet)
+tcpdump: pcap_loop: truncated dump file; tried to read 16 header bytes, only got 3
index 4ae7a5c..386315d 100644 (file)
@@ -17,4 +17,5 @@ IP (tos 0x0, ttl 64, id 63178, offset 0, flags [DF], proto TCP (6), length 52, b
 IP (tos 0x0, ttl 64, id 36752, offset 0, flags [DF], proto TCP (6), length 399, bad cksum a46b (->a474)!)
     204.0.55.10.323 > 204.9.54.80.55936: Flags [P.], cksum 0xc9b6 (incorrect -> 0xa6b3), seq 0:347, ack 1, win 1040, options [nop,nop,TS val 2364757411 ecr 3084508609], length 347
        RPKI-RTRv177 (unknown)
-EXIT CODE 00000100
+
+EXIT CODE 00000100: dump:0 code: 1
diff --git a/tests/kday3.out.stderr b/tests/kday3.out.stderr
new file mode 100644 (file)
index 0000000..05115b0
--- /dev/null
@@ -0,0 +1,2 @@
+reading from file kday3.pcap, link-type EN10MB (Ethernet)
+tcpdump: pcap_loop: invalid packet capture length 1817495761, bigger than snaplen of 65535
index 5e2ab47..92146ff 100644 (file)
@@ -30,4 +30,5 @@ IP (tos 0x0, ttl 64, id 63178, offset 0, flags [DF], proto TCP (6), length 52, b
 IP (tos 0x0, ttl 64, id 36752, offset 0, flags [DF], proto TCP (6), length 399, bad cksum a46b (->a474)!)
     204.0.55.10.323 > 204.9.54.80.55936: Flags [P.], cksum 0xc9b6 (incorrect -> 0x3f28), seq 0:347, ack 4294959105, win 1040, options [nop,nop,TS val 2364757411 ecr 3084508609], length 347
        RPKI-RTRv177 (unknown)
-EXIT CODE 00000100
+
+EXIT CODE 00000100: dump:0 code: 1
diff --git a/tests/kday4.out.stderr b/tests/kday4.out.stderr
new file mode 100644 (file)
index 0000000..c470f9c
--- /dev/null
@@ -0,0 +1,2 @@
+reading from file kday4.pcap, link-type EN10MB (Ethernet)
+tcpdump: pcap_loop: truncated dump file; tried to read 16 header bytes, only got 1
index a529dd2..4caaca0 100644 (file)
@@ -19,4 +19,5 @@ IP (tos 0x0, ttl 64, id 63178, offset 0, flags [DF], proto TCP (6), length 52, b
 IP (tos 0x0, ttl 64, id 36752, offset 0, flags [DF], proto TCP (6), length 399, bad cksum a46b (->a474)!)
     204.0.55.10.323 > 204.9.54.80.55936: Flags [P.], cksum 0xc9b6 (incorrect -> 0x183a), seq 3589495407:3589495754, ack 370428050, win 1040, options [nop,nop,TS val 2351322531 ecr 3084508609], length 347
        RPKI-RTRv177 (unknown)
-EXIT CODE 00000100
+
+EXIT CODE 00000100: dump:0 code: 1
diff --git a/tests/kday5.out.stderr b/tests/kday5.out.stderr
new file mode 100644 (file)
index 0000000..72c4c15
--- /dev/null
@@ -0,0 +1,2 @@
+reading from file kday5.pcap, link-type EN10MB (Ethernet)
+tcpdump: pcap_loop: invalid packet capture length 168430090, bigger than snaplen of 65535
index 0c11b5d..25210db 100644 (file)
@@ -347,4 +347,5 @@ FRF.16 Frag, seq 693, Flags [Begin], UI e8! IS-IS, length 301989913
            unknown TLV #58, length: 58
                0x0000:  3a3a 3a3a 3a3a 3a3a 3a3a 3a3a 3a3a 3a3a
                0x0010:  3a3a 3a [|isis]
-EXIT CODE 00000100
+
+EXIT CODE 00000100: dump:0 code: 1
diff --git a/tests/kday6.out.stderr b/tests/kday6.out.stderr
new file mode 100644 (file)
index 0000000..be6a293
--- /dev/null
@@ -0,0 +1,2 @@
+reading from file kday6.pcap, link-type MFR (FRF.16 Frame Relay)
+tcpdump: pcap_loop: invalid packet capture length 976894522, bigger than snaplen of 65535
index 569cde6..c7701b9 100644 (file)
@@ -30,4 +30,5 @@ IP (tos 0x0, ttl 64, id 63178, offset 0, flags [DF], proto TCP (6), length 52, b
 IP (tos 0x0, ttl 64, id 36752, offset 0, flags [DF], proto TCP (6), length 399, bad cksum a46b (->a474)!)
     204.0.55.10.323 > 204.9.54.80.55936: Flags [P.], cksum 0xc9b6 (incorrect -> 0x4ba9), seq 0:347, ack 4294959105, win 1040, options [nop,nop,TS val 2364757411 ecr 3084508609], length 347
        RPKI-RTRv177 (unknown)
-EXIT CODE 00000100
+
+EXIT CODE 00000100: dump:0 code: 1
diff --git a/tests/kday7.out.stderr b/tests/kday7.out.stderr
new file mode 100644 (file)
index 0000000..8ca6a7a
--- /dev/null
@@ -0,0 +1,2 @@
+reading from file kday7.pcap, link-type EN10MB (Ethernet)
+tcpdump: pcap_loop: invalid packet capture length 138948798, bigger than snaplen of 511
index 2e4060b..8ae0fd2 100644 (file)
@@ -19,4 +19,5 @@ IP (tos 0x0, ttl 64, id 63178, offset 0, flags [DF], proto TCP (6), length 52, b
 IP (tos 0x0, ttl 64, id 36752, offset 0, flags [DF], proto TCP (6), length 399, bad cksum a46b (->a474)!)
     204.0.55.10.323 > 204.9.54.80.55936: Flags [P.], cksum 0xc9b6 (incorrect -> 0xed9b), seq 3589495407:3589495754, ack 370428050, win 1040, options [nop,nop,TS val 2364757411 ecr 3084508609], length 347
        RPKI-RTRv177 (unknown)
-EXIT CODE 00000100
+
+EXIT CODE 00000100: dump:0 code: 1
diff --git a/tests/kday8.out.stderr b/tests/kday8.out.stderr
new file mode 100644 (file)
index 0000000..437e840
--- /dev/null
@@ -0,0 +1,2 @@
+reading from file kday8.pcap, link-type EN10MB (Ethernet)
+tcpdump: pcap_loop: truncated dump file; tried to read 16 header bytes, only got 3
diff --git a/tests/kh-addrfail-001.out b/tests/kh-addrfail-001.out
new file mode 100644 (file)
index 0000000..562d0bc
--- /dev/null
@@ -0,0 +1,2 @@
+
+EXIT CODE 00000100: dump:0 code: 1
diff --git a/tests/kh-addrfail-001.out.stderr b/tests/kh-addrfail-001.out.stderr
new file mode 100644 (file)
index 0000000..f179cba
--- /dev/null
@@ -0,0 +1 @@
+tcpdump: Section Header Block in pcapng dump file has invalid length 28 < _3929026608_ < 1048576 (BT_SHB_INSANE_MAX)
diff --git a/tests/kh-addrfail-001.pcap b/tests/kh-addrfail-001.pcap
new file mode 100644 (file)
index 0000000..16374f0
--- /dev/null
@@ -0,0 +1,3 @@
+
+\r\r
+000êM<+\1a
\ No newline at end of file
diff --git a/tests/kh-addrfail-002.out b/tests/kh-addrfail-002.out
new file mode 100644 (file)
index 0000000..562d0bc
--- /dev/null
@@ -0,0 +1,2 @@
+
+EXIT CODE 00000100: dump:0 code: 1
diff --git a/tests/kh-addrfail-002.out.stderr b/tests/kh-addrfail-002.out.stderr
new file mode 100644 (file)
index 0000000..7930c58
--- /dev/null
@@ -0,0 +1 @@
+tcpdump: Section Header Block in pcapng dump file has invalid length 28 < _4281348144_ < 1048576 (BT_SHB_INSANE_MAX)
diff --git a/tests/kh-addrfail-002.pcap b/tests/kh-addrfail-002.pcap
new file mode 100644 (file)
index 0000000..e7833c8
--- /dev/null
@@ -0,0 +1,3 @@
+
+\r\r
+000ÿM<+\1a
\ No newline at end of file
diff --git a/tests/kh-addrfail-003.out b/tests/kh-addrfail-003.out
new file mode 100644 (file)
index 0000000..562d0bc
--- /dev/null
@@ -0,0 +1,2 @@
+
+EXIT CODE 00000100: dump:0 code: 1
diff --git a/tests/kh-addrfail-003.out.stderr b/tests/kh-addrfail-003.out.stderr
new file mode 100644 (file)
index 0000000..111a886
--- /dev/null
@@ -0,0 +1 @@
+tcpdump: Section Header Block in pcapng dump file has invalid length 28 < _3794808880_ < 1048576 (BT_SHB_INSANE_MAX)
diff --git a/tests/kh-addrfail-003.pcap b/tests/kh-addrfail-003.pcap
new file mode 100644 (file)
index 0000000..caed214
--- /dev/null
@@ -0,0 +1,3 @@
+
+\r\r
+000âM<+\1a
\ No newline at end of file
diff --git a/tests/kh-addrfail-004.out b/tests/kh-addrfail-004.out
new file mode 100644 (file)
index 0000000..562d0bc
--- /dev/null
@@ -0,0 +1,2 @@
+
+EXIT CODE 00000100: dump:0 code: 1
diff --git a/tests/kh-addrfail-004.out.stderr b/tests/kh-addrfail-004.out.stderr
new file mode 100644 (file)
index 0000000..dd39511
--- /dev/null
@@ -0,0 +1 @@
+tcpdump: Section Header Block in pcapng dump file has invalid length 28 < _2150641712_ < 1048576 (BT_SHB_INSANE_MAX)
diff --git a/tests/kh-addrfail-004.pcap b/tests/kh-addrfail-004.pcap
new file mode 100644 (file)
index 0000000..83bf4a4
--- /dev/null
@@ -0,0 +1,3 @@
+
+\r\r
+000\80M<+\1a
\ No newline at end of file
diff --git a/tests/kh-addrfail-005.out b/tests/kh-addrfail-005.out
new file mode 100644 (file)
index 0000000..562d0bc
--- /dev/null
@@ -0,0 +1,2 @@
+
+EXIT CODE 00000100: dump:0 code: 1
diff --git a/tests/kh-addrfail-005.out.stderr b/tests/kh-addrfail-005.out.stderr
new file mode 100644 (file)
index 0000000..b6ef8d5
--- /dev/null
@@ -0,0 +1 @@
+tcpdump: Section Header Block in pcapng dump file has invalid length 28 < _1680879664_ < 1048576 (BT_SHB_INSANE_MAX)
diff --git a/tests/kh-addrfail-005.pcap b/tests/kh-addrfail-005.pcap
new file mode 100644 (file)
index 0000000..4e74f42
--- /dev/null
@@ -0,0 +1,3 @@
+
+\r\r
+000dM<+\1a
\ No newline at end of file
diff --git a/tests/kh-addrfail-006.out b/tests/kh-addrfail-006.out
new file mode 100644 (file)
index 0000000..562d0bc
--- /dev/null
@@ -0,0 +1,2 @@
+
+EXIT CODE 00000100: dump:0 code: 1
diff --git a/tests/kh-addrfail-006.out.stderr b/tests/kh-addrfail-006.out.stderr
new file mode 100644 (file)
index 0000000..0428558
--- /dev/null
@@ -0,0 +1 @@
+tcpdump: Section Header Block in pcapng dump file has invalid length 28 < _2905616432_ < 1048576 (BT_SHB_INSANE_MAX)
diff --git a/tests/kh-addrfail-006.pcap b/tests/kh-addrfail-006.pcap
new file mode 100644 (file)
index 0000000..f50fc44
--- /dev/null
@@ -0,0 +1,3 @@
+
+\r\r
+000­M<+\1a
\ No newline at end of file
diff --git a/tests/kh-addrfail-007.out b/tests/kh-addrfail-007.out
new file mode 100644 (file)
index 0000000..562d0bc
--- /dev/null
@@ -0,0 +1,2 @@
+
+EXIT CODE 00000100: dump:0 code: 1
diff --git a/tests/kh-addrfail-007.out.stderr b/tests/kh-addrfail-007.out.stderr
new file mode 100644 (file)
index 0000000..f37515c
--- /dev/null
@@ -0,0 +1 @@
+tcpdump: Section Header Block in pcapng dump file has invalid length 28 < _3710922800_ < 1048576 (BT_SHB_INSANE_MAX)
diff --git a/tests/kh-addrfail-007.pcap b/tests/kh-addrfail-007.pcap
new file mode 100644 (file)
index 0000000..59a0eb0
--- /dev/null
@@ -0,0 +1,3 @@
+
+\r\r
+000ÝM<+\1a
\ No newline at end of file
diff --git a/tests/kh-addrfail-008.out b/tests/kh-addrfail-008.out
new file mode 100644 (file)
index 0000000..562d0bc
--- /dev/null
@@ -0,0 +1,2 @@
+
+EXIT CODE 00000100: dump:0 code: 1
diff --git a/tests/kh-addrfail-008.out.stderr b/tests/kh-addrfail-008.out.stderr
new file mode 100644 (file)
index 0000000..6ac5142
--- /dev/null
@@ -0,0 +1 @@
+tcpdump: Section Header Block in pcapng dump file has invalid length 28 < _808464432_ < 1048576 (BT_SHB_INSANE_MAX)
diff --git a/tests/kh-addrfail-008.pcap b/tests/kh-addrfail-008.pcap
new file mode 100644 (file)
index 0000000..a90f581
--- /dev/null
@@ -0,0 +1,3 @@
+
+\r\r
+0000M<+\1a
\ No newline at end of file
diff --git a/tests/kh-addrfail-009.out b/tests/kh-addrfail-009.out
new file mode 100644 (file)
index 0000000..562d0bc
--- /dev/null
@@ -0,0 +1,2 @@
+
+EXIT CODE 00000100: dump:0 code: 1
diff --git a/tests/kh-addrfail-009.out.stderr b/tests/kh-addrfail-009.out.stderr
new file mode 100644 (file)
index 0000000..3582875
--- /dev/null
@@ -0,0 +1 @@
+tcpdump: Section Header Block in pcapng dump file has invalid length 28 < _1932537904_ < 1048576 (BT_SHB_INSANE_MAX)
diff --git a/tests/kh-addrfail-009.pcap b/tests/kh-addrfail-009.pcap
new file mode 100644 (file)
index 0000000..a6e68ea
--- /dev/null
@@ -0,0 +1,3 @@
+
+\r\r
+000sM<+\1a
\ No newline at end of file
diff --git a/tests/kh-addrfail-010.out b/tests/kh-addrfail-010.out
new file mode 100644 (file)
index 0000000..562d0bc
--- /dev/null
@@ -0,0 +1,2 @@
+
+EXIT CODE 00000100: dump:0 code: 1
diff --git a/tests/kh-addrfail-010.out.stderr b/tests/kh-addrfail-010.out.stderr
new file mode 100644 (file)
index 0000000..a5099b0
--- /dev/null
@@ -0,0 +1 @@
+tcpdump: Section Header Block in pcapng dump file has invalid length 28 < _1915760688_ < 1048576 (BT_SHB_INSANE_MAX)
diff --git a/tests/kh-addrfail-010.pcap b/tests/kh-addrfail-010.pcap
new file mode 100644 (file)
index 0000000..0973d7a
--- /dev/null
@@ -0,0 +1,3 @@
+
+\r\r
+000rM<+\1a
\ No newline at end of file
diff --git a/tests/kh-addrfail-011.out b/tests/kh-addrfail-011.out
new file mode 100644 (file)
index 0000000..562d0bc
--- /dev/null
@@ -0,0 +1,2 @@
+
+EXIT CODE 00000100: dump:0 code: 1
diff --git a/tests/kh-addrfail-011.out.stderr b/tests/kh-addrfail-011.out.stderr
new file mode 100644 (file)
index 0000000..f292c90
--- /dev/null
@@ -0,0 +1 @@
+tcpdump: Section Header Block in pcapng dump file has invalid length 28 < _4046467120_ < 1048576 (BT_SHB_INSANE_MAX)
diff --git a/tests/kh-addrfail-011.pcap b/tests/kh-addrfail-011.pcap
new file mode 100644 (file)
index 0000000..1a421fb
--- /dev/null
@@ -0,0 +1,3 @@
+
+\r\r
+000ñM<+\1a
\ No newline at end of file
diff --git a/tests/kh-tcpdump-001.out b/tests/kh-tcpdump-001.out
new file mode 100644 (file)
index 0000000..e68f867
--- /dev/null
@@ -0,0 +1,17 @@
+30:30:30:30:30:30 > 30:30:30:30:30:30, ethertype Unknown (0x3030), length 808464432: 
+       0x0000:  3030 3030 3030 3030 3030 3030 3030 3030  0000000000000000
+       0x0010:  3030 3030 3030 3030 3030 3030 3030 3030  0000000000000000
+       0x0020:  3030                                     00
+30:30:30:30:30:30 > 30:30:30:30:30:30, ethertype Unknown (0x3030), length 808464432: 
+       0x0000:  3030 3030 3030 3030 3030 3030 3030 3030  0000000000000000
+       0x0010:  3030 3030 3030 3030 3030 3030 3030 3030  0000000000000000
+       0x0020:  3030                                     00
+30:30:30:30:30:30 > 30:30:30:30:30:30, ethertype Unknown (0x3030), length 808464432: 
+       0x0000:  3030 3030 3030 3030 3030 3030 3030 3030  0000000000000000
+       0x0010:  3030 3030 3030 3030 3030 3030 3030 3030  0000000000000000
+       0x0020:  3030                                     00
+30:30:30:30:30:30 > 30:30:30:30:30:30, ethertype Unknown (0x3030), length 808464432: 
+       0x0000:  3030 3030 3030 3030 3030 3030 3030 3030  0000000000000000
+       0x0010:  3030 3030 3030 3030 3030 3030 3030 3030  0000000000000000
+       0x0020:  3030                                     00
+IP truncated-ip - 14 bytes missing! 48.48.48.48.525 > 48.48.48.48.12336: (tsp_type 0x30) vers 48 seq 12336 [|timed]
diff --git a/tests/kh-tcpdump-001.pcap b/tests/kh-tcpdump-001.pcap
new file mode 100644 (file)
index 0000000..118c7eb
Binary files /dev/null and b/tests/kh-tcpdump-001.pcap differ
diff --git a/tests/kh-tcpdump-002.out b/tests/kh-tcpdump-002.out
new file mode 100644 (file)
index 0000000..d4d7d51
--- /dev/null
@@ -0,0 +1 @@
+IP 48.48.48.48.525 > 48.48.48.48.12336: (tsp_type 0x30) vers 48 seq 12336 [|timed]
diff --git a/tests/kh-tcpdump-002.pcap b/tests/kh-tcpdump-002.pcap
new file mode 100644 (file)
index 0000000..f38f0ec
Binary files /dev/null and b/tests/kh-tcpdump-002.pcap differ
diff --git a/tests/kh-tcpdump-004.pcap b/tests/kh-tcpdump-004.pcap
new file mode 100644 (file)
index 0000000..d5f5aa3
Binary files /dev/null and b/tests/kh-tcpdump-004.pcap differ
index a3b1db2..5b80d98 100644 (file)
@@ -36,4 +36,5 @@ IP (tos 0x30, ttl 48, id 12331, offset 0, flags [none], proto UDP (17), length 8
     127.0.0.229.12416 > 127.236.0.1.1701:  l2tp:[TL](560/2056) VENDOR0001:ATTR0023(0530) |...
 IP (tos 0x30, ttl 48, id 12336, offset 0, flags [none], proto UDP (17), length 12336, bad cksum 1f51 (->2a8b)!)
     127.0.0.229.12416 > 127.236.0.1.1701:  l2tp:[TL](560/2056) VENDOR0080:ATTR06a5(19e8) |...
-EXIT CODE 00000100
+
+EXIT CODE 00000100: dump:0 code: 1
diff --git a/tests/l2tp-avp-overflow.out.stderr b/tests/l2tp-avp-overflow.out.stderr
new file mode 100644 (file)
index 0000000..4c7db91
--- /dev/null
@@ -0,0 +1,2 @@
+reading from file l2tp-avp-overflow.pcap, link-type EN10MB (Ethernet)
+tcpdump: pcap_loop: invalid packet capture length 2147430448, bigger than snaplen of 58
diff --git a/tests/ldp-ldp_tlv_print-oobr.out b/tests/ldp-ldp_tlv_print-oobr.out
new file mode 100644 (file)
index 0000000..e5f6117
--- /dev/null
@@ -0,0 +1,6 @@
+IP (tos 0x0, id 4608, offset 0, flags [+, DF, rsvd], proto UDP (17), length 25600, options (EOL), bad cksum 8e (->4023)!)
+    24.250.219.0.4098 > 0.0.0.0.646: 
+       LDP, Label-Space-ID: 0.0.127.255:796, pdu-length: 514
+         Address Withdraw Message (0x0301), length: 22, Message ID: 0x00001600, Flags: [ignore if unknown]
+           Unknown TLV (0x0404), length: 0, Flags: [ignore and don't forward if unknown]
+           Fault-Tolerant Session Parameters TLV (0x0503), length: 8, Flags: [ignore and don't forward if unknown] [|LDP] [|LDP]
diff --git a/tests/ldp-ldp_tlv_print-oobr.pcap b/tests/ldp-ldp_tlv_print-oobr.pcap
new file mode 100644 (file)
index 0000000..29fb84a
Binary files /dev/null and b/tests/ldp-ldp_tlv_print-oobr.pcap differ
diff --git a/tests/lmp-lmp_print_data_link_subobjs-oobr.out b/tests/lmp-lmp_print_data_link_subobjs-oobr.out
new file mode 100644 (file)
index 0000000..b655b07
--- /dev/null
@@ -0,0 +1,20 @@
+IP (tos 0xfd,ECT(1), ttl 254, id 45839, offset 0, flags [+, DF, rsvd], proto UDP (17), length 56871, bad cksum fe07 (->ddf0)!)
+    17.8.8.255.701 > 40.184.42.8.12: 
+       LMPv1, msg-type: unknown, type: 249, Flags: [none], length: 212
+         Data Link Object (12), Class-Type: Unnumbered (3) Flags: [non-negotiable], length: 20
+           Flags: [none]
+           Local Interface ID: 2435832538 (0x912fdada)
+           Remote Interface ID: 3657433088 (0xda000000)
+           Subobject, Type: Interface Switching Type (1), Length: 4
+             Switching Type: Unknown (0)
+             Encoding Type: Unknown (0) [|LMP]
+IP (tos 0xfd,ECT(1), ttl 254, id 45839, offset 0, flags [+, DF, rsvd], proto UDP (17), length 56871, bad cksum fe07 (->ddf0)!)
+    17.8.8.255.701 > 40.184.42.8.12: 
+       LMPv1, msg-type: unknown, type: 249, Flags: [none], length: 212
+         Data Link Object (12), Class-Type: Unnumbered (3) Flags: [non-negotiable], length: 20
+           Flags: [none]
+           Local Interface ID: 2435832538 (0x912fdada)
+           Remote Interface ID: 3657433088 (0xda000000)
+           Subobject, Type: Interface Switching Type (1), Length: 4
+             Switching Type: Unknown (0)
+             Encoding Type: Unknown (0) [|LMP]
diff --git a/tests/lmp-lmp_print_data_link_subobjs-oobr.pcap b/tests/lmp-lmp_print_data_link_subobjs-oobr.pcap
new file mode 100644 (file)
index 0000000..d1a6ad9
Binary files /dev/null and b/tests/lmp-lmp_print_data_link_subobjs-oobr.pcap differ
index a8c6740..e5a49a2 100755 (executable)
@@ -7,23 +7,31 @@
 # the architecture.
 
 exitcode=0
+srcdir=${1-..}
+: echo $0 using ${srcdir}
+
+testdir=${srcdir}/tests
+passedfile=tests/.passed
+failedfile=tests/.failed
+passed=`cat ${passedfile}`
+failed=`cat ${failedfile}`
 
 # A Windows build may have no file named Makefile and also a version of grep
 # that won't return an error when the file does not exist. Work around.
-if [ ! -f ../Makefile ]
+if [ ! -f Makefile ]
 then
        printf '    %-35s: TEST SKIPPED (no Makefile)\n' 'lmp-v'
-elif grep '^CC = .*gcc' ../Makefile >/dev/null
+elif grep '^CC = .*gcc' Makefile >/dev/null
 then
-       passed=`cat .passed`
-       failed=`cat .failed`
-       if ./TESTonce lmp-v lmp.pcap lmp-v.out '-T lmp -v'
+    passed=`cat ${passedfile}`
+    failed=`cat ${failedfile}`
+       if ${testdir}/TESTonce lmp-v ${testdir}/lmp.pcap ${testdir}/lmp-v.out '-T lmp -v'
        then
                passed=`expr $passed + 1`
-               echo $passed >.passed
+               echo $passed >${passedfile}
        else
                failed=`expr $failed + 1`
-               echo $failed >.failed
+               echo $failed >${failedfile}
                exitcode=1
        fi
 else
index b85b0e8..f6b88ed 100644 (file)
@@ -38,5 +38,4 @@
            0x01d0:  0200 0200 0002 0002 0000 0200 0200 0002
            0x01e0:  0002 0000 0200 0200 0002 0002 0000 0200
            0x01f0:  0200 0002 0002 0000 0200 0200 0002 0002
-         Unknown Object (0), Class-Type: Unknown (0) Flags: [non-negotiable], length: 512
-                packet exceeded snapshot
+         Unknown Object (0), Class-Type: Unknown (0) Flags: [non-negotiable], length: 512 [|LMP]
index 5b5b66c..89dcc40 100755 (executable)
@@ -1,20 +1,26 @@
 #!/bin/sh
 
 exitcode=0
+srcdir=${1-..}
+: echo $0 using ${srcdir}
+
+testdir=${srcdir}/tests
+passedfile=tests/.passed
+failedfile=tests/.failed
+passed=`cat ${passedfile}`
+failed=`cat ${failedfile}`
 
 # NFLOG support depends on both DLT_NFLOG and working <pcap/nflog.h>
 
-if grep '^#define HAVE_PCAP_NFLOG_H 1$' ../config.h >/dev/null
+if grep '^#define HAVE_PCAP_NFLOG_H 1$' config.h >/dev/null
 then
-       passed=`cat .passed`
-       failed=`cat .failed`
-       if ./TESTonce nflog-e nflog.pcap nflog-e.out '-e'
+       if ${testdir}/TESTonce nflog-e ${testdir}/nflog.pcap ${testdir}/nflog-e.out '-e'
        then
                passed=`expr $passed + 1`
-               echo $passed >.passed
+               echo $passed >${passedfile}
        else
                failed=`expr $failed + 1`
-               echo $failed >.failed
+               echo $failed >${failedfile}
                exitcode=1
        fi
 else
diff --git a/tests/of10_7050sx_bsn-oobr.out b/tests/of10_7050sx_bsn-oobr.out
new file mode 100644 (file)
index 0000000..f39e275
--- /dev/null
@@ -0,0 +1,16 @@
+IP (tos 0x0, ttl 64, id 60713, offset 0, flags [DF], proto TCP (6), length 562)
+    109.74.202.168.6653 > 88.150.169.52.4756: Flags [P.], seq 3422281781:3422282291, ack 774258090, win 252, options [nop,nop,TS val 590230876 ecr 50526785], length 510: OpenFlow
+       version 1.0, type VENDOR, length 24, xid 0x0000001a, vendor 0x005c16c7 (Big Switch Networks)
+        subtype SET_IP_MASK, index 1, mask 255.0.14.0
+       version 1.0, type VENDOR, length 24, xid 0x0000001b, vendor 0x005c16c7 (Big Switch Networks)
+        subtype SET_IP_MASK, index 2, mask 255.0.28.0
+       version 1.0, type VENDOR, length 24, xid 0x0000001c, vendor 0x005c16c7 (Big Switch Networks)
+        subtype SET_IP_MASK, index 3, mask 255.0.56.0
+       version 1.0, type VENDOR, length 24, xid 0x0000001d, vendor 0x005c16c7 (Big Switch Networks)
+        subtype SET_IP_MASK, index 4, mask 255.0.112.0
+       version 1.0, type VENDOR, length 24, xid 0x0000001e, vendor 0x005c16c7 (Big Switch Networks)
+        subtype SET_IP_MASK, index 5, mask 255.0.224.0
+       version 1.0, type VENDOR, length 24, xid 0x0000001f, vendor 0x005c16c7 (Big Switch Networks)
+        subtype GET_IP_MASK_REQUEST, index 3
+       version 1.0, type VENDOR, length 30, xid 0x00000020, vendor 0x005c16c7 (Big Switch Networks)
+        subtype SHELL_COMMAND, service 0, data 'show cloc' [|openflow]
diff --git a/tests/of10_7050sx_bsn-oobr.pcap b/tests/of10_7050sx_bsn-oobr.pcap
new file mode 100644 (file)
index 0000000..a564248
Binary files /dev/null and b/tests/of10_7050sx_bsn-oobr.pcap differ
diff --git a/tests/ospf6_print_lshdr-oobr.out b/tests/ospf6_print_lshdr-oobr.out
new file mode 100644 (file)
index 0000000..71adf6b
--- /dev/null
@@ -0,0 +1,59 @@
+IP6 (class 0xe0, hlim 1, next-header OSPF (89) payload length: 36) fe80::1 > ff02::5: OSPFv3, Hello, length 36
+       Router-ID 1.1.1.1, Area 0.0.0.1
+       Options [V6, External, Router]
+         Hello Timer 10s, Dead Timer 40s, Interface-ID 0.0.0.5, Priority 1
+         Neighbor List:
+IP6 (class 0xe0, hlim 1, next-header OSPF (89) payload length: 36) fe80::1 > ff02::5: OSPFv3, Hello, length 36
+       Router-ID 1.1.1.1, Area 0.0.0.1
+       Options [V6, External, Router]
+         Hello Timer 10s, Dead Timer 40s, Interface-ID 0.0.0.5, Priority 1
+         Neighbor List:
+IP6 (class 0xe0, hlim 1, next-header OSPF (89) payload length: 36) fe80::1 > ff02::5: OSPFv3, Hello, length 36
+       Router-ID 1.1.1.1, Area 0.0.0.1
+       Options [V6, External, Router]
+         Hello Timer 10s, Dead Timer 40s, Interface-ID 0.0.0.5, Priority 1
+         Neighbor List:
+IP6 (class 0xe0, hlim 1, next-header OSPF (89) payload length: 36) fe80::1 > ff02::5: OSPFv3, Hello, length 36
+       Router-ID 1.1.1.1, Area 0.0.0.1
+       Options [V6, External, Router]
+         Hello Timer 10s, Dead Timer 40s, Interface-ID 0.0.0.5, Priority 1
+         Neighbor List:
+IP6 (class 0xe0, hlim 1, next-header OSPF (89) payload length: 36) fe80::2 > ff02::5: OSPFv3, Hello, length 36
+       Router-ID 2.2.2.2, Area 0.0.0.1
+       Options [V6, External, Router]
+         Hello Timer 10s, Dead Timer 40s, Interface-ID 0.0.0.5, Priority 1
+         Neighbor List:
+IP6 (class 0xe0, hlim 1, next-header OSPF (89) payload length: 40) fe80::1 > ff02::5: OSPFv3, Hello, length 40
+       Router-ID 1.1.1.1, Area 0.0.0.1
+       Options [V6, External, Router]
+         Hello Timer 10s, Dead Timer 40s, Interface-ID 0.0.0.5, Priority 1
+         Designated Router 1.1.1.1
+         Neighbor List: [|ospf3]
+IP6 (class 0xe0, flowlabel 0x00100, hlim 1, next-header OSPF (89) payload length: 28) fe80::2 > fe80::1: OSPFv3, Database Description, length 28
+       Router-ID 2.2.2.2, Area 0.0.0.1
+       Options [V6, External, Router], DD Flags [Init, More, Master], MTU 1500, DD-Sequence 0x00001d46
+IP6 (class 0xe0, hlim 1, next-header OSPF (89) payload length: 28) fe80::1 > fe80::2: OSPFv3, Database Description, length 28
+       Router-ID 1.1.1.1, Area 0.0.0.1
+       Options [V6, External, Router], DD Flags [Init, More, Master], MTU 1500, DD-Sequence 0x0000242c
+IP6 (class 0xe0, hlim 1, next-header OSPF (89) payload length: 168) fe80::1 > fe80::2: OSPFv3, Database Description, length 168
+       Router-ID 1.1.1.1, Area 0.0.0.1
+       Options [V6, External, Router], DD Flags [More], MTU 1500, DD-Sequence 0x00001d46 [|ospf3]
+IP6 (class 0xe0, hlim 1, next-header OSPF (89) payload length: 148) fe80::2 > fe80::1: OSPFv3, Database Description, length 148
+       Router-ID 2.2.2.2, Area 0.0.0.1
+       Options [V6, External, Router], DD Flags [More, Master], MTU 1500, DD-Sequence 0x00001d47 [|ospf3]
+IP6 (class 0xe0, hlim 1, next-header OSPF (89) payload length: 28) fe80::1 > fe80::2: OSPFv3, Database Description, length 28
+       Router-ID 1.1.1.1, Area 0.0.0.1
+       Options [V6, External, Router], DD Flags [none], MTU 1500, DD-Sequence 0x00001d47
+IP6 (class 0xe0, hlim 1, next-header OSPF (89) payload length: 100) fe80::2 > fe80::1: OSPFv3, LS-Request, length 100
+       Router-ID 2.2.2.2, Area 0.0.0.1
+         Advertising Router 1.1.1.1
+           Router LSA (1), Area Local Scope, LSA-ID 0.0.0.0 [|ospf3]
+IP6 (class 0xe0, hlim 1, next-header OSPF (89) payload length: 88) fe80::1 > fe80::2: OSPFv3, LS-Request, length 88
+       Router-ID 1.1.1.1, Area 0.0.0.1
+         Advertising Router 2.2.2.2
+           Router LSA (1), Area Local Scope, LSA-ID 0.0.0.0 [|ospf3]
+IP6 (class 0xe0, hlim 1, next-header OSPF (89) payload length: 28) fe80::2 > fe80::1: OSPFv3, Database Description, length 28
+       Router-ID 2.2.2.2, Area 0.0.0.1
+       Options [V6, External, Router], DD Flags [Master], MTU 1500, DD-Sequence 0x00001d48
+IP6 (class 0xe0, hlim 1, next-header OSPF (89) payload length: 288) fe80::1 > fe80:0:ff:ffff:f000::2: OSPFv3, LS-Update, length 288
+       Router-ID 1.1.1.1, Area 0.0.0.1 [|ospf3]
diff --git a/tests/ospf6_print_lshdr-oobr.pcapng b/tests/ospf6_print_lshdr-oobr.pcapng
new file mode 100644 (file)
index 0000000..9f96af6
Binary files /dev/null and b/tests/ospf6_print_lshdr-oobr.pcapng differ
index 5edcdda..562d0bc 100644 (file)
@@ -1 +1,2 @@
-EXIT CODE 00000100
+
+EXIT CODE 00000100: dump:0 code: 1
diff --git a/tests/pcap-invalid-version-1.out.stderr b/tests/pcap-invalid-version-1.out.stderr
new file mode 100644 (file)
index 0000000..1036edb
--- /dev/null
@@ -0,0 +1 @@
+tcpdump: archaic pcap savefile format
index 5edcdda..562d0bc 100644 (file)
@@ -1 +1,2 @@
-EXIT CODE 00000100
+
+EXIT CODE 00000100: dump:0 code: 1
diff --git a/tests/pcap-invalid-version-2.out.stderr b/tests/pcap-invalid-version-2.out.stderr
new file mode 100644 (file)
index 0000000..4171b8e
--- /dev/null
@@ -0,0 +1 @@
+tcpdump: unsupported pcap savefile version 2.5
diff --git a/tests/pcap-ng-invalid-vers-1.out b/tests/pcap-ng-invalid-vers-1.out
deleted file mode 100644 (file)
index 5edcdda..0000000
+++ /dev/null
@@ -1 +0,0 @@
-EXIT CODE 00000100
diff --git a/tests/pcap-ng-invalid-vers-2.out b/tests/pcap-ng-invalid-vers-2.out
deleted file mode 100644 (file)
index 5edcdda..0000000
+++ /dev/null
@@ -1 +0,0 @@
-EXIT CODE 00000100
diff --git a/tests/pcapng-invalid-vers-1.out b/tests/pcapng-invalid-vers-1.out
new file mode 100644 (file)
index 0000000..562d0bc
--- /dev/null
@@ -0,0 +1,2 @@
+
+EXIT CODE 00000100: dump:0 code: 1
diff --git a/tests/pcapng-invalid-vers-1.out.stderr b/tests/pcapng-invalid-vers-1.out.stderr
new file mode 100644 (file)
index 0000000..4213849
--- /dev/null
@@ -0,0 +1 @@
+tcpdump: unsupported pcapng savefile version 0.1
diff --git a/tests/pcapng-invalid-vers-2.out b/tests/pcapng-invalid-vers-2.out
new file mode 100644 (file)
index 0000000..562d0bc
--- /dev/null
@@ -0,0 +1,2 @@
+
+EXIT CODE 00000100: dump:0 code: 1
diff --git a/tests/pcapng-invalid-vers-2.out.stderr b/tests/pcapng-invalid-vers-2.out.stderr
new file mode 100644 (file)
index 0000000..4845652
--- /dev/null
@@ -0,0 +1 @@
+tcpdump: unsupported pcapng savefile version 1.1
index e23ed91..d3a600e 100644 (file)
@@ -1,3 +1,4 @@
 [|pktap]
 [|ppp]
-EXIT CODE 00000100
+
+EXIT CODE 00000100: dump:0 code: 1
diff --git a/tests/pktap-heap-overflow.out.stderr b/tests/pktap-heap-overflow.out.stderr
new file mode 100644 (file)
index 0000000..38f484c
--- /dev/null
@@ -0,0 +1,2 @@
+reading from file pktap-heap-overflow.pcap, link-type 149
+tcpdump: pcap_loop: invalid packet capture length 4076008178, bigger than snaplen of 1024
index eb825fb..0624709 100644 (file)
Binary files a/tests/relts-0x80000000.pcap and b/tests/relts-0x80000000.pcap differ
index d3c41ee..08899db 100644 (file)
@@ -1 +1 @@
-IP6 (hlim 64, next-header ICMPv6 (58) payload length: 56) fe80::216:3eff:fe11:3424 > fe80::216:3eff:fe11:3424: [icmp6 sum ok] ICMP6, RPL, (CLR)Destination Advertisement Object [dagid:5431::,seq:10,instance:42,Dagid,40] opt:rpltarget len:25  opt:pad0 opt:pad0 opt:pad0 opt:pad0 opt:pad0 opt:pad0 opt:pad0
+IP6 (hlim 64, next-header ICMPv6 (58) payload length: 56) fe80::216:3eff:fe11:3424 > fe80::216:3eff:fe11:3424: [icmp6 sum ok] ICMP6, RPL, (CLR)Destination Advertisement Object [dagid:5431::,seq:10,instance:42,Dagid,40] opt:rpltarget len:25  opt:pad0 opt:pad0 opt:pad0 opt:pad0 opt:pad0 opt:pad0 [|rpl]
index deee033..3db3834 100644 (file)
@@ -1 +1 @@
-IP6 (hlim 64, next-header ICMPv6 (58) payload length: 56) fe80::216:3eff:fe11:3424 > fe80::216:3eff:fe11:3424: [icmp6 sum ok] ICMP6, RPL, (CLR)Destination Advertisement Object [dagid:5431::,seq:10,instance:42,Dagid,40] opt:rpltarget len:25  0x0000:  0080 2001 0db8 0001 0000 0216 3eff fe11 0x0010:  3424 0000 0000 00 opt:pad0 opt:pad0 opt:pad0 opt:pad0 opt:pad0 opt:pad0 opt:pad0
+IP6 (hlim 64, next-header ICMPv6 (58) payload length: 56) fe80::216:3eff:fe11:3424 > fe80::216:3eff:fe11:3424: [icmp6 sum ok] ICMP6, RPL, (CLR)Destination Advertisement Object [dagid:5431::,seq:10,instance:42,Dagid,40] opt:rpltarget len:25  0x0000:  0080 2001 0db8 0001 0000 0216 3eff fe11 0x0010:  3424 0000 0000 00 opt:pad0 opt:pad0 opt:pad0 opt:pad0 opt:pad0 opt:pad0 [|rpl]
diff --git a/tests/rpl-dao-oobr.out b/tests/rpl-dao-oobr.out
new file mode 100644 (file)
index 0000000..e410ee1
--- /dev/null
@@ -0,0 +1 @@
+IP6 (hlim 64, next-header ICMPv6 (58) payload length: 56) fe80::216:3eff:fe11:3424 > fe80::216:3eff:fe11:3424: ICMP6, RPL, (CLR)Destination Advertisement Object [dagid:<elided>,seq:0,instance:42,00] opt:subopt:13 len:2  opt:subopt:128 len:15  opt:subopt:13 len:15  [|rpl]
diff --git a/tests/rpl-dao-oobr.pcapng b/tests/rpl-dao-oobr.pcapng
new file mode 100644 (file)
index 0000000..39e95a7
Binary files /dev/null and b/tests/rpl-dao-oobr.pcapng differ
diff --git a/tests/rsvp-rsvp_obj_print-oobr.out b/tests/rsvp-rsvp_obj_print-oobr.out
new file mode 100644 (file)
index 0000000..fc1a8c6
--- /dev/null
@@ -0,0 +1,7 @@
+TIPC v5.0 226.0.0 > 64.14.1536, headerlength 56 bytes, MessageSize 51914 bytes, Link Changeover Protocol internal, messageType Unknown (0xcacacaca)[|TIPC]
+[|ether]
+IP (tos 0x0, ttl 14, id 44815, offset 0, flags [+, DF, rsvd], proto RSVP (46), length 40, bad cksum 3280 (->c411)!)
+    250.219.91.71 > 20.100.238.255: 
+       RSVPv1 Hello Message (20), Flags: [none], length: 16384, ttl: 0, checksum: 0x000e
+         Class Type (old) Object (125) Flags: [reject if unknown], Class-Type: 1 (1), length: 4
+                [|rsvp]
diff --git a/tests/rsvp-rsvp_obj_print-oobr.pcap b/tests/rsvp-rsvp_obj_print-oobr.pcap
new file mode 100644 (file)
index 0000000..c12da8d
Binary files /dev/null and b/tests/rsvp-rsvp_obj_print-oobr.pcap differ
diff --git a/tests/rx_serviceid_oobr.out b/tests/rx_serviceid_oobr.out
new file mode 100644 (file)
index 0000000..f2c0e2a
--- /dev/null
@@ -0,0 +1,3 @@
+IP 250.15.128.19.68 > 249.251.157.8.63246: BOOTP/DHCP, unknown (0x00), length 8085
+[|ether]
+IP 0.0.0.0.0 > 0.0.0.0.7004:  rx abort (539)
diff --git a/tests/rx_serviceid_oobr.pcap b/tests/rx_serviceid_oobr.pcap
new file mode 100644 (file)
index 0000000..8bc1a75
Binary files /dev/null and b/tests/rx_serviceid_oobr.pcap differ
diff --git a/tests/smb.sh b/tests/smb.sh
new file mode 100644 (file)
index 0000000..4502354
--- /dev/null
@@ -0,0 +1,49 @@
+#!/bin/sh
+
+srcdir=${1-..}
+: echo smb.sh using ${srcdir} from `pwd`
+
+testdir=${srcdir}/tests
+
+exitcode=0
+passedfile=tests/.passed
+failedfile=tests/.failed
+passed=`cat ${passedfile}`
+failed=`cat ${failedfile}`
+
+# Only attempt OpenSSL-specific tests when compiled with the library.
+
+if grep '^#define ENABLE_SMB 1$' config.h >/dev/null
+then
+    cat ${srcdir}/tests/SMBLIST | while read name input output options
+    do
+        case $name in
+            \#*) continue;;
+            '') continue;;
+        esac
+        rm -f core
+        [ "$only" != "" -a "$name" != "$only" ] && continue
+        SRCDIR=${srcdir}
+        export SRCDIR
+        # I hate shells with their stupid, useless subshells.
+        passed=`cat ${passedfile}`
+        failed=`cat ${failedfile}`
+        (cd tests  # run TESTonce in tests directory
+         if ${srcdir}/tests/TESTonce $name ${srcdir}/tests/$input ${srcdir}/tests/$output "$options"
+         then
+             passed=`expr $passed + 1`
+             echo $passed >${passedfile}
+         else
+             failed=`expr $failed + 1`
+             echo $failed >${failedfile}
+         fi
+         if [ -d COREFILES ]; then
+             if [ -f core ]; then mv core COREFILES/$name.core; fi
+         fi)
+    done
+    # I hate shells with their stupid, useless subshells.
+    passed=`cat ${passedfile}`
+    failed=`cat ${failedfile}`
+fi
+
+exit $exitcode
diff --git a/tests/smb_print_trans-oobr1.out b/tests/smb_print_trans-oobr1.out
new file mode 100644 (file)
index 0000000..1e5dfaf
--- /dev/null
@@ -0,0 +1,39 @@
+IPX a8f87967.00:00:00:00:00:01.0455 > 00000000.ff:ff:ff:ff:ff:ff.0455: ipx-netbios 50
+IPX a8f87967.00:00:00:00:00:01.0455 > 00000000.ff:ff:ff:ff:ff:ff.0455: ipx-netbios 50
+IPX a8f87967.00:00:00:ff:ff:ff.7f55 > 00000000.ff:ff:ff:ff:ff:ff.0455: ipx-netbios 50
+IPX a855000b.41:44:4d:49:4e:54.4553 > 00000000.ff:ff:ff:ff:ff:ff.0455: ipx-netbios 162
+>>> IPX transport Data: (24 bytes)
+[000] 54 20 20 20 20 20 20 00  01 02 5F 5F 4D 53 26 52  T      \0x00 \0x01\0x02__MS&R
+[010] 4F 57 53 45 5F 5F 02 01                           OWSE__\0x02\0x01 
+
+SMB PACKET: SMBtrans (REQUEST)
+SMB Command   =  0x25
+Error class   =  0x0
+Error code    =  0 (0x0)
+Flags1        =  0x0
+Flags2        =  0x0
+Tree ID       =  0 (0x0)
+Proc ID       =  0 (0x0)
+UID           =  0 (0x0)
+MID           =  0 (0x0)
+Word Count    =  17 (0x11)
+TotParamCnt=0 (0x0) 
+TotDataCnt=42 (0x2a) 
+MaxParmCnt=0 (0x0) 
+MaxDataCnt=0 (0x0)
+MaxSCnt=0 (0x0) 
+TransFlags=0x0 
+Res1=0x3E8 
+Res2=0x0 
+Res3=0x0
+ParamCnt=0 (0x0) 
+ParamOff=0 (0x0) 
+DataCnt=42 (0x2a) 
+DataOff=86 (0x56) 
+SUCnt=3 (0x3)
+Data: (6 bytes)
+[000] 01 00 01 00 02 00                                 \0x01\0x00\0x01\0x00\0x02\0x00 
+smb_bcc=59
+[|SMB]
+
+
diff --git a/tests/smb_print_trans-oobr1.pcapng b/tests/smb_print_trans-oobr1.pcapng
new file mode 100644 (file)
index 0000000..44e6459
Binary files /dev/null and b/tests/smb_print_trans-oobr1.pcapng differ
diff --git a/tests/smb_print_trans-oobr2.out b/tests/smb_print_trans-oobr2.out
new file mode 100644 (file)
index 0000000..1b3d99e
--- /dev/null
@@ -0,0 +1,37 @@
+IP (tos 0x0, ttl 128, id 14471, offset 0, flags [none], proto UDP (17), length 207)
+    192.168.1.249.138 > 192.168.1.255.138: 
+>>> NBT UDP PACKET(138) Res=0x110E ID=0x891D IP=192 (0xc0).168 (0xa8).1 (0x1).249 (0xf9) Port=138 (0x8a) Length=165 (0xa5) Res2=0x0
+SourceName=DJP95S0J        NameType=0x00 (Workstation)
+DestName=ARBEIT          NameType=0x00 (Workstation)
+
+SMB PACKET: SMBtrans (REQUEST)
+SMB Command   =  0x25
+Error class   =  0x0
+Error code    =  0 (0x0)
+Flags1        =  0x0
+Flags2        =  0x0
+Tree ID       =  0 (0x0)
+Proc ID       =  0 (0x0)
+UID           =  0 (0x0)
+MID           =  0 (0x0)
+Word Count    =  17 (0x11)
+TotParamCnt=0 (0x0) 
+TotDataCnt=11 (0xb) 
+MaxParmCnt=0 (0x0) 
+MaxDataCnt=0 (0x0)
+MaxSCnt=0 (0x0) 
+TransFlags=0x0 
+Res1=0x3E8 
+Res2=0x0 
+Res3=0x0
+ParamCnt=0 (0x0) 
+ParamOff=0 (0x0) 
+DataCnt=11 (0xb) 
+DataOff=86 (0x56) 
+SUCnt=3 (0x3)
+Data: (6 bytes)
+[000] 01 00 01 00 02 00                                 \0x01\0x00\0x01\0x00\0x02\0x00 
+smb_bcc=28
+[|SMB]
+
+
diff --git a/tests/smb_print_trans-oobr2.pcap b/tests/smb_print_trans-oobr2.pcap
new file mode 100644 (file)
index 0000000..485a5d8
Binary files /dev/null and b/tests/smb_print_trans-oobr2.pcap differ
index b6ae2ac..bfd1c83 100644 (file)
Binary files a/tests/stp-v4-length-sigsegv.pcap and b/tests/stp-v4-length-sigsegv.pcap differ
index c8800f6..3f079fd 100644 (file)
Binary files a/tests/tftp-heapoverflow.pcap and b/tests/tftp-heapoverflow.pcap differ
diff --git a/tests/vrrp-vrrp_print-oobr-2.out b/tests/vrrp-vrrp_print-oobr-2.out
new file mode 100644 (file)
index 0000000..9f1ccbb
--- /dev/null
@@ -0,0 +1,20 @@
+IP (tos 0x2,ECT(0), ttl 35, id 48399, offset 0, flags [+, DF, rsvd], proto VRRP (112), length 39, bad cksum 7f (->c1ae)!)
+    0.3.2.148 > 54.0.0.16: vrrp 0.3.2.148 > 54.0.0.16: VRRPv3, Advertisement, (ttl 35), vrid 255, prio 17, intvl 269cs, length 19, addrs(3):[|vrrp]
+IP (tos 0x2,ECT(0), ttl 35, id 40207, offset 0, flags [+, DF, rsvd], proto VRRP (112), length 39, bad cksum 7e (->e1b5)!)
+    255.251.2.148 > 54.0.0.16: vrrp 255.251.2.148 > 54.0.0.16: VRRPv3, Advertisement, (ttl 35), vrid 255, prio 17, intvl 2304cs, length 19, addrs(3):[|vrrp]
+IP (tos 0x2,ECT(0), ttl 35, id 40207, offset 0, flags [+, DF, rsvd], proto VRRP (112), length 39, bad cksum 597f (->e1ae)!)
+    0.3.2.148 > 54.0.0.16: vrrp 0.3.2.148 > 54.0.0.16: VRRPv3, Advertisement, (ttl 35), vrid 255, prio 17, intvl 256cs, length 19, addrs(3):[|vrrp]
+IP (tos 0x2,ECT(0), ttl 35, id 40207, offset 0, flags [+, DF, rsvd], proto VRRP (112), length 39, bad cksum 7f (->e154)!)
+    0.3.2.148 > 54.90.0.16: vrrp 0.3.2.148 > 54.90.0.16: VRRPv3, Advertisement, (ttl 35), vrid 255, prio 17, intvl 256cs, length 19, addrs(3):[|vrrp]
+IP (tos 0x2,ECT(0), ttl 35, id 40207, offset 0, flags [+, DF, rsvd], proto VRRP (112), length 39, bad cksum 7f (->e1ae)!)
+    0.3.2.148 > 54.0.0.16: vrrp 0.3.2.148 > 54.0.0.16: VRRPv3, Advertisement, (ttl 35), vrid 0, prio 4, intvl 2304cs, length 19, addrs:
+IP (tos 0x2,ECT(0), ttl 35, id 48399, offset 0, flags [+, DF, rsvd], proto VRRP (112), length 39, bad cksum 7f (->c1ae)!)
+    0.3.2.148 > 54.0.0.16: vrrp 0.3.2.148 > 54.0.0.16: VRRPv3, Advertisement, (ttl 35), vrid 255, prio 17, intvl 256cs, length 19, addrs(3):[|vrrp]
+IP (tos 0x2,ECT(0), ttl 35, id 40207, offset 0, flags [+, DF, rsvd], proto VRRP (112), length 39, bad cksum 7f (->e1ae)!)
+    0.3.2.148 > 54.0.0.16: vrrp 0.3.2.148 > 54.0.0.16: VRRPv3, Advertisement, (ttl 35), vrid 255, prio 17, intvl 256cs, length 19, addrs(3):[|vrrp]
+IP (tos 0x2,ECT(0), ttl 34, id 40207, offset 0, flags [+, DF, rsvd], proto VRRP (112), length 27, bad cksum 7f (->e260)!)
+    0.3.2.148 > 54.90.0.16: vrrp 0.3.2.148 > 54.90.0.16: VRRPv3, Advertisement, (ttl 34), vrid 255, prio 17, intvl 256cs, length 7[|vrrp]
+IP (tos 0x2,ECT(0), ttl 35, id 40207, offset 0, flags [+, DF, rsvd], proto VRRP (112), length 39, bad cksum 7f (->17af)!)
+    0.3.2.148 > 0.0.0.16: vrrp 0.3.2.148 > 0.0.0.16: VRRPv3, Advertisement, (ttl 35), vrid 0, prio 4, intvl 2304cs, length 19, addrs:
+IP (tos 0x2,ECT(0), ttl 35, id 48399, offset 0, flags [+, DF, rsvd], proto VRRP (112), length 39, bad cksum 7f (->2e8a)!)
+    242.242.242.242 > 242.242.242.242: vrrp 242.242.242.242 > 242.242.242.242: VRRPv15, unknown type (2), (ttl 35)
diff --git a/tests/vrrp-vrrp_print-oobr-2.pcap b/tests/vrrp-vrrp_print-oobr-2.pcap
new file mode 100644 (file)
index 0000000..b0edc24
Binary files /dev/null and b/tests/vrrp-vrrp_print-oobr-2.pcap differ
diff --git a/tests/vrrp-vrrp_print-oobr.out b/tests/vrrp-vrrp_print-oobr.out
new file mode 100644 (file)
index 0000000..fd87db8
--- /dev/null
@@ -0,0 +1,6 @@
+IP (tos 0x7f,CE, ttl 254, id 40208, offset 0, flags [none], proto VRRP (112), length 34, options (unknown 69 [bad length 83]), bad cksum 8e15 (->bc96)!)
+    250.219.91.20 > 209.150.251.64: vrrp 250.219.91.20 > 209.150.251.64: VRRPv2, Advertisement, (ttl 254), vrid 2, prio 0, authtype simple, intvl 255s, length 6[|vrrp]
+IP (tos 0x7f,CE, ttl 254, id 40208, offset 0, flags [none], proto VRRP (112), length 40, options (unknown 69 [bad length 83]), bad cksum 8e15 (->b790)!)
+    250.219.91.20 > 209.150.251.64: vrrp 250.219.91.20 > 209.150.251.64: VRRPv2, Advertisement, (ttl 254), vrid 2, prio 0, authtype simple, intvl 255s, length 12, addrs:[|vrrp]
+IP (tos 0x7f,CE, ttl 254, id 40208, offset 0, flags [none], proto VRRP (112), length 40, options (unknown 69 [bad length 83]), bad cksum 8e15 (->bc90)!)
+    250.219.91.20 > 209.150.251.64: vrrp 250.219.91.20 > 209.150.251.64: VRRPv2, Advertisement, (ttl 254), vrid 2, prio 0, authtype simple, intvl 255s, length 12, addrs:[|vrrp]
diff --git a/tests/vrrp-vrrp_print-oobr.pcap b/tests/vrrp-vrrp_print-oobr.pcap
new file mode 100644 (file)
index 0000000..a74bc50
Binary files /dev/null and b/tests/vrrp-vrrp_print-oobr.pcap differ
index 90e11b9..0e30d79 100644 (file)
@@ -120,10 +120,21 @@ fn_print(netdissect_options *ndo,
 
 /*
  * Print out a null-terminated filename (or other ascii string) from
- * a fixed-length buffer.
- * If ep is NULL, assume no truncation check is needed.
+ * a fixed-length field in the packet buffer, or from what remains of
+ * the packet.
+ *
+ * n is the length of the fixed-length field, or the number of bytes
+ * remaining in the packet based on its on-the-network length.
+ *
+ * If ep is non-null, it should point just past the last captured byte
+ * of the packet, e.g. ndo->ndo_snapend.  If ep is NULL, we assume no
+ * truncation check, other than the checks of the field length/remaining
+ * packet data length, is needed.
+ *
  * Return the number of bytes of string processed, including the
- * terminating null, if not truncated.  Return 0 if truncated.
+ * terminating null, if not truncated; as the terminating null is
+ * included in the count, and as there must be a terminating null,
+ * this will always be non-zero.  Return 0 if truncated.
  */
 u_int
 fn_printztn(netdissect_options *ndo,
@@ -137,7 +148,8 @@ fn_printztn(netdissect_options *ndo,
                if (n == 0 || (ep != NULL && s >= ep)) {
                        /*
                         * Truncated.  This includes "no null before we
-                        * got to the end of the fixed-length buffer".
+                        * got to the end of the fixed-length buffer or
+                        * the end of the packet".
                         *
                         * XXX - BOOTP says "null-terminated", which
                         * means the maximum length of the string, in