diff -Nru tcpslice-1.3/aclocal.m4 tcpslice-1.5/aclocal.m4 --- tcpslice-1.3/aclocal.m4 2020-08-19 18:16:16.000000000 +0000 +++ tcpslice-1.5/aclocal.m4 2021-10-07 12:13:20.000000000 +0000 @@ -211,36 +211,6 @@ ]) dnl -dnl Check whether, if you pass an unknown warning option to the -dnl compiler, it fails or just prints a warning message and succeeds. -dnl Set ac_lbl_unknown_warning_option_error to the appropriate flag -dnl to force an error if it would otherwise just print a warning message -dnl and succeed. -dnl -AC_DEFUN(AC_LBL_CHECK_UNKNOWN_WARNING_OPTION_ERROR, - [ - AC_MSG_CHECKING([whether the compiler fails when given an unknown warning option]) - save_CFLAGS="$CFLAGS" - CFLAGS="$CFLAGS -Wxyzzy-this-will-never-succeed-xyzzy" - AC_TRY_COMPILE( - [], - [return 0], - [ - AC_MSG_RESULT([no]) - # - # We're assuming this is clang, where - # -Werror=unknown-warning-option is the appropriate - # option to force the compiler to fail. - # - ac_lbl_unknown_warning_option_error="-Werror=unknown-warning-option" - ], - [ - AC_MSG_RESULT([yes]) - ]) - CFLAGS="$save_CFLAGS" - ]) - -dnl dnl Check whether the compiler option specified as the second argument dnl is supported by the compiler and, if so, add it to the macro dnl specified as the first argument @@ -249,21 +219,35 @@ [ AC_MSG_CHECKING([whether the compiler supports the $2 option]) save_CFLAGS="$CFLAGS" - if expr "x$2" : "x-W.*" >/dev/null - then - CFLAGS="$CFLAGS $ac_lbl_unknown_warning_option_error $2" - elif expr "x$2" : "x-f.*" >/dev/null - then - CFLAGS="$CFLAGS -Werror $2" - elif expr "x$2" : "x-m.*" >/dev/null - then - CFLAGS="$CFLAGS -Werror $2" - else - CFLAGS="$CFLAGS $2" - fi - AC_TRY_COMPILE( - [], - [return 0], + CFLAGS="$CFLAGS $2" + # + # XXX - yes, this depends on the way AC_LANG_WERROR works, + # but no mechanism is provided to turn AC_LANG_WERROR on + # *and then turn it back off*, so that we *only* do it when + # testing compiler options - 15 years after somebody asked + # for it: + # + # https://autoconf.gnu.narkive.com/gTAVmfKD/how-to-cancel-flags-set-by-ac-lang-werror + # + save_ac_c_werror_flag="$ac_c_werror_flag" + ac_c_werror_flag=yes + # + # We use AC_LANG_SOURCE() so that we can control the complete + # content of the program being compiled. We do not, for example, + # want the default "int main()" that AC_LANG_PROGRAM() generates, + # as it will generate a warning with -Wold-style-definition, meaning + # that we would treat it as not working, as the test will fail if + # *any* error output, including a warning due to the flag we're + # testing, is generated; see + # + # https://www.postgresql.org/message-id/2192993.1591682589%40sss.pgh.pa.us + # https://www.postgresql.org/message-id/2192993.1591682589%40sss.pgh.pa.us + # + # This may, as per those two messages, be fixed in autoonf 2.70, + # but we only require 2.64 or newer for now. + # + AC_COMPILE_IFELSE( + [AC_LANG_SOURCE([[int main(void) { return 0; }]])], [ AC_MSG_RESULT([yes]) CFLAGS="$save_CFLAGS" @@ -273,6 +257,7 @@ AC_MSG_RESULT([no]) CFLAGS="$save_CFLAGS" ]) + ac_c_werror_flag="$save_ac_c_werror_flag" ]) dnl @@ -872,7 +857,6 @@ # Skip all the warning option stuff on some compilers. # if test "$ac_lbl_cc_dont_try_gcc_dashW" != yes; then - AC_LBL_CHECK_UNKNOWN_WARNING_OPTION_ERROR() AC_LBL_CHECK_COMPILER_OPT($1, -W) AC_LBL_CHECK_COMPILER_OPT($1, -Wall) AC_LBL_CHECK_COMPILER_OPT($1, -Wassign-enum) diff -Nru tcpslice-1.3/CHANGES tcpslice-1.5/CHANGES --- tcpslice-1.3/CHANGES 2020-08-19 18:16:16.000000000 +0000 +++ tcpslice-1.5/CHANGES 2021-12-30 20:53:31.000000000 +0000 @@ -1,3 +1,45 @@ +v1.5 Thu 30 Dec 20:53:17 GMT 2021 + +- CVE-2021-41043: Fix a use-after-free in extract_slice(). + +- Deallocate input resources to plug a leak. + +- Require every input file to have the same DLT. + +- Compare the first and the last timestamps of input. + +- Get the initial value right in latest_end_time(). + +- Makefile.in: Quote some pathnames properly. + +- Handle some build errors better. + +- Fix "make releasetar" on AIX and Solaris. + +- Address all compiler warnings (Linux, NetBSD 9.2 and Solaris). + +- Improve CI build matrix scripts. + +v1.4 Tue 15 Jun 08:30:11 BST 2021 + +- Install into bindir, not sbindir. + +- Refine some C code style. + +- Address many warnings from GCC, Clang and cppcheck. + +- Fix wording in an error message. + +- Update MAX_REASONABLE_PACKET_LENGTH to 262144. + +- Tell libooh323c in the "-h" message. + +- Update config.{guess,sub}, timestamps 2021-01-25,2021-03-10. + +- Fix parallel build with FreeBSD make. + +- Fix building with OpenBSD libpcap. + v1.3 Wed 19 Aug 19:00:47 BST 2020 - Update to modern autotools and remove some obsolete code. diff -Nru tcpslice-1.3/.cirrus.yml tcpslice-1.5/.cirrus.yml --- tcpslice-1.3/.cirrus.yml 2020-08-19 18:16:16.000000000 +0000 +++ tcpslice-1.5/.cirrus.yml 1970-01-01 00:00:00.000000000 +0000 @@ -1,23 +0,0 @@ -env: - CIRRUS_CLONE_DEPTH: 3 - IGNORE_OSVERSION: yes - # Parallel make is currently broken in tcpslice. - MAKEFLAGS: '-j 1' - -task: - freebsd_instance: - matrix: - - image_family: freebsd-11-3-snap - - image_family: freebsd-12-1-snap - - image_family: freebsd-13-0-snap - script: - - freebsd-version - - pkg update -f - - pkg install -qy autoconf - - touch .devel - - cc --version - - ./configure --prefix=/tmp - - make CFLAGS=-Werror - - ./tcpslice -h - - make install - - make releasetar diff -Nru tcpslice-1.3/compiler-tests.h tcpslice-1.5/compiler-tests.h --- tcpslice-1.3/compiler-tests.h 2020-08-19 18:16:16.000000000 +0000 +++ tcpslice-1.5/compiler-tests.h 2021-10-07 12:13:20.000000000 +0000 @@ -88,6 +88,18 @@ #endif /* + * Check whether this is Clang major.minor or a later release. + */ + +#if !defined(__clang__) +#define TCPSLICE_IS_AT_LEAST_CLANG_VERSION(major, minor) 0 +#else +#define TCPSLICE_IS_AT_LEAST_CLANG_VERSION(major, minor) \ + (__clang_major__ > (major) || \ + (__clang_major__ == (major) && __clang_minor__ >= (minor))) +#endif + +/* * Check whether this is Sun C/SunPro C/Oracle Studio major.minor * or a later release. * @@ -121,12 +133,21 @@ * * The version number in __xlC__ has the major version in the * upper 8 bits and the minor version in the lower 8 bits. + * On AIX __xlC__ is always defined, __ibmxl__ becomes defined in XL C 16.1. + * On Linux since XL C 13.1.6 __xlC__ is not defined by default anymore, but + * __ibmxl__ is defined since at least XL C 13.1.1. */ #if ! defined(__xlC__) +#if ! defined(__ibmxl__) #define TCPSLICE_IS_AT_LEAST_XL_C_VERSION(major,minor) 0 #else #define TCPSLICE_IS_AT_LEAST_XL_C_VERSION(major, minor) \ + (__ibmxl_version__ > (major) || \ + (__ibmxl_version__ == (major) && __ibmxl_release__ >= (minor))) +#endif /* ! __ibmxl__ */ +#else /* ! __xlC__ */ +#define TCPSLICE_IS_AT_LEAST_XL_C_VERSION(major, minor) \ (__xlC__ >= (((major) << 8) | (minor))) #endif @@ -148,4 +169,4 @@ (__HP_aCC >= ((major)*10000 + (minor)*100)) #endif -#endif /* tcpslice_funcattrs_h */ +#endif /* tcpslice_compiler_tests_h */ diff -Nru tcpslice-1.3/config.guess tcpslice-1.5/config.guess --- tcpslice-1.3/config.guess 2020-08-19 18:16:16.000000000 +0000 +++ tcpslice-1.5/config.guess 2021-10-07 12:13:20.000000000 +0000 @@ -1,8 +1,8 @@ #! /bin/sh # Attempt to guess a canonical system name. -# Copyright 1992-2018 Free Software Foundation, Inc. +# Copyright 1992-2021 Free Software Foundation, Inc. -timestamp='2018-07-06' +timestamp='2021-01-25' # 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 @@ -27,12 +27,12 @@ # Originally written by Per Bothner; maintained since 2000 by Ben Elliston. # # You can get the latest version of this script from: -# https://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess +# https://git.savannah.gnu.org/cgit/config.git/plain/config.guess # # Please send patches to . -me=`echo "$0" | sed -e 's,.*/,,'` +me=$(echo "$0" | sed -e 's,.*/,,') usage="\ Usage: $0 [OPTION] @@ -50,7 +50,7 @@ GNU config.guess ($timestamp) Originally written by Per Bothner. -Copyright 1992-2018 Free Software Foundation, Inc. +Copyright 1992-2021 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." @@ -84,8 +84,6 @@ exit 1 fi -trap 'exit 1' 1 2 15 - # CC_FOR_BUILD -- compiler used by this script. Note that the use of a # compiler to aid in system detection is discouraged as it requires # temporary files to be created and, as you can see below, it is a @@ -96,66 +94,82 @@ # Portable tmp directory creation inspired by the Autoconf team. -set_cc_for_build=' -trap "exitcode=\$?; (rm -f \$tmpfiles 2>/dev/null; rmdir \$tmp 2>/dev/null) && exit \$exitcode" 0 ; -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 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" ; - for c in cc gcc c89 c99 ; do - if ($c -c -o "$dummy.o" "$dummy.c") >/dev/null 2>&1 ; then - CC_FOR_BUILD="$c"; break ; - fi ; - done ; - if test x"$CC_FOR_BUILD" = x ; then - CC_FOR_BUILD=no_compiler_found ; - fi - ;; - ,,*) CC_FOR_BUILD=$CC ;; - ,*,*) CC_FOR_BUILD=$HOST_CC ;; -esac ; set_cc_for_build= ;' +tmp= +# shellcheck disable=SC2172 +trap 'test -z "$tmp" || rm -fr "$tmp"' 0 1 2 13 15 + +set_cc_for_build() { + # prevent multiple calls if $tmp is already set + test "$tmp" && return 0 + : "${TMPDIR=/tmp}" + # shellcheck disable=SC2039 + { 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" 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 + case ${CC_FOR_BUILD-},${HOST_CC-},${CC-} in + ,,) echo "int x;" > "$dummy.c" + for driver in cc gcc c89 c99 ; do + if ($driver -c -o "$dummy.o" "$dummy.c") >/dev/null 2>&1 ; then + CC_FOR_BUILD="$driver" + break + fi + done + if test x"$CC_FOR_BUILD" = x ; then + CC_FOR_BUILD=no_compiler_found + fi + ;; + ,,*) CC_FOR_BUILD=$CC ;; + ,*,*) CC_FOR_BUILD=$HOST_CC ;; + esac +} # This is needed to find uname on a Pyramid OSx when run in the BSD universe. # (ghazi@noc.rutgers.edu 1994-08-24) -if (test -f /.attbin/uname) >/dev/null 2>&1 ; then +if test -f /.attbin/uname ; then PATH=$PATH:/.attbin ; export PATH fi -UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown -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 +UNAME_MACHINE=$( (uname -m) 2>/dev/null) || UNAME_MACHINE=unknown +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 Linux|GNU|GNU/*) - # If the system lacks a compiler, then just pick glibc. - # We could probably try harder. - LIBC=gnu + LIBC=unknown - eval "$set_cc_for_build" + set_cc_for_build cat <<-EOF > "$dummy.c" #include #if defined(__UCLIBC__) LIBC=uclibc #elif defined(__dietlibc__) LIBC=dietlibc - #else + #elif defined(__GLIBC__) LIBC=gnu + #else + #include + /* First heuristic to detect musl libc. */ + #ifdef __DEFINED_va_list + LIBC=musl + #endif #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 + # Second heuristic to detect musl libc. + if [ "$LIBC" = unknown ] && + command -v ldd >/dev/null && + ldd --version 2>&1 | grep -q ^musl; then + LIBC=musl + fi + + # If the system lacks a compiler, then just pick glibc. + # We could probably try harder. + if [ "$LIBC" = unknown ]; then + LIBC=gnu fi ;; esac @@ -174,20 +188,20 @@ # # Note: NetBSD doesn't particularly care about the vendor # 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 || \ - echo unknown)` + UNAME_MACHINE_ARCH=$( (uname -p 2>/dev/null || \ + /sbin/sysctl -n hw.machine_arch 2>/dev/null || \ + /usr/sbin/sysctl -n hw.machine_arch 2>/dev/null || \ + echo unknown)) case "$UNAME_MACHINE_ARCH" in + aarch64eb) machine=aarch64_be-unknown ;; 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'` + 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 ;; @@ -199,7 +213,7 @@ os=netbsdelf ;; arm*|i386|m68k|ns32k|sh3*|sparc|vax) - eval "$set_cc_for_build" + set_cc_for_build if echo __ELF__ | $CC_FOR_BUILD -E - 2>/dev/null \ | grep -q __ELF__ then @@ -218,7 +232,7 @@ 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 @@ -231,7 +245,7 @@ release='-gnu' ;; *) - release=`echo "$UNAME_RELEASE" | sed -e 's/[-_].*//' | cut -d. -f1,2` + release=$(echo "$UNAME_RELEASE" | sed -e 's/[-_].*//' | cut -d. -f1,2) ;; esac # Since CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM: @@ -240,15 +254,15 @@ echo "$machine-${os}${release}${abi-}" exit ;; *:Bitrig:*:*) - UNAME_MACHINE_ARCH=`arch | sed 's/Bitrig.//'` + UNAME_MACHINE_ARCH=$(arch | sed 's/Bitrig.//') echo "$UNAME_MACHINE_ARCH"-unknown-bitrig"$UNAME_RELEASE" exit ;; *:OpenBSD:*:*) - UNAME_MACHINE_ARCH=`arch | sed 's/OpenBSD.//'` + UNAME_MACHINE_ARCH=$(arch | sed 's/OpenBSD.//') echo "$UNAME_MACHINE_ARCH"-unknown-openbsd"$UNAME_RELEASE" exit ;; *:LibertyBSD:*:*) - UNAME_MACHINE_ARCH=`arch | sed 's/^.*BSD\.//'` + UNAME_MACHINE_ARCH=$(arch | sed 's/^.*BSD\.//') echo "$UNAME_MACHINE_ARCH"-unknown-libertybsd"$UNAME_RELEASE" exit ;; *:MidnightBSD:*:*) @@ -260,6 +274,9 @@ *:SolidBSD:*:*) echo "$UNAME_MACHINE"-unknown-solidbsd"$UNAME_RELEASE" exit ;; + *:OS108:*:*) + echo "$UNAME_MACHINE"-unknown-os108_"$UNAME_RELEASE" + exit ;; macppc:MirBSD:*:*) echo powerpc-unknown-mirbsd"$UNAME_RELEASE" exit ;; @@ -269,26 +286,29 @@ *:Sortix:*:*) echo "$UNAME_MACHINE"-unknown-sortix exit ;; + *:Twizzler:*:*) + echo "$UNAME_MACHINE"-unknown-twizzler + exit ;; *:Redox:*:*) echo "$UNAME_MACHINE"-unknown-redox exit ;; mips:OSF1:*.*) - echo mips-dec-osf1 - exit ;; + echo mips-dec-osf1 + exit ;; alpha:OSF1:*:*) case $UNAME_RELEASE in *4.0) - UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $3}'` + UNAME_RELEASE=$(/usr/sbin/sizer -v | awk '{print $3}') ;; *5.*) - UNAME_RELEASE=`/usr/sbin/sizer -v | awk '{print $4}'` + UNAME_RELEASE=$(/usr/sbin/sizer -v | awk '{print $4}') ;; esac # According to Compaq, /usr/sbin/psrinfo has been available on # OSF/1 and Tru64 systems produced since 1995. I hope that # covers most systems running today. This code pipes the CPU # types through head -n 1, so we only detect the type of CPU 0. - ALPHA_CPU_TYPE=`/usr/sbin/psrinfo -v | sed -n -e 's/^ The alpha \(.*\) processor.*$/\1/p' | head -n 1` + 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 ;; @@ -326,7 +346,7 @@ # 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 @@ -360,7 +380,7 @@ exit ;; Pyramid*:OSx*:*:* | MIS*:OSx*:*:* | MIS*:SMP_DC-OSx*:*:*) # akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE. - if test "`(/bin/universe) 2>/dev/null`" = att ; then + if test "$( (/bin/universe) 2>/dev/null)" = att ; then echo pyramid-pyramid-sysv3 else echo pyramid-pyramid-bsd @@ -373,28 +393,28 @@ echo sparc-icl-nx6 exit ;; DRS?6000:UNIX_SV:4.2*:7* | DRS?6000:isis:4.2*:7*) - case `/usr/bin/uname -p` in + case $(/usr/bin/uname -p) 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" exit ;; i86pc:SunOS:5.*:* | i86xen:SunOS:5.*:*) - eval "$set_cc_for_build" + 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 test "$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) | \ grep IS_64BIT_ARCH >/dev/null @@ -402,30 +422,30 @@ 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 + case "$(/usr/bin/arch -k)" in Series*|S4*) - UNAME_RELEASE=`uname -v` + UNAME_RELEASE=$(uname -v) ;; 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" exit ;; sun*:*:4.2BSD:*) - UNAME_RELEASE=`(sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null` + UNAME_RELEASE=$( (sed 1q /etc/motd | awk '{print substr($5,1,3)}') 2>/dev/null) test "x$UNAME_RELEASE" = x && UNAME_RELEASE=3 - case "`/bin/arch`" in + case "$(/bin/arch)" in sun3) echo m68k-sun-sunos"$UNAME_RELEASE" ;; @@ -482,7 +502,7 @@ echo clipper-intergraph-clix"$UNAME_RELEASE" exit ;; mips:*:*:UMIPS | mips:*:*:RISCos) - eval "$set_cc_for_build" + set_cc_for_build sed 's/^ //' << EOF > "$dummy.c" #ifdef __cplusplus #include /* for printf() prototype */ @@ -505,8 +525,8 @@ } EOF $CC_FOR_BUILD -o "$dummy" "$dummy.c" && - dummyarg=`echo "$UNAME_RELEASE" | sed -n 's/\([0-9]*\).*/\1/p'` && - SYSTEM_NAME=`"$dummy" "$dummyarg"` && + 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" exit ;; @@ -533,11 +553,11 @@ exit ;; AViiON:dgux:*:*) # DG/UX returns AViiON for all architectures - UNAME_PROCESSOR=`/usr/bin/uname -p` - if [ "$UNAME_PROCESSOR" = mc88100 ] || [ "$UNAME_PROCESSOR" = mc88110 ] + UNAME_PROCESSOR=$(/usr/bin/uname -p) + if test "$UNAME_PROCESSOR" = mc88100 || test "$UNAME_PROCESSOR" = mc88110 then - if [ "$TARGET_BINARY_INTERFACE"x = m88kdguxelfx ] || \ - [ "$TARGET_BINARY_INTERFACE"x = x ] + if test "$TARGET_BINARY_INTERFACE"x = m88kdguxelfx || \ + test "$TARGET_BINARY_INTERFACE"x = x then echo m88k-dg-dgux"$UNAME_RELEASE" else @@ -561,17 +581,17 @@ 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 - exit ;; # Note that: echo "'`uname -s`'" gives 'AIX ' + exit ;; # Note that: echo "'$(uname -s)'" gives 'AIX ' i*86:AIX:*:*) echo i386-ibm-aix exit ;; ia64:AIX:*:*) - if [ -x /usr/bin/oslevel ] ; then - IBM_REV=`/usr/bin/oslevel` + if test -x /usr/bin/oslevel ; then + IBM_REV=$(/usr/bin/oslevel) else IBM_REV="$UNAME_VERSION.$UNAME_RELEASE" fi @@ -579,7 +599,7 @@ exit ;; *:AIX:2:3) if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then - eval "$set_cc_for_build" + set_cc_for_build sed 's/^ //' << EOF > "$dummy.c" #include @@ -591,7 +611,7 @@ 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 @@ -604,15 +624,15 @@ fi exit ;; *:AIX:*:[4567]) - IBM_CPU_ID=`/usr/sbin/lsdev -C -c processor -S available | sed 1q | awk '{ print $1 }'` + 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 IBM_ARCH=rs6000 else IBM_ARCH=powerpc fi - if [ -x /usr/bin/lslpp ] ; then - IBM_REV=`/usr/bin/lslpp -Lqc bos.rte.libc | - awk -F: '{ print $3 }' | sed s/[0-9]*$/0/` + if test -x /usr/bin/lslpp ; then + 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" fi @@ -640,14 +660,14 @@ echo m68k-hp-bsd4.4 exit ;; 9000/[34678]??:HP-UX:*:*) - HPUX_REV=`echo "$UNAME_RELEASE"|sed -e 's/[^.]*.[0B]*//'` + 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` + if test -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 @@ -659,8 +679,8 @@ esac ;; esac fi - if [ "$HP_ARCH" = "" ]; then - eval "$set_cc_for_build" + if test "$HP_ARCH" = ""; then + set_cc_for_build sed 's/^ //' << EOF > "$dummy.c" #define _HPUX_SOURCE @@ -694,13 +714,13 @@ 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 test "$HP_ARCH" = hppa2.0w then - eval "$set_cc_for_build" + 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 @@ -722,11 +742,11 @@ echo "$HP_ARCH"-hp-hpux"$HPUX_REV" exit ;; ia64:HP-UX:*:*) - HPUX_REV=`echo "$UNAME_RELEASE"|sed -e 's/[^.]*.[0B]*//'` + HPUX_REV=$(echo "$UNAME_RELEASE"|sed -e 's/[^.]*.[0B]*//') echo ia64-hp-hpux"$HPUX_REV" exit ;; 3050*:HI-UX:*:*) - eval "$set_cc_for_build" + set_cc_for_build sed 's/^ //' << EOF > "$dummy.c" #include int @@ -752,7 +772,7 @@ 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 ;; @@ -772,7 +792,7 @@ echo hppa1.0-hp-osf exit ;; i*86:OSF1:*:*) - if [ -x /usr/sbin/sysversion ] ; then + if test -x /usr/sbin/sysversion ; then echo "$UNAME_MACHINE"-unknown-osf1mk else echo "$UNAME_MACHINE"-unknown-osf1 @@ -821,14 +841,14 @@ 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:*:*) @@ -840,15 +860,26 @@ *:BSD/OS:*:*) echo "$UNAME_MACHINE"-unknown-bsdi"$UNAME_RELEASE" exit ;; + arm:FreeBSD:*:*) + UNAME_PROCESSOR=$(uname -p) + set_cc_for_build + if echo __ARM_PCS_VFP | $CC_FOR_BUILD -E - 2>/dev/null \ + | grep -q __ARM_PCS_VFP + then + echo "${UNAME_PROCESSOR}"-unknown-freebsd"$(echo ${UNAME_RELEASE}|sed -e 's/[-(].*//')"-gnueabi + else + echo "${UNAME_PROCESSOR}"-unknown-freebsd"$(echo ${UNAME_RELEASE}|sed -e 's/[-(].*//')"-gnueabihf + fi + exit ;; *:FreeBSD:*:*) - UNAME_PROCESSOR=`/usr/bin/uname -p` + UNAME_PROCESSOR=$(/usr/bin/uname -p) case "$UNAME_PROCESSOR" in amd64) UNAME_PROCESSOR=x86_64 ;; i386) UNAME_PROCESSOR=i586 ;; esac - echo "$UNAME_PROCESSOR"-unknown-freebsd"`echo "$UNAME_RELEASE"|sed -e 's/[-(].*//'`" + echo "$UNAME_PROCESSOR"-unknown-freebsd"$(echo "$UNAME_RELEASE"|sed -e 's/[-(].*//')" exit ;; i*:CYGWIN*:*) echo "$UNAME_MACHINE"-pc-cygwin @@ -881,18 +912,18 @@ echo "$UNAME_MACHINE"-pc-uwin exit ;; amd64:CYGWIN*:*:* | x86_64:CYGWIN*:*:*) - echo x86_64-unknown-cygwin + echo x86_64-pc-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 "[:upper:]" "[:lower:]"``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 ;; *:Minix:*:*) echo "$UNAME_MACHINE"-unknown-minix @@ -905,7 +936,7 @@ echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; alpha:Linux:*:*) - case `sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' < /proc/cpuinfo` in + case $(sed -n '/^cpu model/s/^.*: \(.*\)/\1/p' /proc/cpuinfo 2>/dev/null) in EV5) UNAME_MACHINE=alphaev5 ;; EV56) UNAME_MACHINE=alphaev56 ;; PCA56) UNAME_MACHINE=alphapca56 ;; @@ -922,7 +953,7 @@ echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; arm*:Linux:*:*) - eval "$set_cc_for_build" + set_cc_for_build if echo __ARM_EABI__ | $CC_FOR_BUILD -E - 2>/dev/null \ | grep -q __ARM_EABI__ then @@ -964,6 +995,9 @@ k1om:Linux:*:*) echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; + loongarch32:Linux:*:* | loongarch64:Linux:*:* | loongarchx32:Linux:*:*) + echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" + exit ;; m32r*:Linux:*:*) echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; @@ -971,23 +1005,51 @@ echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; mips:Linux:*:* | mips64:Linux:*:*) - eval "$set_cc_for_build" + set_cc_for_build + IS_GLIBC=0 + test x"${LIBC}" = xgnu && IS_GLIBC=1 sed 's/^ //' << EOF > "$dummy.c" #undef CPU - #undef ${UNAME_MACHINE} - #undef ${UNAME_MACHINE}el + #undef mips + #undef mipsel + #undef mips64 + #undef mips64el + #if ${IS_GLIBC} && defined(_ABI64) + LIBCABI=gnuabi64 + #else + #if ${IS_GLIBC} && defined(_ABIN32) + LIBCABI=gnuabin32 + #else + LIBCABI=${LIBC} + #endif + #endif + + #if ${IS_GLIBC} && defined(__mips64) && defined(__mips_isa_rev) && __mips_isa_rev>=6 + CPU=mipsisa64r6 + #else + #if ${IS_GLIBC} && !defined(__mips64) && defined(__mips_isa_rev) && __mips_isa_rev>=6 + CPU=mipsisa32r6 + #else + #if defined(__mips64) + CPU=mips64 + #else + CPU=mips + #endif + #endif + #endif + #if defined(__MIPSEL__) || defined(__MIPSEL) || defined(_MIPSEL) || defined(MIPSEL) - CPU=${UNAME_MACHINE}el + MIPS_ENDIAN=el #else #if defined(__MIPSEB__) || defined(__MIPSEB) || defined(_MIPSEB) || defined(MIPSEB) - CPU=${UNAME_MACHINE} + MIPS_ENDIAN= #else - CPU= + MIPS_ENDIAN= #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\|^MIPS_ENDIAN\|^LIBCABI')" + test "x$CPU" != x && { echo "$CPU${MIPS_ENDIAN}-unknown-linux-$LIBCABI"; exit; } ;; mips64el:Linux:*:*) echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" @@ -1006,7 +1068,7 @@ exit ;; parisc:Linux:*:* | hppa:Linux:*:*) # Look for CPU level - case `grep '^cpu[^a-z]*:' /proc/cpuinfo 2>/dev/null | cut -d' ' -f2` in + 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" ;; @@ -1024,7 +1086,7 @@ ppcle:Linux:*:*) echo powerpcle-unknown-linux-"$LIBC" exit ;; - riscv32:Linux:*:* | riscv64:Linux:*:*) + riscv32:Linux:*:* | riscv32be:Linux:*:* | riscv64:Linux:*:* | riscv64be:Linux:*:*) echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" exit ;; s390:Linux:*:* | s390x:Linux:*:*) @@ -1046,7 +1108,17 @@ echo "$UNAME_MACHINE"-dec-linux-"$LIBC" exit ;; x86_64:Linux:*:*) - echo "$UNAME_MACHINE"-pc-linux-"$LIBC" + set_cc_for_build + LIBCABI=$LIBC + if test "$CC_FOR_BUILD" != no_compiler_found; then + if (echo '#ifdef __ILP32__'; echo IS_X32; echo '#endif') | \ + (CCOPTS="" $CC_FOR_BUILD -E - 2>/dev/null) | \ + grep IS_X32 >/dev/null + then + LIBCABI="$LIBC"x32 + fi + fi + echo "$UNAME_MACHINE"-pc-linux-"$LIBCABI" exit ;; xtensa*:Linux:*:*) echo "$UNAME_MACHINE"-unknown-linux-"$LIBC" @@ -1086,7 +1158,7 @@ echo "$UNAME_MACHINE"-pc-msdosdjgpp exit ;; i*86:*:4.*:*) - UNAME_REL=`echo "$UNAME_RELEASE" | sed 's/\/MP$//'` + 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" else @@ -1095,19 +1167,19 @@ exit ;; i*86:*:5:[678]*) # UnixWare 7.x, OpenUNIX and OpenServer 6. - case `/bin/uname -X | grep "^Machine"` in + case $(/bin/uname -X | grep "^Machine") in *486*) UNAME_MACHINE=i486 ;; *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' /dev/null >/dev/null ; then - UNAME_REL=`(/bin/uname -X|grep Release|sed -e 's/.*= //')` + UNAME_REL=$( (/bin/uname -X|grep Release|sed -e 's/.*= //')) (/bin/uname -X|grep i80486 >/dev/null) && UNAME_MACHINE=i486 (/bin/uname -X|grep '^Machine.*Pentium' >/dev/null) \ && UNAME_MACHINE=i586 @@ -1157,7 +1229,7 @@ 3[345]??:*:4.0:3.0 | 3[34]??A:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 3[34]??/*:*:4.0:3.0 | 4400:*:4.0:3.0 | 4850:*:4.0:3.0 | SKA40:*:4.0:3.0 | SDS2:*:4.0:3.0 | SHG2:*:4.0:3.0 | S7501*:*:4.0:3.0) OS_REL='' test -r /etc/.relid \ - && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /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; } /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ @@ -1168,7 +1240,7 @@ NCR*:*:4.2:* | MPRAS*:*:4.2:*) OS_REL='.3' test -r /etc/.relid \ - && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /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; } /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ @@ -1201,7 +1273,7 @@ exit ;; *:SINIX-*:*:*) if uname -p 2>/dev/null >/dev/null ; then - UNAME_MACHINE=`(uname -p) 2>/dev/null` + UNAME_MACHINE=$( (uname -p) 2>/dev/null) echo "$UNAME_MACHINE"-sni-sysv4 else echo ns32k-sni-sysv @@ -1235,7 +1307,7 @@ echo mips-sony-newsos6 exit ;; R[34]000:*System_V*:*:* | R4000:UNIX_SYSV:*:* | R*000:UNIX_SV:*:*) - if [ -d /usr/nec ]; then + if test -d /usr/nec; then echo mips-nec-sysv"$UNAME_RELEASE" else echo mips-unknown-sysv"$UNAME_RELEASE" @@ -1283,44 +1355,48 @@ *:Rhapsody:*:*) echo "$UNAME_MACHINE"-apple-rhapsody"$UNAME_RELEASE" exit ;; + arm64:Darwin:*:*) + echo aarch64-apple-darwin"$UNAME_RELEASE" + exit ;; *:Darwin:*:*) - UNAME_PROCESSOR=`uname -p` || UNAME_PROCESSOR=unknown - 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 (echo '#ifdef __LP64__'; echo IS_64BIT_ARCH; echo '#endif') | \ - (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 + UNAME_PROCESSOR=$(uname -p) + case $UNAME_PROCESSOR in + unknown) UNAME_PROCESSOR=powerpc ;; + esac + if command -v xcode-select > /dev/null 2> /dev/null && \ + ! xcode-select --print-path > /dev/null 2> /dev/null ; then + # Avoid executing cc if there is no toolchain installed as + # cc will be a stub that puts up a graphical alert + # prompting the user to install developer tools. + CC_FOR_BUILD=no_compiler_found + else + set_cc_for_build + fi + if test "$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 + 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 elif test "$UNAME_PROCESSOR" = i386 ; then - # Avoid executing cc on OS X 10.9, as it ships with a stub - # that puts up a graphical alert prompting to install - # developer tools. Any system running Mac OS X 10.7 or - # later (Darwin 11 and later) is required to have a 64-bit - # processor. This is not true of the ARM version of Darwin - # that Apple uses in portable devices. - UNAME_PROCESSOR=x86_64 + # uname -m returns i386 or x86_64 + UNAME_PROCESSOR=$UNAME_MACHINE fi echo "$UNAME_PROCESSOR"-apple-darwin"$UNAME_RELEASE" exit ;; *:procnto*:*:* | *:QNX:[0123456789]*:*) - UNAME_PROCESSOR=`uname -p` + UNAME_PROCESSOR=$(uname -p) if test "$UNAME_PROCESSOR" = x86; then UNAME_PROCESSOR=i386 UNAME_MACHINE=pc @@ -1358,6 +1434,7 @@ # "uname -m" is not consistent, so use $cputype instead. 386 # is converted to i386 for consistency with other x86 # operating systems. + # shellcheck disable=SC2154 if test "$cputype" = 386; then UNAME_MACHINE=i386 else @@ -1387,10 +1464,10 @@ 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` + UNAME_MACHINE=$( (uname -p) 2>/dev/null) case "$UNAME_MACHINE" in A*) echo alpha-dec-vms ; exit ;; I*) echo ia64-dec-vms ; exit ;; @@ -1400,13 +1477,13 @@ 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 exit ;; - i*86:AROS:*:*) - echo "$UNAME_MACHINE"-pc-aros + *:AROS:*:*) + echo "$UNAME_MACHINE"-unknown-aros exit ;; x86_64:VMkernel:*:*) echo "$UNAME_MACHINE"-unknown-esx @@ -1414,8 +1491,148 @@ amd64:Isilon\ OneFS:*:*) echo x86_64-unknown-onefs exit ;; + *:Unleashed:*:*) + echo "$UNAME_MACHINE"-unknown-unleashed"$UNAME_RELEASE" + exit ;; esac +# No uname command or uname output not recognized. +set_cc_for_build +cat > "$dummy.c" < +#include +#endif +#if defined(ultrix) || defined(_ultrix) || defined(__ultrix) || defined(__ultrix__) +#if defined (vax) || defined (__vax) || defined (__vax__) || defined(mips) || defined(__mips) || defined(__mips__) || defined(MIPS) || defined(__MIPS__) +#include +#if defined(_SIZE_T_) || defined(SIGLOST) +#include +#endif +#endif +#endif +main () +{ +#if defined (sony) +#if defined (MIPSEB) + /* BFD wants "bsd" instead of "newsos". Perhaps BFD should be changed, + I don't know.... */ + printf ("mips-sony-bsd\n"); exit (0); +#else +#include + printf ("m68k-sony-newsos%s\n", +#ifdef NEWSOS4 + "4" +#else + "" +#endif + ); exit (0); +#endif +#endif + +#if defined (NeXT) +#if !defined (__ARCHITECTURE__) +#define __ARCHITECTURE__ "m68k" +#endif + int version; + version=$( (hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null); + if (version < 4) + printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version); + else + printf ("%s-next-openstep%d\n", __ARCHITECTURE__, version); + exit (0); +#endif + +#if defined (MULTIMAX) || defined (n16) +#if defined (UMAXV) + printf ("ns32k-encore-sysv\n"); exit (0); +#else +#if defined (CMU) + printf ("ns32k-encore-mach\n"); exit (0); +#else + printf ("ns32k-encore-bsd\n"); exit (0); +#endif +#endif +#endif + +#if defined (__386BSD__) + printf ("i386-pc-bsd\n"); exit (0); +#endif + +#if defined (sequent) +#if defined (i386) + printf ("i386-sequent-dynix\n"); exit (0); +#endif +#if defined (ns32000) + printf ("ns32k-sequent-dynix\n"); exit (0); +#endif +#endif + +#if defined (_SEQUENT_) + struct utsname un; + + uname(&un); + if (strncmp(un.version, "V2", 2) == 0) { + printf ("i386-sequent-ptx2\n"); exit (0); + } + if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */ + printf ("i386-sequent-ptx1\n"); exit (0); + } + printf ("i386-sequent-ptx\n"); exit (0); +#endif + +#if defined (vax) +#if !defined (ultrix) +#include +#if defined (BSD) +#if BSD == 43 + printf ("vax-dec-bsd4.3\n"); exit (0); +#else +#if BSD == 199006 + printf ("vax-dec-bsd4.3reno\n"); exit (0); +#else + printf ("vax-dec-bsd\n"); exit (0); +#endif +#endif +#else + printf ("vax-dec-bsd\n"); exit (0); +#endif +#else +#if defined(_SIZE_T_) || defined(SIGLOST) + struct utsname un; + uname (&un); + printf ("vax-dec-ultrix%s\n", un.release); exit (0); +#else + printf ("vax-dec-ultrix\n"); exit (0); +#endif +#endif +#endif +#if defined(ultrix) || defined(_ultrix) || defined(__ultrix) || defined(__ultrix__) +#if defined(mips) || defined(__mips) || defined(__mips__) || defined(MIPS) || defined(__MIPS__) +#if defined(_SIZE_T_) || defined(SIGLOST) + struct utsname *un; + uname (&un); + printf ("mips-dec-ultrix%s\n", un.release); exit (0); +#else + printf ("mips-dec-ultrix\n"); exit (0); +#endif +#endif +#endif + +#if defined (alliant) && defined (i860) + printf ("i860-alliant-bsd\n"); exit (0); +#endif + + exit (1); +} +EOF + +$CC_FOR_BUILD -o "$dummy" "$dummy.c" 2>/dev/null && SYSTEM_NAME=$($dummy) && + { echo "$SYSTEM_NAME"; exit; } + +# Apollos put the system type in the environment. +test -d /usr/apollo && { echo "$ISP-apollo-$SYSTYPE"; exit; } + echo "$0: unable to guess system type" >&2 case "$UNAME_MACHINE:$UNAME_SYSTEM" in @@ -1435,9 +1652,15 @@ operating system you are using. If your script is old, overwrite *all* copies of config.guess and config.sub with the latest versions from: - https://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.guess + https://git.savannah.gnu.org/cgit/config.git/plain/config.guess and - https://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub + https://git.savannah.gnu.org/cgit/config.git/plain/config.sub +EOF + +year=$(echo $timestamp | sed 's,-.*,,') +# shellcheck disable=SC2003 +if test "$(expr "$(date +%Y)" - "$year")" -lt 3 ; then + cat >&2 </dev/null || echo unknown` -uname -r = `(uname -r) 2>/dev/null || echo unknown` -uname -s = `(uname -s) 2>/dev/null || echo unknown` -uname -v = `(uname -v) 2>/dev/null || echo unknown` - -/usr/bin/uname -p = `(/usr/bin/uname -p) 2>/dev/null` -/bin/uname -X = `(/bin/uname -X) 2>/dev/null` - -hostinfo = `(hostinfo) 2>/dev/null` -/bin/universe = `(/bin/universe) 2>/dev/null` -/usr/bin/arch -k = `(/usr/bin/arch -k) 2>/dev/null` -/bin/arch = `(/bin/arch) 2>/dev/null` -/usr/bin/oslevel = `(/usr/bin/oslevel) 2>/dev/null` -/usr/convex/getsysinfo = `(/usr/convex/getsysinfo) 2>/dev/null` +uname -m = $( (uname -m) 2>/dev/null || echo unknown) +uname -r = $( (uname -r) 2>/dev/null || echo unknown) +uname -s = $( (uname -s) 2>/dev/null || echo unknown) +uname -v = $( (uname -v) 2>/dev/null || echo unknown) + +/usr/bin/uname -p = $( (/usr/bin/uname -p) 2>/dev/null) +/bin/uname -X = $( (/bin/uname -X) 2>/dev/null) + +hostinfo = $( (hostinfo) 2>/dev/null) +/bin/universe = $( (/bin/universe) 2>/dev/null) +/usr/bin/arch -k = $( (/usr/bin/arch -k) 2>/dev/null) +/bin/arch = $( (/bin/arch) 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" EOF +fi exit 1 diff -Nru tcpslice-1.3/config.sub tcpslice-1.5/config.sub --- tcpslice-1.3/config.sub 2020-08-19 18:16:16.000000000 +0000 +++ tcpslice-1.5/config.sub 2021-10-07 12:13:20.000000000 +0000 @@ -1,8 +1,8 @@ #! /bin/sh # Configuration validation subroutine script. -# Copyright 1992-2018 Free Software Foundation, Inc. +# Copyright 1992-2021 Free Software Foundation, Inc. -timestamp='2018-07-03' +timestamp='2021-03-10' # 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 @@ -33,7 +33,7 @@ # Otherwise, we print the canonical config type on stdout and succeed. # You can get the latest version of this script from: -# https://git.savannah.gnu.org/gitweb/?p=config.git;a=blob_plain;f=config.sub +# https://git.savannah.gnu.org/cgit/config.git/plain/config.sub # This file is supposed to be the same for all GNU packages # and recognize all the CPU types, system types and aliases @@ -50,7 +50,7 @@ # CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM # It is wrong to echo any other type of specification. -me=`echo "$0" | sed -e 's,.*/,,'` +me=$(echo "$0" | sed -e 's,.*/,,') usage="\ Usage: $0 [OPTION] CPU-MFR-OPSYS or ALIAS @@ -67,7 +67,7 @@ version="\ GNU config.sub ($timestamp) -Copyright 1992-2018 Free Software Foundation, Inc. +Copyright 1992-2021 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." @@ -89,7 +89,7 @@ - ) # Use stdin as input. break ;; -* ) - echo "$me: invalid option $1$help" + echo "$me: invalid option $1$help" >&2 exit 1 ;; *local*) @@ -111,7 +111,8 @@ esac # Split fields of configuration type -IFS="-" read -r field1 field2 field3 field4 <&2 - exit 1 + # Recognize the canonical CPU types that are allowed with any + # company name. + case $cpu in + 1750a | 580 \ + | a29k \ + | aarch64 | aarch64_be \ + | abacus \ + | alpha | alphaev[4-8] | alphaev56 | alphaev6[78] \ + | alpha64 | alpha64ev[4-8] | alpha64ev56 | alpha64ev6[78] \ + | alphapca5[67] | alpha64pca5[67] \ + | am33_2.0 \ + | amdgcn \ + | arc | arceb \ + | arm | arm[lb]e | arme[lb] | armv* \ + | avr | avr32 \ + | asmjs \ + | ba \ + | be32 | be64 \ + | bfin | bpf | bs2000 \ + | c[123]* | c30 | [cjt]90 | c4x \ + | c8051 | clipper | craynv | csky | cydra \ + | d10v | d30v | dlx | dsp16xx \ + | e2k | elxsi | epiphany \ + | f30[01] | f700 | fido | fr30 | frv | ft32 | fx80 \ + | h8300 | h8500 \ + | hppa | hppa1.[01] | hppa2.0 | hppa2.0[nw] | hppa64 \ + | hexagon \ + | i370 | i*86 | i860 | i960 | ia16 | ia64 \ + | ip2k | iq2000 \ + | k1om \ + | le32 | le64 \ + | lm32 \ + | loongarch32 | loongarch64 | loongarchx32 \ + | m32c | m32r | m32rle \ + | m5200 | m68000 | m680[012346]0 | m68360 | m683?2 | m68k \ + | m6811 | m68hc11 | m6812 | m68hc12 | m68hcs12x \ + | m88110 | m88k | maxq | mb | mcore | mep | metag \ + | microblaze | microblazeel \ + | mips | mipsbe | mipseb | mipsel | mipsle \ + | mips16 \ + | mips64 | mips64eb | mips64el \ + | mips64octeon | mips64octeonel \ + | mips64orion | mips64orionel \ + | mips64r5900 | mips64r5900el \ + | mips64vr | mips64vrel \ + | mips64vr4100 | mips64vr4100el \ + | mips64vr4300 | mips64vr4300el \ + | mips64vr5000 | mips64vr5000el \ + | mips64vr5900 | mips64vr5900el \ + | mipsisa32 | mipsisa32el \ + | mipsisa32r2 | mipsisa32r2el \ + | mipsisa32r6 | mipsisa32r6el \ + | mipsisa64 | mipsisa64el \ + | mipsisa64r2 | mipsisa64r2el \ + | mipsisa64r6 | mipsisa64r6el \ + | mipsisa64sb1 | mipsisa64sb1el \ + | mipsisa64sr71k | mipsisa64sr71kel \ + | mipsr5900 | mipsr5900el \ + | mipstx39 | mipstx39el \ + | mmix \ + | mn10200 | mn10300 \ + | moxie \ + | mt \ + | msp430 \ + | nds32 | nds32le | nds32be \ + | nfp \ + | nios | nios2 | nios2eb | nios2el \ + | none | np1 | ns16k | ns32k | nvptx \ + | open8 \ + | or1k* \ + | or32 \ + | orion \ + | picochip \ + | pdp10 | pdp11 | pj | pjl | pn | power \ + | powerpc | powerpc64 | powerpc64le | powerpcle | powerpcspe \ + | pru \ + | pyramid \ + | riscv | riscv32 | riscv32be | riscv64 | riscv64be \ + | rl78 | romp | rs6000 | rx \ + | s390 | s390x \ + | score \ + | sh | shl \ + | sh[1234] | sh[24]a | sh[24]ae[lb] | sh[23]e | she[lb] | sh[lb]e \ + | sh[1234]e[lb] | sh[12345][lb]e | sh[23]ele | sh64 | sh64le \ + | sparc | sparc64 | sparc64b | sparc64v | sparc86x | sparclet \ + | sparclite \ + | sparcv8 | sparcv9 | sparcv9b | sparcv9v | sv1 | sx* \ + | spu \ + | tahoe \ + | thumbv7* \ + | tic30 | tic4x | tic54x | tic55x | tic6x | tic80 \ + | tron \ + | ubicom32 \ + | v70 | v850 | v850e | v850e1 | v850es | v850e2 | v850e2v3 \ + | vax \ + | visium \ + | w65 \ + | wasm32 | wasm64 \ + | we32k \ + | x86 | x86_64 | xc16x | xgate | xps100 \ + | xstormy16 | xtensa* \ + | ymp \ + | z8k | z80) + ;; + + *) + echo Invalid configuration \`"$1"\': machine \`"$cpu-$vendor"\' not recognized 1>&2 + exit 1 + ;; + esac ;; esac # Here we canonicalize certain aliases for manufacturers. -case $basic_machine in - *-digital*) - basic_machine=`echo "$basic_machine" | sed 's/digital.*/dec/'` +case $vendor in + digital*) + vendor=dec ;; - *-commodore*) - basic_machine=`echo "$basic_machine" | sed 's/commodore.*/cbm/'` + commodore*) + vendor=cbm ;; *) ;; @@ -1286,8 +1280,47 @@ # Decode manufacturer-specific aliases for certain operating systems. -if [ x$os != x ] +if test x$basic_os != x then + +# First recognize some ad-hoc caes, or perhaps split kernel-os, or else just +# set os. +case $basic_os in + gnu/linux*) + kernel=linux + os=$(echo $basic_os | sed -e 's|gnu/linux|gnu|') + ;; + os2-emx) + kernel=os2 + os=$(echo $basic_os | sed -e 's|os2-emx|emx|') + ;; + nto-qnx*) + kernel=nto + os=$(echo $basic_os | sed -e 's|nto-qnx|qnx|') + ;; + *-*) + # shellcheck disable=SC2162 + IFS="-" read kernel os <&2 - exit 1 + # No normalization, but not necessarily accepted, that comes below. ;; esac + else # Here we handle the default operating systems that come with various machines. @@ -1541,7 +1499,8 @@ # will signal an error saying that MANUFACTURER isn't an operating # system, and we'll never get to this point. -case $basic_machine in +kernel= +case $cpu-$vendor in score-*) os=elf ;; @@ -1552,7 +1511,8 @@ os=riscix1.2 ;; arm*-rebel) - os=linux + kernel=linux + os=gnu ;; arm*-semi) os=aout @@ -1718,86 +1678,178 @@ os=none ;; esac + fi +# Now, validate our (potentially fixed-up) OS. +case $os in + # Sometimes we do "kernel-libc", so those need to count as OSes. + musl* | newlib* | uclibc*) + ;; + # Likewise for "kernel-abi" + eabi* | gnueabi*) + ;; + # VxWorks passes extra cpu info in the 4th filed. + simlinux | simwindows | spe) + ;; + # Now accept the basic system types. + # The portable systems comes first. + # Each alternative MUST end in a * to match a version number. + gnu* | android* | bsd* | mach* | minix* | genix* | ultrix* | irix* \ + | *vms* | esix* | aix* | cnk* | sunos | sunos[34]* \ + | hpux* | unos* | osf* | luna* | dgux* | auroraux* | solaris* \ + | sym* | plan9* | psp* | sim* | xray* | os68k* | v88r* \ + | hiux* | abug | nacl* | netware* | windows* \ + | os9* | macos* | osx* | ios* \ + | mpw* | magic* | mmixware* | mon960* | lnews* \ + | amigaos* | amigados* | msdos* | newsos* | unicos* | aof* \ + | aos* | aros* | cloudabi* | sortix* | twizzler* \ + | nindy* | vxsim* | vxworks* | ebmon* | hms* | mvs* \ + | clix* | riscos* | uniplus* | iris* | isc* | rtu* | xenix* \ + | mirbsd* | netbsd* | dicos* | openedition* | ose* \ + | bitrig* | openbsd* | solidbsd* | libertybsd* | os108* \ + | ekkobsd* | freebsd* | riscix* | lynxos* | os400* \ + | bosx* | nextstep* | cxux* | aout* | elf* | oabi* \ + | ptx* | coff* | ecoff* | winnt* | domain* | vsta* \ + | udi* | lites* | ieee* | go32* | aux* | hcos* \ + | chorusrdb* | cegcc* | glidix* | serenity* \ + | cygwin* | msys* | pe* | moss* | proelf* | rtems* \ + | midipix* | mingw32* | mingw64* | mint* \ + | 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* \ + | scout* | superux* | sysv* | rtmk* | tpf* | windiss* \ + | powermax* | dnix* | nx6 | nx7 | sei* | dragonfly* \ + | skyos* | haiku* | rdos* | toppers* | drops* | es* \ + | onefs* | tirtos* | phoenix* | fuchsia* | redox* | bme* \ + | midnightbsd* | amdhsa* | unleashed* | emscripten* | wasi* \ + | nsk* | powerunix* | genode* | zvmoe* | qnx* | emx*) + ;; + # This one is extra strict with allowed versions + sco3.2v2 | sco3.2v[4-9]* | sco5v6*) + # Don't forget version if it is 3.2v4 or newer. + ;; + none) + ;; + *) + echo Invalid configuration \`"$1"\': OS \`"$os"\' not recognized 1>&2 + exit 1 + ;; +esac + +# As a final step for OS-related things, validate the OS-kernel combination +# (given a valid OS), if there is a kernel. +case $kernel-$os in + linux-gnu* | linux-dietlibc* | linux-android* | linux-newlib* | linux-musl* | linux-uclibc* ) + ;; + uclinux-uclibc* ) + ;; + -dietlibc* | -newlib* | -musl* | -uclibc* ) + # These are just libc implementations, not actual OSes, and thus + # require a kernel. + echo "Invalid configuration \`$1': libc \`$os' needs explicit kernel." 1>&2 + exit 1 + ;; + kfreebsd*-gnu* | kopensolaris*-gnu*) + ;; + vxworks-simlinux | vxworks-simwindows | vxworks-spe) + ;; + nto-qnx*) + ;; + os2-emx) + ;; + *-eabi* | *-gnueabi*) + ;; + -*) + # Blank kernel with real OS is always fine. + ;; + *-*) + echo "Invalid configuration \`$1': Kernel \`$kernel' not known to work with OS \`$os'." 1>&2 + exit 1 + ;; +esac + # Here we handle the case where we know the os, and the CPU type, but not the # manufacturer. We pick the logical manufacturer. -vendor=unknown -case $basic_machine in - *-unknown) - case $os in - riscix*) +case $vendor in + unknown) + case $cpu-$os in + *-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 ;; - clix*) + *-clix*) vendor=intergraph ;; - mvs* | opened*) + *-mvs* | *-opened*) + vendor=ibm + ;; + *-os400*) vendor=ibm ;; - os400*) + s390-* | s390x-*) 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/"` ;; esac -echo "$basic_machine-$os" +echo "$cpu-$vendor-${kernel:+$kernel-}$os" exit # Local variables: diff -Nru tcpslice-1.3/configure tcpslice-1.5/configure --- tcpslice-1.3/configure 2020-08-19 18:16:16.000000000 +0000 +++ tcpslice-1.5/configure 2021-12-30 20:54:45.000000000 +0000 @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.69 for tcpslice 1.3. +# Generated by GNU Autoconf 2.69 for tcpslice 1.5. # # # Copyright (C) 1992-1996, 1998-2012 Free Software Foundation, Inc. @@ -577,8 +577,8 @@ # Identity of this package. PACKAGE_NAME='tcpslice' PACKAGE_TARNAME='tcpslice' -PACKAGE_VERSION='1.3' -PACKAGE_STRING='tcpslice 1.3' +PACKAGE_VERSION='1.5' +PACKAGE_STRING='tcpslice 1.5' PACKAGE_BUGREPORT='' PACKAGE_URL='' @@ -670,6 +670,7 @@ docdir oldincludedir includedir +runstatedir localstatedir sharedstatedir sysconfdir @@ -743,6 +744,7 @@ sysconfdir='${prefix}/etc' sharedstatedir='${prefix}/com' localstatedir='${prefix}/var' +runstatedir='${localstatedir}/run' includedir='${prefix}/include' oldincludedir='/usr/include' docdir='${datarootdir}/doc/${PACKAGE_TARNAME}' @@ -995,6 +997,15 @@ | -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=* \ @@ -1132,7 +1143,7 @@ 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. @@ -1245,7 +1256,7 @@ # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures tcpslice 1.3 to adapt to many kinds of systems. +\`configure' configures tcpslice 1.5 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1285,6 +1296,7 @@ --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] @@ -1310,7 +1322,7 @@ if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of tcpslice 1.3:";; + short | recursive ) echo "Configuration of tcpslice 1.5:";; esac cat <<\_ACEOF @@ -1402,7 +1414,7 @@ test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -tcpslice configure 1.3 +tcpslice configure 1.5 generated by GNU Autoconf 2.69 Copyright (C) 2012 Free Software Foundation, Inc. @@ -1821,7 +1833,7 @@ This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by tcpslice $as_me 1.3, which was +It was created by tcpslice $as_me 1.5, which was generated by GNU Autoconf 2.69. Invocation command line was $ $0 $@ @@ -3993,7 +4005,7 @@ We can't simply define LARGE_OFF_T to be 9223372036854775807, since some C++ compilers masquerading as C compilers incorrectly reject 9223372036854775807. */ -#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) +#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31)) int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 && LARGE_OFF_T % 2147483647 == 1) ? 1 : -1]; @@ -4039,7 +4051,7 @@ We can't simply define LARGE_OFF_T to be 9223372036854775807, since some C++ compilers masquerading as C compilers incorrectly reject 9223372036854775807. */ -#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) +#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31)) int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 && LARGE_OFF_T % 2147483647 == 1) ? 1 : -1]; @@ -4063,7 +4075,7 @@ We can't simply define LARGE_OFF_T to be 9223372036854775807, since some C++ compilers masquerading as C compilers incorrectly reject 9223372036854775807. */ -#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) +#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31)) int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 && LARGE_OFF_T % 2147483647 == 1) ? 1 : -1]; @@ -4108,7 +4120,7 @@ We can't simply define LARGE_OFF_T to be 9223372036854775807, since some C++ compilers masquerading as C compilers incorrectly reject 9223372036854775807. */ -#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) +#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31)) int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 && LARGE_OFF_T % 2147483647 == 1) ? 1 : -1]; @@ -4132,7 +4144,7 @@ We can't simply define LARGE_OFF_T to be 9223372036854775807, since some C++ compilers masquerading as C compilers incorrectly reject 9223372036854775807. */ -#define LARGE_OFF_T (((off_t) 1 << 62) - 1 + ((off_t) 1 << 62)) +#define LARGE_OFF_T ((((off_t) 1 << 31) << 31) - 1 + (((off_t) 1 << 31) << 31)) int off_t_is_large[(LARGE_OFF_T % 2147483629 == 721 && LARGE_OFF_T % 2147483647 == 1) ? 1 : -1]; @@ -5366,67 +5378,39 @@ # if test "$ac_lbl_cc_dont_try_gcc_dashW" != yes; then - { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the compiler fails when given an unknown warning option" >&5 -$as_echo_n "checking whether the compiler fails when given an unknown warning option... " >&6; } - save_CFLAGS="$CFLAGS" - CFLAGS="$CFLAGS -Wxyzzy-this-will-never-succeed-xyzzy" - cat confdefs.h - <<_ACEOF >conftest.$ac_ext -/* end confdefs.h. */ - -int -main () -{ -return 0 - ; - return 0; -} -_ACEOF -if ac_fn_c_try_compile "$LINENO"; then : - - { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 -$as_echo "no" >&6; } - # - # We're assuming this is clang, where - # -Werror=unknown-warning-option is the appropriate - # option to force the compiler to fail. - # - ac_lbl_unknown_warning_option_error="-Werror=unknown-warning-option" - -else - - { $as_echo "$as_me:${as_lineno-$LINENO}: result: yes" >&5 -$as_echo "yes" >&6; } - -fi -rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext - CFLAGS="$save_CFLAGS" - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the compiler supports the -W option" >&5 $as_echo_n "checking whether the compiler supports the -W option... " >&6; } save_CFLAGS="$CFLAGS" - if expr "x-W" : "x-W.*" >/dev/null - then - CFLAGS="$CFLAGS $ac_lbl_unknown_warning_option_error -W" - elif expr "x-W" : "x-f.*" >/dev/null - then - CFLAGS="$CFLAGS -Werror -W" - elif expr "x-W" : "x-m.*" >/dev/null - then - CFLAGS="$CFLAGS -Werror -W" - else - CFLAGS="$CFLAGS -W" - fi + CFLAGS="$CFLAGS -W" + # + # XXX - yes, this depends on the way AC_LANG_WERROR works, + # but no mechanism is provided to turn AC_LANG_WERROR on + # *and then turn it back off*, so that we *only* do it when + # testing compiler options - 15 years after somebody asked + # for it: + # + # https://autoconf.gnu.narkive.com/gTAVmfKD/how-to-cancel-flags-set-by-ac-lang-werror + # + save_ac_c_werror_flag="$ac_c_werror_flag" + ac_c_werror_flag=yes + # + # We use AC_LANG_SOURCE() so that we can control the complete + # content of the program being compiled. We do not, for example, + # want the default "int main()" that AC_LANG_PROGRAM() generates, + # as it will generate a warning with -Wold-style-definition, meaning + # that we would treat it as not working, as the test will fail if + # *any* error output, including a warning due to the flag we're + # testing, is generated; see + # + # https://www.postgresql.org/message-id/2192993.1591682589%40sss.pgh.pa.us + # https://www.postgresql.org/message-id/2192993.1591682589%40sss.pgh.pa.us + # + # This may, as per those two messages, be fixed in autoonf 2.70, + # but we only require 2.64 or newer for now. + # cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ - -int -main () -{ -return 0 - ; - return 0; -} +int main(void) { return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : @@ -5443,33 +5427,42 @@ fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + ac_c_werror_flag="$save_ac_c_werror_flag" { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the compiler supports the -Wall option" >&5 $as_echo_n "checking whether the compiler supports the -Wall option... " >&6; } save_CFLAGS="$CFLAGS" - if expr "x-Wall" : "x-W.*" >/dev/null - then - CFLAGS="$CFLAGS $ac_lbl_unknown_warning_option_error -Wall" - elif expr "x-Wall" : "x-f.*" >/dev/null - then - CFLAGS="$CFLAGS -Werror -Wall" - elif expr "x-Wall" : "x-m.*" >/dev/null - then - CFLAGS="$CFLAGS -Werror -Wall" - else - CFLAGS="$CFLAGS -Wall" - fi + CFLAGS="$CFLAGS -Wall" + # + # XXX - yes, this depends on the way AC_LANG_WERROR works, + # but no mechanism is provided to turn AC_LANG_WERROR on + # *and then turn it back off*, so that we *only* do it when + # testing compiler options - 15 years after somebody asked + # for it: + # + # https://autoconf.gnu.narkive.com/gTAVmfKD/how-to-cancel-flags-set-by-ac-lang-werror + # + save_ac_c_werror_flag="$ac_c_werror_flag" + ac_c_werror_flag=yes + # + # We use AC_LANG_SOURCE() so that we can control the complete + # content of the program being compiled. We do not, for example, + # want the default "int main()" that AC_LANG_PROGRAM() generates, + # as it will generate a warning with -Wold-style-definition, meaning + # that we would treat it as not working, as the test will fail if + # *any* error output, including a warning due to the flag we're + # testing, is generated; see + # + # https://www.postgresql.org/message-id/2192993.1591682589%40sss.pgh.pa.us + # https://www.postgresql.org/message-id/2192993.1591682589%40sss.pgh.pa.us + # + # This may, as per those two messages, be fixed in autoonf 2.70, + # but we only require 2.64 or newer for now. + # cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ - -int -main () -{ -return 0 - ; - return 0; -} +int main(void) { return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : @@ -5486,33 +5479,42 @@ fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + ac_c_werror_flag="$save_ac_c_werror_flag" { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the compiler supports the -Wassign-enum option" >&5 $as_echo_n "checking whether the compiler supports the -Wassign-enum option... " >&6; } save_CFLAGS="$CFLAGS" - if expr "x-Wassign-enum" : "x-W.*" >/dev/null - then - CFLAGS="$CFLAGS $ac_lbl_unknown_warning_option_error -Wassign-enum" - elif expr "x-Wassign-enum" : "x-f.*" >/dev/null - then - CFLAGS="$CFLAGS -Werror -Wassign-enum" - elif expr "x-Wassign-enum" : "x-m.*" >/dev/null - then - CFLAGS="$CFLAGS -Werror -Wassign-enum" - else - CFLAGS="$CFLAGS -Wassign-enum" - fi + CFLAGS="$CFLAGS -Wassign-enum" + # + # XXX - yes, this depends on the way AC_LANG_WERROR works, + # but no mechanism is provided to turn AC_LANG_WERROR on + # *and then turn it back off*, so that we *only* do it when + # testing compiler options - 15 years after somebody asked + # for it: + # + # https://autoconf.gnu.narkive.com/gTAVmfKD/how-to-cancel-flags-set-by-ac-lang-werror + # + save_ac_c_werror_flag="$ac_c_werror_flag" + ac_c_werror_flag=yes + # + # We use AC_LANG_SOURCE() so that we can control the complete + # content of the program being compiled. We do not, for example, + # want the default "int main()" that AC_LANG_PROGRAM() generates, + # as it will generate a warning with -Wold-style-definition, meaning + # that we would treat it as not working, as the test will fail if + # *any* error output, including a warning due to the flag we're + # testing, is generated; see + # + # https://www.postgresql.org/message-id/2192993.1591682589%40sss.pgh.pa.us + # https://www.postgresql.org/message-id/2192993.1591682589%40sss.pgh.pa.us + # + # This may, as per those two messages, be fixed in autoonf 2.70, + # but we only require 2.64 or newer for now. + # cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ - -int -main () -{ -return 0 - ; - return 0; -} +int main(void) { return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : @@ -5529,33 +5531,42 @@ fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + ac_c_werror_flag="$save_ac_c_werror_flag" { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the compiler supports the -Wcast-qual option" >&5 $as_echo_n "checking whether the compiler supports the -Wcast-qual option... " >&6; } save_CFLAGS="$CFLAGS" - if expr "x-Wcast-qual" : "x-W.*" >/dev/null - then - CFLAGS="$CFLAGS $ac_lbl_unknown_warning_option_error -Wcast-qual" - elif expr "x-Wcast-qual" : "x-f.*" >/dev/null - then - CFLAGS="$CFLAGS -Werror -Wcast-qual" - elif expr "x-Wcast-qual" : "x-m.*" >/dev/null - then - CFLAGS="$CFLAGS -Werror -Wcast-qual" - else - CFLAGS="$CFLAGS -Wcast-qual" - fi + CFLAGS="$CFLAGS -Wcast-qual" + # + # XXX - yes, this depends on the way AC_LANG_WERROR works, + # but no mechanism is provided to turn AC_LANG_WERROR on + # *and then turn it back off*, so that we *only* do it when + # testing compiler options - 15 years after somebody asked + # for it: + # + # https://autoconf.gnu.narkive.com/gTAVmfKD/how-to-cancel-flags-set-by-ac-lang-werror + # + save_ac_c_werror_flag="$ac_c_werror_flag" + ac_c_werror_flag=yes + # + # We use AC_LANG_SOURCE() so that we can control the complete + # content of the program being compiled. We do not, for example, + # want the default "int main()" that AC_LANG_PROGRAM() generates, + # as it will generate a warning with -Wold-style-definition, meaning + # that we would treat it as not working, as the test will fail if + # *any* error output, including a warning due to the flag we're + # testing, is generated; see + # + # https://www.postgresql.org/message-id/2192993.1591682589%40sss.pgh.pa.us + # https://www.postgresql.org/message-id/2192993.1591682589%40sss.pgh.pa.us + # + # This may, as per those two messages, be fixed in autoonf 2.70, + # but we only require 2.64 or newer for now. + # cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ - -int -main () -{ -return 0 - ; - return 0; -} +int main(void) { return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : @@ -5572,33 +5583,42 @@ fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + ac_c_werror_flag="$save_ac_c_werror_flag" { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the compiler supports the -Wmissing-prototypes option" >&5 $as_echo_n "checking whether the compiler supports the -Wmissing-prototypes option... " >&6; } save_CFLAGS="$CFLAGS" - if expr "x-Wmissing-prototypes" : "x-W.*" >/dev/null - then - CFLAGS="$CFLAGS $ac_lbl_unknown_warning_option_error -Wmissing-prototypes" - elif expr "x-Wmissing-prototypes" : "x-f.*" >/dev/null - then - CFLAGS="$CFLAGS -Werror -Wmissing-prototypes" - elif expr "x-Wmissing-prototypes" : "x-m.*" >/dev/null - then - CFLAGS="$CFLAGS -Werror -Wmissing-prototypes" - else - CFLAGS="$CFLAGS -Wmissing-prototypes" - fi + CFLAGS="$CFLAGS -Wmissing-prototypes" + # + # XXX - yes, this depends on the way AC_LANG_WERROR works, + # but no mechanism is provided to turn AC_LANG_WERROR on + # *and then turn it back off*, so that we *only* do it when + # testing compiler options - 15 years after somebody asked + # for it: + # + # https://autoconf.gnu.narkive.com/gTAVmfKD/how-to-cancel-flags-set-by-ac-lang-werror + # + save_ac_c_werror_flag="$ac_c_werror_flag" + ac_c_werror_flag=yes + # + # We use AC_LANG_SOURCE() so that we can control the complete + # content of the program being compiled. We do not, for example, + # want the default "int main()" that AC_LANG_PROGRAM() generates, + # as it will generate a warning with -Wold-style-definition, meaning + # that we would treat it as not working, as the test will fail if + # *any* error output, including a warning due to the flag we're + # testing, is generated; see + # + # https://www.postgresql.org/message-id/2192993.1591682589%40sss.pgh.pa.us + # https://www.postgresql.org/message-id/2192993.1591682589%40sss.pgh.pa.us + # + # This may, as per those two messages, be fixed in autoonf 2.70, + # but we only require 2.64 or newer for now. + # cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ - -int -main () -{ -return 0 - ; - return 0; -} +int main(void) { return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : @@ -5615,33 +5635,42 @@ fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + ac_c_werror_flag="$save_ac_c_werror_flag" { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the compiler supports the -Wold-style-definition option" >&5 $as_echo_n "checking whether the compiler supports the -Wold-style-definition option... " >&6; } save_CFLAGS="$CFLAGS" - if expr "x-Wold-style-definition" : "x-W.*" >/dev/null - then - CFLAGS="$CFLAGS $ac_lbl_unknown_warning_option_error -Wold-style-definition" - elif expr "x-Wold-style-definition" : "x-f.*" >/dev/null - then - CFLAGS="$CFLAGS -Werror -Wold-style-definition" - elif expr "x-Wold-style-definition" : "x-m.*" >/dev/null - then - CFLAGS="$CFLAGS -Werror -Wold-style-definition" - else - CFLAGS="$CFLAGS -Wold-style-definition" - fi + CFLAGS="$CFLAGS -Wold-style-definition" + # + # XXX - yes, this depends on the way AC_LANG_WERROR works, + # but no mechanism is provided to turn AC_LANG_WERROR on + # *and then turn it back off*, so that we *only* do it when + # testing compiler options - 15 years after somebody asked + # for it: + # + # https://autoconf.gnu.narkive.com/gTAVmfKD/how-to-cancel-flags-set-by-ac-lang-werror + # + save_ac_c_werror_flag="$ac_c_werror_flag" + ac_c_werror_flag=yes + # + # We use AC_LANG_SOURCE() so that we can control the complete + # content of the program being compiled. We do not, for example, + # want the default "int main()" that AC_LANG_PROGRAM() generates, + # as it will generate a warning with -Wold-style-definition, meaning + # that we would treat it as not working, as the test will fail if + # *any* error output, including a warning due to the flag we're + # testing, is generated; see + # + # https://www.postgresql.org/message-id/2192993.1591682589%40sss.pgh.pa.us + # https://www.postgresql.org/message-id/2192993.1591682589%40sss.pgh.pa.us + # + # This may, as per those two messages, be fixed in autoonf 2.70, + # but we only require 2.64 or newer for now. + # cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ - -int -main () -{ -return 0 - ; - return 0; -} +int main(void) { return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : @@ -5658,33 +5687,42 @@ fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + ac_c_werror_flag="$save_ac_c_werror_flag" { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the compiler supports the -Wpedantic option" >&5 $as_echo_n "checking whether the compiler supports the -Wpedantic option... " >&6; } save_CFLAGS="$CFLAGS" - if expr "x-Wpedantic" : "x-W.*" >/dev/null - then - CFLAGS="$CFLAGS $ac_lbl_unknown_warning_option_error -Wpedantic" - elif expr "x-Wpedantic" : "x-f.*" >/dev/null - then - CFLAGS="$CFLAGS -Werror -Wpedantic" - elif expr "x-Wpedantic" : "x-m.*" >/dev/null - then - CFLAGS="$CFLAGS -Werror -Wpedantic" - else - CFLAGS="$CFLAGS -Wpedantic" - fi + CFLAGS="$CFLAGS -Wpedantic" + # + # XXX - yes, this depends on the way AC_LANG_WERROR works, + # but no mechanism is provided to turn AC_LANG_WERROR on + # *and then turn it back off*, so that we *only* do it when + # testing compiler options - 15 years after somebody asked + # for it: + # + # https://autoconf.gnu.narkive.com/gTAVmfKD/how-to-cancel-flags-set-by-ac-lang-werror + # + save_ac_c_werror_flag="$ac_c_werror_flag" + ac_c_werror_flag=yes + # + # We use AC_LANG_SOURCE() so that we can control the complete + # content of the program being compiled. We do not, for example, + # want the default "int main()" that AC_LANG_PROGRAM() generates, + # as it will generate a warning with -Wold-style-definition, meaning + # that we would treat it as not working, as the test will fail if + # *any* error output, including a warning due to the flag we're + # testing, is generated; see + # + # https://www.postgresql.org/message-id/2192993.1591682589%40sss.pgh.pa.us + # https://www.postgresql.org/message-id/2192993.1591682589%40sss.pgh.pa.us + # + # This may, as per those two messages, be fixed in autoonf 2.70, + # but we only require 2.64 or newer for now. + # cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ - -int -main () -{ -return 0 - ; - return 0; -} +int main(void) { return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : @@ -5701,33 +5739,42 @@ fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + ac_c_werror_flag="$save_ac_c_werror_flag" { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the compiler supports the -Wpointer-arith option" >&5 $as_echo_n "checking whether the compiler supports the -Wpointer-arith option... " >&6; } save_CFLAGS="$CFLAGS" - if expr "x-Wpointer-arith" : "x-W.*" >/dev/null - then - CFLAGS="$CFLAGS $ac_lbl_unknown_warning_option_error -Wpointer-arith" - elif expr "x-Wpointer-arith" : "x-f.*" >/dev/null - then - CFLAGS="$CFLAGS -Werror -Wpointer-arith" - elif expr "x-Wpointer-arith" : "x-m.*" >/dev/null - then - CFLAGS="$CFLAGS -Werror -Wpointer-arith" - else - CFLAGS="$CFLAGS -Wpointer-arith" - fi + CFLAGS="$CFLAGS -Wpointer-arith" + # + # XXX - yes, this depends on the way AC_LANG_WERROR works, + # but no mechanism is provided to turn AC_LANG_WERROR on + # *and then turn it back off*, so that we *only* do it when + # testing compiler options - 15 years after somebody asked + # for it: + # + # https://autoconf.gnu.narkive.com/gTAVmfKD/how-to-cancel-flags-set-by-ac-lang-werror + # + save_ac_c_werror_flag="$ac_c_werror_flag" + ac_c_werror_flag=yes + # + # We use AC_LANG_SOURCE() so that we can control the complete + # content of the program being compiled. We do not, for example, + # want the default "int main()" that AC_LANG_PROGRAM() generates, + # as it will generate a warning with -Wold-style-definition, meaning + # that we would treat it as not working, as the test will fail if + # *any* error output, including a warning due to the flag we're + # testing, is generated; see + # + # https://www.postgresql.org/message-id/2192993.1591682589%40sss.pgh.pa.us + # https://www.postgresql.org/message-id/2192993.1591682589%40sss.pgh.pa.us + # + # This may, as per those two messages, be fixed in autoonf 2.70, + # but we only require 2.64 or newer for now. + # cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ - -int -main () -{ -return 0 - ; - return 0; -} +int main(void) { return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : @@ -5744,33 +5791,42 @@ fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + ac_c_werror_flag="$save_ac_c_werror_flag" { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the compiler supports the -Wpointer-sign option" >&5 $as_echo_n "checking whether the compiler supports the -Wpointer-sign option... " >&6; } save_CFLAGS="$CFLAGS" - if expr "x-Wpointer-sign" : "x-W.*" >/dev/null - then - CFLAGS="$CFLAGS $ac_lbl_unknown_warning_option_error -Wpointer-sign" - elif expr "x-Wpointer-sign" : "x-f.*" >/dev/null - then - CFLAGS="$CFLAGS -Werror -Wpointer-sign" - elif expr "x-Wpointer-sign" : "x-m.*" >/dev/null - then - CFLAGS="$CFLAGS -Werror -Wpointer-sign" - else - CFLAGS="$CFLAGS -Wpointer-sign" - fi + CFLAGS="$CFLAGS -Wpointer-sign" + # + # XXX - yes, this depends on the way AC_LANG_WERROR works, + # but no mechanism is provided to turn AC_LANG_WERROR on + # *and then turn it back off*, so that we *only* do it when + # testing compiler options - 15 years after somebody asked + # for it: + # + # https://autoconf.gnu.narkive.com/gTAVmfKD/how-to-cancel-flags-set-by-ac-lang-werror + # + save_ac_c_werror_flag="$ac_c_werror_flag" + ac_c_werror_flag=yes + # + # We use AC_LANG_SOURCE() so that we can control the complete + # content of the program being compiled. We do not, for example, + # want the default "int main()" that AC_LANG_PROGRAM() generates, + # as it will generate a warning with -Wold-style-definition, meaning + # that we would treat it as not working, as the test will fail if + # *any* error output, including a warning due to the flag we're + # testing, is generated; see + # + # https://www.postgresql.org/message-id/2192993.1591682589%40sss.pgh.pa.us + # https://www.postgresql.org/message-id/2192993.1591682589%40sss.pgh.pa.us + # + # This may, as per those two messages, be fixed in autoonf 2.70, + # but we only require 2.64 or newer for now. + # cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ - -int -main () -{ -return 0 - ; - return 0; -} +int main(void) { return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : @@ -5787,33 +5843,42 @@ fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + ac_c_werror_flag="$save_ac_c_werror_flag" { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the compiler supports the -Wshadow option" >&5 $as_echo_n "checking whether the compiler supports the -Wshadow option... " >&6; } save_CFLAGS="$CFLAGS" - if expr "x-Wshadow" : "x-W.*" >/dev/null - then - CFLAGS="$CFLAGS $ac_lbl_unknown_warning_option_error -Wshadow" - elif expr "x-Wshadow" : "x-f.*" >/dev/null - then - CFLAGS="$CFLAGS -Werror -Wshadow" - elif expr "x-Wshadow" : "x-m.*" >/dev/null - then - CFLAGS="$CFLAGS -Werror -Wshadow" - else - CFLAGS="$CFLAGS -Wshadow" - fi + CFLAGS="$CFLAGS -Wshadow" + # + # XXX - yes, this depends on the way AC_LANG_WERROR works, + # but no mechanism is provided to turn AC_LANG_WERROR on + # *and then turn it back off*, so that we *only* do it when + # testing compiler options - 15 years after somebody asked + # for it: + # + # https://autoconf.gnu.narkive.com/gTAVmfKD/how-to-cancel-flags-set-by-ac-lang-werror + # + save_ac_c_werror_flag="$ac_c_werror_flag" + ac_c_werror_flag=yes + # + # We use AC_LANG_SOURCE() so that we can control the complete + # content of the program being compiled. We do not, for example, + # want the default "int main()" that AC_LANG_PROGRAM() generates, + # as it will generate a warning with -Wold-style-definition, meaning + # that we would treat it as not working, as the test will fail if + # *any* error output, including a warning due to the flag we're + # testing, is generated; see + # + # https://www.postgresql.org/message-id/2192993.1591682589%40sss.pgh.pa.us + # https://www.postgresql.org/message-id/2192993.1591682589%40sss.pgh.pa.us + # + # This may, as per those two messages, be fixed in autoonf 2.70, + # but we only require 2.64 or newer for now. + # cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ - -int -main () -{ -return 0 - ; - return 0; -} +int main(void) { return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : @@ -5830,33 +5895,42 @@ fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + ac_c_werror_flag="$save_ac_c_werror_flag" { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the compiler supports the -Wsign-compare option" >&5 $as_echo_n "checking whether the compiler supports the -Wsign-compare option... " >&6; } save_CFLAGS="$CFLAGS" - if expr "x-Wsign-compare" : "x-W.*" >/dev/null - then - CFLAGS="$CFLAGS $ac_lbl_unknown_warning_option_error -Wsign-compare" - elif expr "x-Wsign-compare" : "x-f.*" >/dev/null - then - CFLAGS="$CFLAGS -Werror -Wsign-compare" - elif expr "x-Wsign-compare" : "x-m.*" >/dev/null - then - CFLAGS="$CFLAGS -Werror -Wsign-compare" - else - CFLAGS="$CFLAGS -Wsign-compare" - fi + CFLAGS="$CFLAGS -Wsign-compare" + # + # XXX - yes, this depends on the way AC_LANG_WERROR works, + # but no mechanism is provided to turn AC_LANG_WERROR on + # *and then turn it back off*, so that we *only* do it when + # testing compiler options - 15 years after somebody asked + # for it: + # + # https://autoconf.gnu.narkive.com/gTAVmfKD/how-to-cancel-flags-set-by-ac-lang-werror + # + save_ac_c_werror_flag="$ac_c_werror_flag" + ac_c_werror_flag=yes + # + # We use AC_LANG_SOURCE() so that we can control the complete + # content of the program being compiled. We do not, for example, + # want the default "int main()" that AC_LANG_PROGRAM() generates, + # as it will generate a warning with -Wold-style-definition, meaning + # that we would treat it as not working, as the test will fail if + # *any* error output, including a warning due to the flag we're + # testing, is generated; see + # + # https://www.postgresql.org/message-id/2192993.1591682589%40sss.pgh.pa.us + # https://www.postgresql.org/message-id/2192993.1591682589%40sss.pgh.pa.us + # + # This may, as per those two messages, be fixed in autoonf 2.70, + # but we only require 2.64 or newer for now. + # cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ - -int -main () -{ -return 0 - ; - return 0; -} +int main(void) { return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : @@ -5873,33 +5947,42 @@ fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + ac_c_werror_flag="$save_ac_c_werror_flag" { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the compiler supports the -Wstrict-prototypes option" >&5 $as_echo_n "checking whether the compiler supports the -Wstrict-prototypes option... " >&6; } save_CFLAGS="$CFLAGS" - if expr "x-Wstrict-prototypes" : "x-W.*" >/dev/null - then - CFLAGS="$CFLAGS $ac_lbl_unknown_warning_option_error -Wstrict-prototypes" - elif expr "x-Wstrict-prototypes" : "x-f.*" >/dev/null - then - CFLAGS="$CFLAGS -Werror -Wstrict-prototypes" - elif expr "x-Wstrict-prototypes" : "x-m.*" >/dev/null - then - CFLAGS="$CFLAGS -Werror -Wstrict-prototypes" - else - CFLAGS="$CFLAGS -Wstrict-prototypes" - fi + CFLAGS="$CFLAGS -Wstrict-prototypes" + # + # XXX - yes, this depends on the way AC_LANG_WERROR works, + # but no mechanism is provided to turn AC_LANG_WERROR on + # *and then turn it back off*, so that we *only* do it when + # testing compiler options - 15 years after somebody asked + # for it: + # + # https://autoconf.gnu.narkive.com/gTAVmfKD/how-to-cancel-flags-set-by-ac-lang-werror + # + save_ac_c_werror_flag="$ac_c_werror_flag" + ac_c_werror_flag=yes + # + # We use AC_LANG_SOURCE() so that we can control the complete + # content of the program being compiled. We do not, for example, + # want the default "int main()" that AC_LANG_PROGRAM() generates, + # as it will generate a warning with -Wold-style-definition, meaning + # that we would treat it as not working, as the test will fail if + # *any* error output, including a warning due to the flag we're + # testing, is generated; see + # + # https://www.postgresql.org/message-id/2192993.1591682589%40sss.pgh.pa.us + # https://www.postgresql.org/message-id/2192993.1591682589%40sss.pgh.pa.us + # + # This may, as per those two messages, be fixed in autoonf 2.70, + # but we only require 2.64 or newer for now. + # cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ - -int -main () -{ -return 0 - ; - return 0; -} +int main(void) { return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : @@ -5916,33 +5999,42 @@ fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + ac_c_werror_flag="$save_ac_c_werror_flag" { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the compiler supports the -Wunreachable-code-return option" >&5 $as_echo_n "checking whether the compiler supports the -Wunreachable-code-return option... " >&6; } save_CFLAGS="$CFLAGS" - if expr "x-Wunreachable-code-return" : "x-W.*" >/dev/null - then - CFLAGS="$CFLAGS $ac_lbl_unknown_warning_option_error -Wunreachable-code-return" - elif expr "x-Wunreachable-code-return" : "x-f.*" >/dev/null - then - CFLAGS="$CFLAGS -Werror -Wunreachable-code-return" - elif expr "x-Wunreachable-code-return" : "x-m.*" >/dev/null - then - CFLAGS="$CFLAGS -Werror -Wunreachable-code-return" - else - CFLAGS="$CFLAGS -Wunreachable-code-return" - fi + CFLAGS="$CFLAGS -Wunreachable-code-return" + # + # XXX - yes, this depends on the way AC_LANG_WERROR works, + # but no mechanism is provided to turn AC_LANG_WERROR on + # *and then turn it back off*, so that we *only* do it when + # testing compiler options - 15 years after somebody asked + # for it: + # + # https://autoconf.gnu.narkive.com/gTAVmfKD/how-to-cancel-flags-set-by-ac-lang-werror + # + save_ac_c_werror_flag="$ac_c_werror_flag" + ac_c_werror_flag=yes + # + # We use AC_LANG_SOURCE() so that we can control the complete + # content of the program being compiled. We do not, for example, + # want the default "int main()" that AC_LANG_PROGRAM() generates, + # as it will generate a warning with -Wold-style-definition, meaning + # that we would treat it as not working, as the test will fail if + # *any* error output, including a warning due to the flag we're + # testing, is generated; see + # + # https://www.postgresql.org/message-id/2192993.1591682589%40sss.pgh.pa.us + # https://www.postgresql.org/message-id/2192993.1591682589%40sss.pgh.pa.us + # + # This may, as per those two messages, be fixed in autoonf 2.70, + # but we only require 2.64 or newer for now. + # cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ - -int -main () -{ -return 0 - ; - return 0; -} +int main(void) { return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : @@ -5959,33 +6051,42 @@ fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + ac_c_werror_flag="$save_ac_c_werror_flag" { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the compiler supports the -Wused-but-marked-unused option" >&5 $as_echo_n "checking whether the compiler supports the -Wused-but-marked-unused option... " >&6; } save_CFLAGS="$CFLAGS" - if expr "x-Wused-but-marked-unused" : "x-W.*" >/dev/null - then - CFLAGS="$CFLAGS $ac_lbl_unknown_warning_option_error -Wused-but-marked-unused" - elif expr "x-Wused-but-marked-unused" : "x-f.*" >/dev/null - then - CFLAGS="$CFLAGS -Werror -Wused-but-marked-unused" - elif expr "x-Wused-but-marked-unused" : "x-m.*" >/dev/null - then - CFLAGS="$CFLAGS -Werror -Wused-but-marked-unused" - else - CFLAGS="$CFLAGS -Wused-but-marked-unused" - fi + CFLAGS="$CFLAGS -Wused-but-marked-unused" + # + # XXX - yes, this depends on the way AC_LANG_WERROR works, + # but no mechanism is provided to turn AC_LANG_WERROR on + # *and then turn it back off*, so that we *only* do it when + # testing compiler options - 15 years after somebody asked + # for it: + # + # https://autoconf.gnu.narkive.com/gTAVmfKD/how-to-cancel-flags-set-by-ac-lang-werror + # + save_ac_c_werror_flag="$ac_c_werror_flag" + ac_c_werror_flag=yes + # + # We use AC_LANG_SOURCE() so that we can control the complete + # content of the program being compiled. We do not, for example, + # want the default "int main()" that AC_LANG_PROGRAM() generates, + # as it will generate a warning with -Wold-style-definition, meaning + # that we would treat it as not working, as the test will fail if + # *any* error output, including a warning due to the flag we're + # testing, is generated; see + # + # https://www.postgresql.org/message-id/2192993.1591682589%40sss.pgh.pa.us + # https://www.postgresql.org/message-id/2192993.1591682589%40sss.pgh.pa.us + # + # This may, as per those two messages, be fixed in autoonf 2.70, + # but we only require 2.64 or newer for now. + # cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ - -int -main () -{ -return 0 - ; - return 0; -} +int main(void) { return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : @@ -6002,33 +6103,42 @@ fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + ac_c_werror_flag="$save_ac_c_werror_flag" { $as_echo "$as_me:${as_lineno-$LINENO}: checking whether the compiler supports the -Wwrite-strings option" >&5 $as_echo_n "checking whether the compiler supports the -Wwrite-strings option... " >&6; } save_CFLAGS="$CFLAGS" - if expr "x-Wwrite-strings" : "x-W.*" >/dev/null - then - CFLAGS="$CFLAGS $ac_lbl_unknown_warning_option_error -Wwrite-strings" - elif expr "x-Wwrite-strings" : "x-f.*" >/dev/null - then - CFLAGS="$CFLAGS -Werror -Wwrite-strings" - elif expr "x-Wwrite-strings" : "x-m.*" >/dev/null - then - CFLAGS="$CFLAGS -Werror -Wwrite-strings" - else - CFLAGS="$CFLAGS -Wwrite-strings" - fi + CFLAGS="$CFLAGS -Wwrite-strings" + # + # XXX - yes, this depends on the way AC_LANG_WERROR works, + # but no mechanism is provided to turn AC_LANG_WERROR on + # *and then turn it back off*, so that we *only* do it when + # testing compiler options - 15 years after somebody asked + # for it: + # + # https://autoconf.gnu.narkive.com/gTAVmfKD/how-to-cancel-flags-set-by-ac-lang-werror + # + save_ac_c_werror_flag="$ac_c_werror_flag" + ac_c_werror_flag=yes + # + # We use AC_LANG_SOURCE() so that we can control the complete + # content of the program being compiled. We do not, for example, + # want the default "int main()" that AC_LANG_PROGRAM() generates, + # as it will generate a warning with -Wold-style-definition, meaning + # that we would treat it as not working, as the test will fail if + # *any* error output, including a warning due to the flag we're + # testing, is generated; see + # + # https://www.postgresql.org/message-id/2192993.1591682589%40sss.pgh.pa.us + # https://www.postgresql.org/message-id/2192993.1591682589%40sss.pgh.pa.us + # + # This may, as per those two messages, be fixed in autoonf 2.70, + # but we only require 2.64 or newer for now. + # cat confdefs.h - <<_ACEOF >conftest.$ac_ext /* end confdefs.h. */ - -int -main () -{ -return 0 - ; - return 0; -} +int main(void) { return 0; } _ACEOF if ac_fn_c_try_compile "$LINENO"; then : @@ -6045,6 +6155,7 @@ fi rm -f core conftest.err conftest.$ac_objext conftest.$ac_ext + ac_c_werror_flag="$save_ac_c_werror_flag" fi @@ -6793,7 +6904,7 @@ # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by tcpslice $as_me 1.3, which was +This file was extended by tcpslice $as_me 1.5, which was generated by GNU Autoconf 2.69. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -6859,7 +6970,7 @@ cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config="`$as_echo "$ac_configure_args" | sed 's/^ //; s/[\\""\`\$]/\\\\&/g'`" ac_cs_version="\\ -tcpslice config.status 1.3 +tcpslice config.status 1.5 configured by $0, generated by GNU Autoconf 2.69, with options \\"\$ac_cs_config\\" @@ -7547,7 +7658,7 @@ "default-1":C) if test -f .devel; then echo timestamp > stamp-h cat $srcdir/Makefile-devel-adds >> Makefile - make depend + make depend || exit 1 fi ;; esac diff -Nru tcpslice-1.3/configure.ac tcpslice-1.5/configure.ac --- tcpslice-1.3/configure.ac 2020-08-19 18:16:16.000000000 +0000 +++ tcpslice-1.5/configure.ac 2021-10-07 12:13:20.000000000 +0000 @@ -127,7 +127,7 @@ AC_OUTPUT_COMMANDS([if test -f .devel; then echo timestamp > stamp-h cat $srcdir/Makefile-devel-adds >> Makefile - make depend + make depend || exit 1 fi]) AC_OUTPUT(Makefile) exit 0 diff -Nru tcpslice-1.3/CREDITS tcpslice-1.5/CREDITS --- tcpslice-1.3/CREDITS 2020-08-19 18:16:16.000000000 +0000 +++ tcpslice-1.5/CREDITS 2021-12-06 19:02:30.000000000 +0000 @@ -3,7 +3,7 @@ The current maintainers (in alphabetical order): Denis Ovsienko Francois-Xavier Le Bail - Guy Harris + Guy Harris Michael Richardson Additional people who have contributed patches (in alphabetical order): diff -Nru tcpslice-1.3/debian/changelog tcpslice-1.5/debian/changelog --- tcpslice-1.3/debian/changelog 2020-08-31 02:01:27.000000000 +0000 +++ tcpslice-1.5/debian/changelog 2022-05-28 23:56:55.000000000 +0000 @@ -1,3 +1,24 @@ +tcpslice (1.5-1) unstable; urgency=medium + + * New upstream version 1.5. (includes a fix for CVE-2021-41043) + (Closes: #1003190) + * Enable GPG-checking of orig tarball. + - debian/upstream/signing-key.asc: upstream public key. + - debian/watch: + ~ Add "pgpmode=auto" as an option. + ~ Changed the URL. + * debian/control: + - Added libnids-dev and libosip2-dev to Build-Depends field. + - Bumped Standards-Version to 4.6.0. + * debian/copyright: + - Added licensing for diag-control.h file. + - Updated the packaging and upstream copyright years. + * debian/docs: changed from README to README.md. + * debian/patches: removed. The upstream fixed the source code. Thanks. + * debian/upstream/metadata: fixed spelling error. + + -- Bruno Naibert de Campos Sat, 28 May 2022 20:56:55 -0300 + tcpslice (1.3-2) unstable; urgency=medium * Upload to unstable. @@ -27,7 +48,7 @@ - 08_hardening.patch: ~ Renamed to 20_hardening.patch. ~ Updated to make it compliant with new upstream version. - * debian/tests/control: updated superficial test. + * debian/tests/control: updated superficial test. * debian/watch: updated (using only GitHub now). -- Bruno Naibert de Campos Sat, 22 Aug 2020 21:27:46 -0300 diff -Nru tcpslice-1.3/debian/control tcpslice-1.5/debian/control --- tcpslice-1.3/debian/control 2020-08-21 02:34:28.000000000 +0000 +++ tcpslice-1.5/debian/control 2022-05-28 18:38:13.000000000 +0000 @@ -3,8 +3,10 @@ Priority: optional Maintainer: Bruno Naibert de Campos Build-Depends: debhelper-compat (= 13), + libnids-dev, + libosip2-dev, libpcap-dev -Standards-Version: 4.5.0 +Standards-Version: 4.6.0 Rules-Requires-Root: binary-targets Homepage: http://www.tcpdump.org Vcs-Browser: https://salsa.debian.org/debian/tcpslice diff -Nru tcpslice-1.3/debian/copyright tcpslice-1.5/debian/copyright --- tcpslice-1.3/debian/copyright 2020-08-24 01:58:31.000000000 +0000 +++ tcpslice-1.5/debian/copyright 2022-05-28 18:16:48.000000000 +0000 @@ -5,7 +5,7 @@ Files: * Copyright: 1989-2000 The Regents of the University of California - 2020 The Tcpdump Group + 2020-2021 The Tcpdump Group License: BSD-4-Clause Files: missing/strlcpy.c @@ -16,13 +16,17 @@ Copyright: 2006 Sebastien Raveau License: BSD-3-Clause +Files: diag-control.h +Copyright: 2021 The Tcpdump Group +License: BSD-2-Clause + Files: debian/* Copyright: 1999 Philip Hands 2001 Doug Porter 2002 Torsten Landschoff 2004-2010 Jochen Friedrich 2007 Margarita Manterola - 2020 Bruno Naibert de Campos + 2020-2022 Bruno Naibert de Campos License: BSD-4-Clause License: BSD-4-Clause @@ -78,3 +82,26 @@ LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + +License: BSD-2-Clause + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions + are met: + 1. Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + 2. Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + . + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + POSSIBILITY OF SUCH DAMAGE. diff -Nru tcpslice-1.3/debian/docs tcpslice-1.5/debian/docs --- tcpslice-1.3/debian/docs 2020-08-22 23:03:27.000000000 +0000 +++ tcpslice-1.5/debian/docs 2022-05-28 18:27:35.000000000 +0000 @@ -1,3 +1,3 @@ CHANGES CREDITS -README +README.md diff -Nru tcpslice-1.3/debian/patches/01_fix-install.patch tcpslice-1.5/debian/patches/01_fix-install.patch --- tcpslice-1.3/debian/patches/01_fix-install.patch 2020-08-22 23:16:10.000000000 +0000 +++ tcpslice-1.5/debian/patches/01_fix-install.patch 1970-01-01 00:00:00.000000000 +0000 @@ -1,36 +0,0 @@ -Description: fixed install in accordance with FHS 3.0 -Author: Bruno Naibert de Campos -Last-Update: 2020-08-22 -Index: tcpslice/Makefile.in -=================================================================== ---- tcpslice.orig/Makefile.in -+++ tcpslice/Makefile.in -@@ -26,7 +26,7 @@ prefix = @prefix@ - exec_prefix = @exec_prefix@ - datarootdir = @datarootdir@ - # Pathname of directory to install the binary --sbindir = @sbindir@ -+bindir = @bindir@ - # Pathname of directory to install the man page - mandir = @mandir@ - -@@ -137,15 +137,15 @@ strlcpy.o: $(srcdir)/missing/strlcpy.c - $(CC) $(FULL_CFLAGS) -o $@ -c $(srcdir)/missing/strlcpy.c - - install: all -- [ -d $(DESTDIR)$(sbindir) ] || \ -- (mkdir -p $(DESTDIR)$(sbindir); chmod 755 $(DESTDIR)$(sbindir)) -- $(INSTALL_PROGRAM) $(PROG) $(DESTDIR)$(sbindir)/$(PROG) -+ [ -d $(DESTDIR)$(bindir) ] || \ -+ (mkdir -p $(DESTDIR)$(bindir); chmod 755 $(DESTDIR)$(bindir)) -+ $(INSTALL_PROGRAM) $(PROG) $(DESTDIR)$(bindir)/$(PROG) - [ -d $(DESTDIR)$(mandir)/man1 ] || \ - (mkdir -p $(DESTDIR)$(mandir)/man1; chmod 755 $(DESTDIR)$(mandir)/man1) - $(INSTALL_DATA) $(srcdir)/$(PROG).1 $(DESTDIR)$(mandir)/man1/$(PROG).1 - - uninstall: -- rm -f $(DESTDIR)$(sbindir)/$(PROG) -+ rm -f $(DESTDIR)$(bindir)/$(PROG) - rm -f $(DESTDIR)$(mandir)/man1/$(PROG).1 - - lint: $(GENSRC) diff -Nru tcpslice-1.3/debian/patches/02_hardening.patch tcpslice-1.5/debian/patches/02_hardening.patch --- tcpslice-1.3/debian/patches/02_hardening.patch 2020-08-23 00:20:35.000000000 +0000 +++ tcpslice-1.5/debian/patches/02_hardening.patch 1970-01-01 00:00:00.000000000 +0000 @@ -1,16 +0,0 @@ -Description: Fix hardening in CPPFLAGS -Author: Bruno Naibert de Campos -Last-Update: 2020-08-22 -Index: tcpslice/Makefile.in -=================================================================== ---- tcpslice.orig/Makefile.in -+++ tcpslice/Makefile.in -@@ -127,7 +127,7 @@ $(PROG): $(OBJ) @V_PCAPDEP@ - $(CC) $(FULL_CFLAGS) $(LDFLAGS) -o $@ $(OBJ) $(LIBS) - - version.o: version.c -- $(CC) $(CFLAGS) -c version.c -+ $(CC) $(FULL_CFLAGS) -c version.c - - version.c: $(srcdir)/VERSION - @rm -f $@ diff -Nru tcpslice-1.3/debian/patches/series tcpslice-1.5/debian/patches/series --- tcpslice-1.3/debian/patches/series 2020-08-22 22:47:31.000000000 +0000 +++ tcpslice-1.5/debian/patches/series 1970-01-01 00:00:00.000000000 +0000 @@ -1,2 +0,0 @@ -01_fix-install.patch -02_hardening.patch diff -Nru tcpslice-1.3/debian/upstream/metadata tcpslice-1.5/debian/upstream/metadata --- tcpslice-1.3/debian/upstream/metadata 2020-08-21 02:34:28.000000000 +0000 +++ tcpslice-1.5/debian/upstream/metadata 2022-05-28 18:59:37.000000000 +0000 @@ -1,4 +1,4 @@ Bug-Database: https://github.com/the-tcpdump-group/tcpslice/issues Bug-Submit: https://github.com/the-tcpdump-group/tcpslice/issues/new Repository: https://github.com/the-tcpdump-group/tcpslice.git -Repository-Browser: https://github.com/the-tcpdump-group/tcpslice +Repository-Browse: https://github.com/the-tcpdump-group/tcpslice diff -Nru tcpslice-1.3/debian/upstream/signing-key.asc tcpslice-1.5/debian/upstream/signing-key.asc --- tcpslice-1.3/debian/upstream/signing-key.asc 1970-01-01 00:00:00.000000000 +0000 +++ tcpslice-1.5/debian/upstream/signing-key.asc 2022-05-28 19:54:42.000000000 +0000 @@ -0,0 +1,24 @@ +-----BEGIN PGP PUBLIC KEY BLOCK----- + +mQGRBFGRD2gBDCDcthM1N9jeWic9tD17LsHwWyh/IelKgFMVFShgHk31YsQUetKn +5hGKlW0WU7+r3dsECiqxgyuqeUKvqiZneqma0GDk1n8ucXLc7oFFLrF7qbvssPPM +831014FlzsN82OZZ1SnNUGacdyNzV5myPybKILWemsLuAJaGU60IkAJkTReiaMFR +pB0QmBiqM5KY2SHAkeja2+UhupBw/lHyAwU/KVhkohmvUTJeUBJaKK2gRY7jJQmf +ouTbIe0nKIqDzMmE9GvFhyQmMJzbxAwTfSxSZq3bMCpsyQtjoi2LGQFoMVkI6g7K +IRNWgCqSTHF238VIdOkLzbwuoZAmS+oacXszIln2jLJsKkbiCCOb/lV+5u5O6/wJ +M4RHxCBnkRgBmMLyXSM9qAo1FU5suPqf01msqvKMsa99lTF6kIWurR/7rw4S2bNl +iaMqHNHliFNfaAE42S8as+Pw5Rhq2SJczWyd8rYw/q1IIZyKLO1oGn6ZRt+EQ7BS +8nlREmT/MDqP0rgrpvRrABEBAAG0PVRoZSBUY3BkdW1wIEdyb3VwIChQYWNrYWdl +IHNpZ25pbmcga2V5KSA8cmVsZWFzZUB0Y3BkdW1wLm9yZz6JAcIEEwECACgFAlGR +D2gCGwMFCRLMAwAGCwkIBwMCBhUIAgkKCwQWAgMBAh4BAheAAAoJEOCJ3vHZwV0N +wPAMH22fmTbjByMSvR/gxDFA26ULgf02qZzqYlRLKB7EDbEjB1Ga6PrLB22Sn/b5 +8fxNw/9zH0EPkorv0YnBhinE51jLmZ99Sk5eGFIMcCkNAOOhadFZGGKarekEPwNB +oDtxCuSuOQ0JVvyn5fLcbA5u3+LBvHvbnUKgCpiXahpq15bZiS1aoVkdXknUQVO+ +bU6Y2lj3m8Q1C6t+J29UvbyixgQhFeTkl25NZkTS6Cqds5F9q3nUBD/7gvQbATBy +A+p+iWLHqt1s4c5UHRzriuLyBbnJgOEI13pNbgFIoKhbCSGQj0uQVZORmzzqs0nh +QXtj+JPOAMd619mHjmhXItgqu2llywQ36tXTEdRoUjJmgMkoqXtZQ8XDVdJ6f/sG +OJDHCctr5aVanWierzePl1PvWPWeC9mnB6Nnxuah+8zQFb4wXUnYO09OX47UgQlu +mE9/lZfY7okIODVrXjqbPVxSBLzCzptBrkeZ3brkrl5oCdYlWsUiQCY0hO6jzMEd +CnxEp1kkn2c= +=2mPY +-----END PGP PUBLIC KEY BLOCK----- diff -Nru tcpslice-1.3/debian/watch tcpslice-1.5/debian/watch --- tcpslice-1.3/debian/watch 2020-08-21 02:47:43.000000000 +0000 +++ tcpslice-1.5/debian/watch 2022-05-28 19:55:39.000000000 +0000 @@ -1,2 +1,3 @@ version=4 -https://github.com/the-tcpdump-group/tcpslice/tags (?:.*/)@PACKAGE@@ANY_VERSION@@ARCHIVE_EXT@ +opts=pgpmode=auto \ + https://www.tcpdump.org/release/@PACKAGE@@ANY_VERSION@@ARCHIVE_EXT@ diff -Nru tcpslice-1.3/diag-control.h tcpslice-1.5/diag-control.h --- tcpslice-1.3/diag-control.h 1970-01-01 00:00:00.000000000 +0000 +++ tcpslice-1.5/diag-control.h 2021-10-07 12:13:20.000000000 +0000 @@ -0,0 +1,82 @@ +/* + * Copyright (c) 2021 The Tcpdump Group + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; + * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER + * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN + * ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE + * POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef tcpslice_diag_control_h +#define tcpslice_diag_control_h + +#include "compiler-tests.h" +#define DIAG_DO_PRAGMA(x) _Pragma (#x) + +/* + * XL C has to be tested first because starting with version 16.1 it defines + * both __GNUC__ and __clang__. + */ +#if TCPSLICE_IS_AT_LEAST_XL_C_VERSION(1,0) + /* + * GCC diagnostic pragmas became available in XL C version 16.1.0, for Linux + * only. XL C for Linux always defines __linux__. + */ + #if TCPSLICE_IS_AT_LEAST_XL_C_VERSION(16,1) && defined(__linux__) + #define DIAG_OFF_PEDANTIC \ + DIAG_DO_PRAGMA(GCC diagnostic push) \ + DIAG_DO_PRAGMA(GCC diagnostic ignored "-Wpedantic") + #define DIAG_ON_PEDANTIC \ + DIAG_DO_PRAGMA(GCC diagnostic pop) + #endif +/* + * Clang defines __GNUC__ and __GNUC_MINOR__, so has to be tested before GCC. + */ +#elif TCPSLICE_IS_AT_LEAST_CLANG_VERSION(2,8) + #define DIAG_OFF_PEDANTIC \ + DIAG_DO_PRAGMA(clang diagnostic push) \ + DIAG_DO_PRAGMA(clang diagnostic ignored "-Wpedantic") + #define DIAG_ON_PEDANTIC \ + DIAG_DO_PRAGMA(clang diagnostic pop) +/* + * GCC 4.6 has working ignored/push/pop. + */ +#elif TCPSLICE_IS_AT_LEAST_GNUC_VERSION(4,6) + /* + * -Wpedantic became available in GCC 4.8.0. + */ + #if TCPSLICE_IS_AT_LEAST_GNUC_VERSION(4,8) + #define DIAG_OFF_PEDANTIC \ + DIAG_DO_PRAGMA(GCC diagnostic push) \ + DIAG_DO_PRAGMA(GCC diagnostic ignored "-Wpedantic") + #define DIAG_ON_PEDANTIC \ + DIAG_DO_PRAGMA(GCC diagnostic pop) + #endif +#endif + +#ifndef DIAG_OFF_PEDANTIC +#define DIAG_OFF_PEDANTIC +#endif +#ifndef DIAG_ON_PEDANTIC +#define DIAG_ON_PEDANTIC +#endif + +#endif /* tcpslice_diag_control_h */ diff -Nru tcpslice-1.3/.gitignore tcpslice-1.5/.gitignore --- tcpslice-1.3/.gitignore 2020-08-19 18:16:16.000000000 +0000 +++ tcpslice-1.5/.gitignore 1970-01-01 00:00:00.000000000 +0000 @@ -1,14 +0,0 @@ -version.c -Makefile -config.status -config.log -config.cache -config.h -.devel -os-proto.h -stamp-h -stamp-h.in -tcpslice -autom4te.cache/ -*.o -*~ diff -Nru tcpslice-1.3/gmt2local.c tcpslice-1.5/gmt2local.c --- tcpslice-1.3/gmt2local.c 2020-08-19 18:16:16.000000000 +0000 +++ tcpslice-1.5/gmt2local.c 2021-10-07 12:13:20.000000000 +0000 @@ -44,8 +44,8 @@ int32_t gmt2local(time_t t) { - register int dt, dir; - register struct tm *gmt, *loc; + int dt, dir; + struct tm *gmt, *loc; struct tm sgmt; if (t == 0) diff -Nru tcpslice-1.3/gwtm2secs.c tcpslice-1.5/gwtm2secs.c --- tcpslice-1.3/gwtm2secs.c 2020-08-19 18:16:16.000000000 +0000 +++ tcpslice-1.5/gwtm2secs.c 2021-10-07 12:13:20.000000000 +0000 @@ -30,7 +30,6 @@ #include #include -#include #ifdef HAVE_OS_PROTO_H #include "os-proto.h" @@ -42,8 +41,9 @@ /* Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec */ { 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }; -time_t gwtm2secs( struct tm *tm ) - { +time_t +gwtm2secs( const struct tm *tm ) +{ int i, days, year; /* tm_year is either: @@ -62,11 +62,11 @@ days = 0; for ( i = 1970; i < year; ++i ) - { + { days += 365; if ( IS_LEAP_YEAR(i) ) ++days; - } + } for ( i = 0; i < tm->tm_mon; ++i ) days += days_in_month[i]; @@ -77,4 +77,4 @@ days += tm->tm_mday - 1; /* -1 since days are numbered starting at 1 */ return days * 86400 + tm->tm_hour * 3600 + tm->tm_min * 60 + tm->tm_sec; - } +} diff -Nru tcpslice-1.3/INSTALL tcpslice-1.5/INSTALL --- tcpslice-1.3/INSTALL 2020-08-19 18:16:16.000000000 +0000 +++ tcpslice-1.5/INSTALL 2021-10-07 12:13:20.000000000 +0000 @@ -1,4 +1,4 @@ -If you have not built libpcap, do so first. See the README file in +If you have not built libpcap, do so first. See the README.md file in this directory for the source code location. You will need an ANSI C compiler to build tcpslice. The configure @@ -25,7 +25,7 @@ INSTALL - this file Makefile.in - compilation rules (input to the configure script) Makefile-devel-adds - additional rules if .devel file exists -README - description of distribution +README.md - description of distribution VERSION - version of this release aclocal.m4 - autoconf macros compiler-tests.h - compiler version definitions diff -Nru tcpslice-1.3/install-sh tcpslice-1.5/install-sh --- tcpslice-1.3/install-sh 2020-08-19 18:16:16.000000000 +0000 +++ tcpslice-1.5/install-sh 2021-10-07 12:13:20.000000000 +0000 @@ -115,7 +115,7 @@ if [ x"$dir_arg" != x ]; then dst=$src src="" - + if [ -d $dst ]; then instcmd=: else @@ -124,7 +124,7 @@ else # Waiting for this to be detected by the "$instcmd $src $dsttmp" command -# might cause directories to be created, which would be especially bad +# might cause directories to be created, which would be especially bad # if $src (and thus $dsttmp) contains '*'. if [ -f $src -o -d $src ] @@ -134,7 +134,7 @@ echo "install: $src does not exist" exit 1 fi - + if [ x"$dst" = x ] then echo "install: no destination specified" @@ -201,17 +201,17 @@ # If we're going to rename the final executable, determine the name now. - if [ x"$transformarg" = x ] + if [ x"$transformarg" = x ] then dstfile=`basename $dst` else - dstfile=`basename $dst $transformbasename | + dstfile=`basename $dst $transformbasename | sed $transformarg`$transformbasename fi # don't allow the sed command to completely eliminate the filename - if [ x"$dstfile" = x ] + if [ x"$dstfile" = x ] then dstfile=`basename $dst` else @@ -242,7 +242,7 @@ # Now rename the file to the real destination. $doit $rmcmd -f $dstdir/$dstfile && - $doit $mvcmd $dsttmp $dstdir/$dstfile + $doit $mvcmd $dsttmp $dstdir/$dstfile fi && diff -Nru tcpslice-1.3/machdep.c tcpslice-1.5/machdep.c --- tcpslice-1.3/machdep.c 2020-08-19 18:16:16.000000000 +0000 +++ tcpslice-1.5/machdep.c 2021-10-07 12:13:20.000000000 +0000 @@ -44,7 +44,7 @@ * UNIX^W^WTru64 UNIX. */ int -abort_on_misalignment(char *ebuf _U_, size_t ebufsiz _U_) +abort_on_misalignment(char *ebuf _U_, const size_t ebufsiz _U_) { #ifdef __osf__ static int buf[2] = { SSIN_UACPROC, UAC_SIGBUS }; diff -Nru tcpslice-1.3/machdep.h tcpslice-1.5/machdep.h --- tcpslice-1.3/machdep.h 2020-08-19 18:16:16.000000000 +0000 +++ tcpslice-1.5/machdep.h 2021-10-07 12:13:20.000000000 +0000 @@ -21,5 +21,5 @@ #ifndef tcpslice_machdep_h #define tcpslice_machdep_h -int abort_on_misalignment(char *, size_t); +int abort_on_misalignment(char *, const size_t); #endif diff -Nru tcpslice-1.3/Makefile-devel-adds tcpslice-1.5/Makefile-devel-adds --- tcpslice-1.3/Makefile-devel-adds 2020-08-19 18:16:16.000000000 +0000 +++ tcpslice-1.5/Makefile-devel-adds 2021-10-07 12:13:20.000000000 +0000 @@ -3,12 +3,12 @@ # From autoconf.info . Works best with GNU Make. # ${srcdir}/configure: configure.ac aclocal.m4 - cd ${srcdir} && autoconf + (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.ac aclocal.m4 - cd ${srcdir} && autoheader + (cd ${srcdir} && autoheader) echo timestamp > ${srcdir}/stamp-h.in config.h: stamp-h diff -Nru tcpslice-1.3/Makefile.in tcpslice-1.5/Makefile.in --- tcpslice-1.3/Makefile.in 2020-08-19 18:16:16.000000000 +0000 +++ tcpslice-1.5/Makefile.in 2021-12-25 17:17:07.000000000 +0000 @@ -26,7 +26,7 @@ exec_prefix = @exec_prefix@ datarootdir = @datarootdir@ # Pathname of directory to install the binary -sbindir = @sbindir@ +bindir = @bindir@ # Pathname of directory to install the man page mandir = @mandir@ @@ -81,6 +81,7 @@ OBJ = $(CSRC:.c=.o) $(GENSRC:.c=.o) $(LIBOBJS) HDR = \ compiler-tests.h \ + diag-control.h \ gmt2local.h \ machdep.h \ sessions.h \ @@ -88,7 +89,6 @@ varattrs.h TAGHDR = \ - /usr/include/net/slip.h \ /usr/include/netinet/in.h \ /usr/include/netinet/udp.h \ /usr/include/netinet/tcp.h \ @@ -105,7 +105,7 @@ INSTALL \ Makefile.in \ Makefile-devel-adds \ - README \ + README.md \ VERSION \ aclocal.m4 \ config.guess \ @@ -127,7 +127,7 @@ $(CC) $(FULL_CFLAGS) $(LDFLAGS) -o $@ $(OBJ) $(LIBS) version.o: version.c - $(CC) $(CFLAGS) -c version.c + $(CC) $(FULL_CFLAGS) -c version.c version.c: $(srcdir)/VERSION @rm -f $@ @@ -137,16 +137,16 @@ $(CC) $(FULL_CFLAGS) -o $@ -c $(srcdir)/missing/strlcpy.c install: all - [ -d $(DESTDIR)$(sbindir) ] || \ - (mkdir -p $(DESTDIR)$(sbindir); chmod 755 $(DESTDIR)$(sbindir)) - $(INSTALL_PROGRAM) $(PROG) $(DESTDIR)$(sbindir)/$(PROG) - [ -d $(DESTDIR)$(mandir)/man1 ] || \ - (mkdir -p $(DESTDIR)$(mandir)/man1; chmod 755 $(DESTDIR)$(mandir)/man1) - $(INSTALL_DATA) $(srcdir)/$(PROG).1 $(DESTDIR)$(mandir)/man1/$(PROG).1 + [ -d "$(DESTDIR)$(bindir)" ] || \ + (mkdir -p "$(DESTDIR)$(bindir)"; chmod 755 "$(DESTDIR)$(bindir)") + $(INSTALL_PROGRAM) $(PROG) "$(DESTDIR)$(bindir)/$(PROG)" + [ -d "$(DESTDIR)$(mandir)/man1" ] || \ + (mkdir -p "$(DESTDIR)$(mandir)/man1"; chmod 755 "$(DESTDIR)$(mandir)/man1") + $(INSTALL_DATA) $(srcdir)/$(PROG).1 "$(DESTDIR)$(mandir)/man1/$(PROG).1" uninstall: - rm -f $(DESTDIR)$(sbindir)/$(PROG) - rm -f $(DESTDIR)$(mandir)/man1/$(PROG).1 + rm -f "$(DESTDIR)$(bindir)/$(PROG)" + rm -f "$(DESTDIR)$(mandir)/man1/$(PROG).1" lint: $(GENSRC) lint -hbxn $(SRC) | \ @@ -154,12 +154,15 @@ grep -v 'possible pointer alignment problem' clean: - rm -f $(CLEANFILES) + rm -f $(CLEANFILES) $(PROG)-`cat VERSION`.tar.gz distclean: rm -f $(CLEANFILES) Makefile config.cache config.log config.status \ config.h gnuc.h os-proto.h stamp-h stamp-h.in - rm -rf autom4te.cache tests/DIFF tests/NEW + rm -rf autom4te.cache + +extags: $(TAGFILES) + ctags $(TAGFILES) tags: $(TAGFILES) ctags -wtd $(TAGFILES) @@ -167,12 +170,17 @@ TAGS: $(TAGFILES) etags $(TAGFILES) +# AIX tar does not support "z", so use a pipe for gzip. +# Solaris tar understands "cf -", but not "-c -f -". releasetar: @name=$(PROG)-`cat VERSION` ; \ - mkdir $$name; \ - tar cf - $(CSRC) $(HDR) $(EXTRA_DIST) | (cd $$name; tar xf -); \ - tar -c -z -f $$name.tar.gz $$name; \ + mkdir $$name && \ + tar cf - $(CSRC) $(HDR) $(EXTRA_DIST) | (cd $$name; tar xf -) && \ + tar cf - $$name | gzip >$$name.tar.gz && \ rm -rf $$name depend: $(GENSRC) $(MKDEP) -c "$(CC)" -m "$(DEPENDENCY_CFLAG)" -s "$(srcdir)" $(DEFS) $(INCLS) $(SRC) $(LIBNETDISSECT_SRC) + +shellcheck: + shellcheck -f gcc -e SC2006 build.sh build_matrix.sh build_common.sh .ci-coverity-scan-build.sh diff -Nru tcpslice-1.3/missing/strlcpy.c tcpslice-1.5/missing/strlcpy.c --- tcpslice-1.3/missing/strlcpy.c 2020-08-19 18:16:16.000000000 +0000 +++ tcpslice-1.5/missing/strlcpy.c 2021-10-07 12:13:20.000000000 +0000 @@ -29,7 +29,7 @@ */ #ifdef HAVE_CONFIG_H -#include "config.h" +#include #endif #include @@ -45,9 +45,9 @@ size_t strlcpy(char *dst, const char *src, size_t siz) { - register char *d = dst; - register const char *s = src; - register size_t n = siz; + char *d = dst; + const char *s = src; + size_t n = siz; /* Copy as many bytes as will fit */ if (n != 0 && --n != 0) { diff -Nru tcpslice-1.3/README tcpslice-1.5/README --- tcpslice-1.3/README 2020-08-19 18:16:16.000000000 +0000 +++ tcpslice-1.5/README 1970-01-01 00:00:00.000000000 +0000 @@ -1,24 +0,0 @@ -TCPSLICE 1.x -Now maintained by "The Tcpdump Group" -See https://www.tcpdump.org - -https://github.com/the-tcpdump-group/tcpslice - -formerly from Lawrence Berkeley National Laboratory - ftp://ftp.ee.lbl.gov/tcpslice-1.2a3.tar.gz - -This directory contains source code for tcpslice, a tool for extracting -portions of packet trace files generated using tcpdump's -w flag. - -Tcpslice uses libpcap, a system-independent interface for user-level -packet capture. Before building tcpslice, you must first retrieve and -build libpcap, also originally from LBL and now being maintained by -The Tcpdump Group; see https://www.tcpdump.org/. - -Once libpcap is built (either install it or make sure it's in ../libpcap), -you can build tcpslice using the procedure in the INSTALL file. - -Problems, bugs, questions, desirable enhancements, source code contributions, -etc., should be sent to the mailing list "tcpdump-workers@lists.tcpdump.org". - -The Tcpdump Group diff -Nru tcpslice-1.3/README.md tcpslice-1.5/README.md --- tcpslice-1.3/README.md 1970-01-01 00:00:00.000000000 +0000 +++ tcpslice-1.5/README.md 2021-10-07 12:13:20.000000000 +0000 @@ -0,0 +1,28 @@ +# TCPSLICE 1.x by [The Tcpdump Group](https://www.tcpdump.org/) + +**To report a security issue please send an e-mail to security@tcpdump.org.** + +Anonymous git access is available via + + https://github.com/the-tcpdump-group/tcpslice + +This directory contains source code for tcpslice, a tool for extracting +portions of packet trace files generated using tcpdump's `-w` flag. + +Problems, bugs, questions, desirable enhancements, source code contributions, +etc., should be sent to the mailing list "tcpdump-workers@lists.tcpdump.org". + +### Dependency on libpcap +Tcpslice uses libpcap, a system-independent interface for user-level +packet capture. Before building tcpslice, you must first retrieve and +build libpcap. + +Once libpcap is built (either install it or make sure it's in `../libpcap`), +you can build tcpslice using the procedure in the [installation guidelines](INSTALL). + +### Origins of tcpslice + +```text +formerly from Lawrence Berkeley National Laboratory + ftp://ftp.ee.lbl.gov/tcpslice-1.2a3.tar.gz +``` diff -Nru tcpslice-1.3/search.c tcpslice-1.5/search.c --- tcpslice-1.3/search.c 2020-08-19 18:16:16.000000000 +0000 +++ tcpslice-1.5/search.c 2021-10-07 12:13:20.000000000 +0000 @@ -72,15 +72,11 @@ bpf_u_int32 len; /* length this packet (off wire) */ }; -/* stringify macros, for error reporting. */ -#define SS(x) #x -#define S(x) SS(x) - /* Maximum number of seconds that we can conceive of a dump file spanning. */ #define MAX_REASONABLE_FILE_SPAN (3600*24*366) /* one year */ /* Maximum packet length we ever expect to see. */ -#define MAX_REASONABLE_PACKET_LENGTH 65535 +#define MAX_REASONABLE_PACKET_LENGTH 262144 /* Size of a packet header in bytes; easier than typing the sizeof() all * the time ... @@ -119,8 +115,8 @@ * if the header looks reasonable and zero otherwise. */ static int -reasonable_header( struct pcap_pkthdr *hdr, time_t first_time, time_t last_time ) - { +reasonable_header( const struct pcap_pkthdr *hdr, const time_t first_time, time_t last_time ) +{ if ( last_time == 0 ) last_time = first_time + MAX_REASONABLE_FILE_SPAN; @@ -130,17 +126,15 @@ hdr->len <= MAX_REASONABLE_PACKET_LENGTH && hdr->caplen > 0 && hdr->caplen <= MAX_REASONABLE_PACKET_LENGTH; - } - +} #define SWAPLONG(y) \ ((((y)&0xff)<<24) | (((y)&0xff00)<<8) | (((y)&0xff0000)>>8) | (((y)>>24)&0xff)) /* Given a buffer, extracts a (properly aligned) packet header from it. */ - static void -extract_header( pcap_t *p, u_char *buf, struct pcap_pkthdr *hdr ) - { +extract_header( pcap_t *p, const u_char *buf, struct pcap_pkthdr *hdr ) +{ struct pcap_sf_pkthdr sfhdr; memcpy(&sfhdr, buf, sizeof(sfhdr)); @@ -151,12 +145,12 @@ hdr->len = sfhdr.len; if ( pcap_is_swapped( p ) ) - { + { hdr->ts.tv_sec = SWAPLONG(hdr->ts.tv_sec); hdr->ts.tv_usec = SWAPLONG(hdr->ts.tv_usec); hdr->len = SWAPLONG(hdr->len); hdr->caplen = SWAPLONG(hdr->caplen); - } + } /* * From bpf/libpcap/savefile.c: @@ -173,8 +167,7 @@ hdr->caplen = hdr->len; hdr->len = t; } - } - +} /* Search a buffer to locate the first header within it. Return values * are HEADER_NONE, HEADER_CLASH, HEADER_PERHAPS, and HEADER_DEFINITELY. @@ -209,10 +202,10 @@ #define HEADER_DEFINITELY 3 static int -find_header( pcap_t *p, u_char *buf, int buf_len, - time_t first_time, time_t last_time, +find_header( pcap_t *p, u_char *buf, const int buf_len, + const time_t first_time, const time_t last_time, u_char **hdrpos_addr, struct pcap_pkthdr *return_hdr ) - { +{ u_char *bufptr, *bufend, *last_pos_to_try; struct pcap_pkthdr hdr, hdr2; int status = HEADER_NONE; @@ -227,22 +220,22 @@ last_pos_to_try = bufend - PACKET_HDR_LEN; for ( bufptr = buf; bufptr < last_pos_to_try; ++bufptr ) - { + { extract_header( p, bufptr, &hdr ); if ( reasonable_header( &hdr, first_time, last_time ) ) - { + { u_char *next_header = bufptr + PACKET_HDR_LEN + hdr.caplen; if ( next_header + PACKET_HDR_LEN < bufend ) - { /* check for another good header */ + { /* check for another good header */ extract_header( p, next_header, &hdr2 ); if ( reasonable_header( &hdr2, hdr.ts.tv_sec, hdr.ts.tv_sec + MAX_REASONABLE_HDR_SEPARATION ) ) - { /* a confirmed header */ + { /* a confirmed header */ switch ( status ) - { + { case HEADER_NONE: case HEADER_PERHAPS: status = HEADER_DEFINITELY; @@ -261,18 +254,17 @@ default: error( "bad status in %s()", __func__ ); - } } + } /* ... else the header is bogus - we've verified that it's * not followed by a reasonable header. */ - } - + } else - { /* can't check for another good header */ + { /* can't check for another good header */ switch ( status ) - { + { case HEADER_NONE: status = HEADER_PERHAPS; *hdrpos_addr = bufptr; @@ -293,17 +285,16 @@ default: error( "bad status in %s()", __func__ ); - } } } } + } if ( status == HEADER_PERHAPS && saw_PERHAPS_clash ) status = HEADER_CLASH; return status; - } - +} /* Positions the sf_readfile stream such that the next sf_read() will * read the final full packet in the file. Returns non-zero if @@ -316,9 +307,9 @@ * present in the dump file. */ int -sf_find_end( pcap_t *p, struct timeval *first_timestamp, +sf_find_end( pcap_t *p, const struct timeval *first_timestamp, struct timeval *last_timestamp ) - { +{ time_t first_time = first_timestamp->tv_sec; int64_t len_file; int num_bytes; @@ -367,7 +358,7 @@ * chain till we find the last valid packet in the file ... */ for ( ; ; ) - { + { /* move to the next header position */ bufpos = hdrpos + PACKET_HDR_LEN + hdr.caplen; @@ -403,56 +394,50 @@ /* Accept this packet as fully legit. */ hdrpos = bufpos; hdr = successor_hdr; - } + } /* Success! Last valid packet is at hdrpos. */ - *last_timestamp = hdr.ts; + TIMEVAL_FROM_PKTHDR_TS(*last_timestamp, hdr.ts); status = 1; /* Seek so that the next read will start at last valid packet. */ if ( fseek64( pcap_file( p ), -(int64_t) (bufend - hdrpos), SEEK_END ) < 0 ) - error( "final " S(fseek64) "() failed in %s()", __func__ ); + error( "final fseek64() failed in %s()", __func__ ); done: free( (char *) buf ); return status; - } - +} /* Takes two timeval's and returns the difference, tv2 - tv1, as a double. */ - static double -timeval_diff( struct timeval *tv1, struct timeval *tv2 ) - { +timeval_diff( const struct timeval *tv1, const struct timeval *tv2 ) +{ double result = (tv2->tv_sec - tv1->tv_sec); result += (tv2->tv_usec - tv1->tv_usec) / 1000000.0; return result; - } - +} /* Returns true if timestamp t1 is chronologically less than timestamp t2. */ - int -sf_timestamp_less_than( struct timeval *t1, struct timeval *t2 ) - { +sf_timestamp_less_than( const struct timeval *t1, const struct timeval *t2 ) +{ return t1->tv_sec < t2->tv_sec || (t1->tv_sec == t2->tv_sec && t1->tv_usec < t2->tv_usec); - } - +} /* Given two timestamps on either side of desired_time and their positions, * returns the interpolated position of the desired_time packet. Returns a * negative value if the desired_time is outside the given range. */ - static int64_t -interpolated_position( struct timeval *min_time, int64_t min_pos, - struct timeval *max_time, int64_t max_pos, - struct timeval *desired_time ) - { +interpolated_position( const struct timeval *min_time, const int64_t min_pos, + const struct timeval *max_time, const int64_t max_pos, + const struct timeval *desired_time ) +{ double full_span = timeval_diff( max_time, min_time ); double desired_span = timeval_diff( desired_time, min_time ); int64_t full_span_pos = max_pos - min_pos; @@ -462,32 +447,28 @@ return -1; return min_pos + (int64_t) (fractional_offset * (double) full_span_pos); - } - +} /* Reads packets linearly until one with a time >= the given desired time * is found; positions the dump file so that the next read will start * at the given packet. Returns non-zero on success, 0 if an EOF was * first encountered. */ - static int -read_up_to( pcap_t *p, struct timeval *desired_time ) - { +read_up_to( pcap_t *p, const struct timeval *desired_time ) +{ struct pcap_pkthdr hdr; - const u_char *buf; int64_t pos; int status; for ( ; ; ) - { - struct timeval *timestamp; + { + struct timeval tvbuf; pos = ftell64( pcap_file( p ) ); - buf = pcap_next( p, &hdr ); - if ( buf == 0 ) - { + if ( pcap_next( p, &hdr ) == NULL ) + { if ( feof( pcap_file( p ) ) ) { status = 0; @@ -496,22 +477,22 @@ } error( "bad status in %s()", __func__ ); - } + } - timestamp = &hdr.ts; + TIMEVAL_FROM_PKTHDR_TS(tvbuf, hdr.ts); - if ( ! sf_timestamp_less_than( timestamp, desired_time ) ) - { + if ( ! sf_timestamp_less_than( &tvbuf, desired_time ) ) + { status = 1; break; - } } + } if ( fseek64( pcap_file( p ), pos, SEEK_SET ) < 0 ) - error( S(fseek64) "() failed in %s()", __func__ ); + error( "fseek64() failed in %s()", __func__ ); return (status); - } +} /* Positions the sf_readfile stream so that the next sf_read() will * return the first packet with a time greater than or equal to @@ -526,24 +507,21 @@ * already aligned so that the next call to sf_next_packet() will yield * a valid packet. */ - int sf_find_packet( pcap_t *p, struct timeval *min_time, int64_t min_pos, struct timeval *max_time, int64_t max_pos, - struct timeval *desired_time ) - { + const struct timeval *desired_time ) +{ int status = 1; struct timeval min_time_copy, max_time_copy; u_int num_bytes = MAX_BYTES_FOR_DEFINITE_HEADER; - int num_bytes_read; - int64_t desired_pos, present_pos; u_char *buf, *hdrpos; struct pcap_pkthdr hdr; buf = (u_char *) malloc( num_bytes ); if ( ! buf ) - error( "malloc() failured in %s()", __func__ ); + error( "malloc() failed in %s()", __func__ ); min_time_copy = *min_time; min_time = &min_time_copy; @@ -552,11 +530,12 @@ max_time = &max_time_copy; for ( ; ; ) /* loop until positioned correctly */ - { - desired_pos = + { + int64_t desired_pos = interpolated_position( min_time, min_pos, max_time, max_pos, desired_time ); + struct timeval tvbuf; if ( desired_pos < 0 ) { @@ -564,16 +543,16 @@ break; } - present_pos = ftell64( pcap_file( p ) ); + int64_t present_pos = ftell64( pcap_file( p ) ); if ( present_pos < 0 ) - error ( S(ftell64) "() failed in %s()", __func__ ); + error ( "ftell64() failed in %s()", __func__ ); if ( present_pos <= desired_pos && (uint64_t) (desired_pos - present_pos) < STRAIGHT_SCAN_THRESHOLD ) - { /* we're close enough to just blindly read ahead */ + { /* we're close enough to just blindly read ahead */ status = read_up_to( p, desired_time ); break; - } + } /* Undershoot the target a little bit - it's much easier to * then scan straight forward than to try to read backwards ... @@ -583,9 +562,9 @@ desired_pos = min_pos; if ( fseek64( pcap_file( p ), desired_pos, SEEK_SET ) < 0 ) - error( S(fseek64) "() failed in %s()", __func__ ); + error( "fseek64() failed in %s()", __func__ ); - num_bytes_read = + int num_bytes_read = fread( (char *) buf, 1, num_bytes, pcap_file( p ) ); if ( num_bytes_read == 0 ) @@ -606,26 +585,27 @@ /* Seek to the beginning of the header. */ if ( fseek64( pcap_file( p ), desired_pos, SEEK_SET ) < 0 ) - error( S(fseek64) "() failed in %s()", __func__ ); + error( "fseek64() failed in %s()", __func__ ); - if ( sf_timestamp_less_than( &hdr.ts, desired_time ) ) - { /* too early in the file */ - *min_time = hdr.ts; + TIMEVAL_FROM_PKTHDR_TS(tvbuf, hdr.ts); + if ( sf_timestamp_less_than( &tvbuf, desired_time ) ) + { /* too early in the file */ + *min_time = tvbuf; min_pos = desired_pos; - } + } - else if ( sf_timestamp_less_than( desired_time, &hdr.ts ) ) - { /* too late in the file */ - *max_time = hdr.ts; + else if ( sf_timestamp_less_than( desired_time, &tvbuf ) ) + { /* too late in the file */ + *max_time = tvbuf; max_pos = desired_pos; - } + } else /* got it! */ break; - } + } free( (char *) buf ); return status; - } +} diff -Nru tcpslice-1.3/seek-tell.c tcpslice-1.5/seek-tell.c --- tcpslice-1.3/seek-tell.c 2020-08-19 18:16:16.000000000 +0000 +++ tcpslice-1.5/seek-tell.c 2021-10-07 12:13:20.000000000 +0000 @@ -39,7 +39,7 @@ * with more than 32 bits. */ int -fseek64(FILE *p, int64_t offset, int whence) +fseek64(FILE *p, const int64_t offset, const int whence) { off_t off_t_offset; @@ -68,7 +68,7 @@ * _fseeki64() and _ftelli64(). */ int -fseek64(FILE *p, int64_t offset, int whence) +fseek64(FILE *p, const int64_t offset, const int whence) { return (_fseeki64(p, offset, whence)); } @@ -89,7 +89,7 @@ * XXX - what about MinGW? */ int -fseek64(FILE *p, int64_t offset, int whence) +fseek64(FILE *p, const int64_t offset, const int whence) { long long_offset; diff -Nru tcpslice-1.3/sessions.c tcpslice-1.5/sessions.c --- tcpslice-1.3/sessions.c 2020-08-19 18:16:16.000000000 +0000 +++ tcpslice-1.5/sessions.c 2021-10-07 12:13:20.000000000 +0000 @@ -43,12 +43,17 @@ * - tcp_callback() is called upon reception of correct TCP data */ +#ifdef HAVE_CONFIG_H +#include +#endif + #include #include #include #include "varattrs.h" #include "sessions.h" +#include "diag-control.h" /* * The global variables below have the following purposes: @@ -69,7 +74,7 @@ * * `track_sessions' is a flag set by sessions_init() and * sessions_exit() but it is mostly used in tcpslice.c to know - * wether or not to pass each PCAP frame to libnids in order to + * whether or not to pass each PCAP frame to libnids in order to * track sessions (it saves further processing if the user did * not want to track sessions, which should be the case most of * the time). @@ -101,16 +106,12 @@ char *sessions_file_format = NULL; time_t sessions_expiration_delay = 0; -#ifdef HAVE_CONFIG_H -# include -#endif - #ifndef HAVE_LIBNIDS -void sessions_init(char *types _U_) +void +sessions_init(const char *types _U_) { - fprintf(stderr, "Libnids required for session tracking support, sorry.\n"); - exit(-1); + error("libnids required for session tracking support, sorry."); } void sessions_exit(void) @@ -121,30 +122,33 @@ { } -#else +#else /* HAVE_LIBNIDS */ # include # include # ifdef HAVE_LIBOSIPPARSER2 # include # include -# endif +# endif /* HAVE_LIBOSIPPARSER2 */ # ifdef HAVE_LIBOOH323C # include # include # include -# endif +# include +# endif /* HAVE_LIBOOH323C */ # include "tcpslice.h" # include -# define IPHDRLEN sizeof(struct ip) +# define IPHDRLEN (sizeof(struct ip)) # include -# define UDPHDRLEN sizeof(struct udphdr) +# define UDPHDRLEN (sizeof(struct udphdr)) # include -# define TCPHDRLEN sizeof(struct tcphdr) +# define TCPHDRLEN (sizeof(struct tcphdr)) +# include +# include /* * Session type identifiers, used as bitmasks for - * convenience in searchs among tracked sessions. + * convenience in searches among tracked sessions. */ enum type { @@ -208,26 +212,24 @@ # if defined(HAVE_LIBOSIPPARSER2) || defined(HAVE_LIBOOH323C) union { -# endif -# ifdef HAVE_LIBOSIPPARSER2 +# ifdef HAVE_LIBOSIPPARSER2 struct { struct tuple4 rtp_addr; osip_call_id_t *call_id; int picked_up; } sip_params; -# endif -# ifdef HAVE_LIBOOH323C +# endif /* HAVE_LIBOSIPPARSER2 */ +# ifdef HAVE_LIBOOH323C struct { struct tuple4 cs_addr; H225RequestSeqNum seqnum; char call_id[16]; } ras_params; -# endif -# if defined(HAVE_LIBOSIPPARSER2) || defined(HAVE_LIBOOH323C) +# endif /* HAVE_LIBOOH323C */ } u; -# endif +# endif /* defined(HAVE_LIBOSIPPARSER2) || defined(HAVE_LIBOOH323C) */ }; /* @@ -284,15 +286,15 @@ * ITU's H.225 Registration Admission Status and H.225 Call Signaling (both * part of H.323) data. */ -static struct session *sessions_add(uint8_t t, struct tuple4 *addr, struct session *parent); +static struct session *sessions_add(const uint8_t t, const struct tuple4 *addr, const struct session *parent); static void sessions_del(struct session *elt); -static struct session *sessions_find(struct session *start, uint8_t t, uint32_t parent_id, struct tuple4 *addr); -static struct shared_dumper *dumper_open(enum type t, uint32_t id); +static struct session *sessions_find(struct session *start, const uint8_t t, const uint32_t parent_id, const struct tuple4 *addr); +static struct shared_dumper *dumper_open(const enum type t, const uint32_t id); static void dumper_too_many_open_files(struct shared_dumper **d); static void dumper_close(struct shared_dumper *d); -static void dump_frame(u_char *data, int len, struct shared_dumper *output); +static void dump_frame(const u_char *data, const int len, struct shared_dumper *output); static enum type parse_type(const char *str); -static const char *type2string(enum type t, int upper); +static const char *type2string(const enum type t, const int upper); static void ip_callback(struct ip *ip, int len); static void tcp_callback(struct tcp_stream *tcp, void **user); static void udp_callback(struct tuple4 *addr, u_char *data, int len, struct ip *ip); @@ -307,19 +309,20 @@ # ifdef HAVE_LIBOSIPPARSER2 if (!strcmp("sip", str)) return CLASS_SIP; -# endif +# endif /* HAVE_LIBOSIPPARSER2 */ # ifdef HAVE_LIBOOH323C if (!strcmp("h323", str)) return CLASS_H323; -# endif - fprintf(stderr, "Error: unsupported session type `%s'\n", str); - exit(-1); +# endif /* HAVE_LIBOOH323C */ + error("unsupported session type `%s'", str); + /* NOTREACHED */ + return TYPE_NONE; } -void sessions_init(char *types) +void +sessions_init(const char *types) { char *comma; - struct session *elt; bonus_time = 0; sessions_track_types = TYPE_NONE; @@ -330,7 +333,7 @@ } sessions_track_types |= parse_type(types); while (sessions_count) { - elt = first_session; + struct session *elt = first_session; first_session = first_session->next; --sessions_count; dumper_close(elt->dumper); @@ -339,7 +342,7 @@ # ifdef HAVE_LIBOOH323C ooH323EpInitialize(OO_CALLMODE_AUDIOCALL, "/dev/null"); ooH323EpDisableAutoAnswer(); -# endif +# endif /* HAVE_LIBOOH323C */ track_sessions = 1; } @@ -375,7 +378,7 @@ # ifdef HAVE_LIBOSIPPARSER2 if ((elt->type & TYPE_SIP) && !elt->u.sip_params.picked_up) sessions_del(elt); -# endif +# endif /* HAVE_LIBOSIPPARSER2 */ } /* @@ -383,10 +386,10 @@ */ if (sessions_count) { fprintf(stderr, - "%d unclosed %s (id, type, last, source, destination, bytes):\n", + "%u unclosed %s (id, type, last, source, destination, bytes):\n", sessions_count, sessions_count > 1 ? "sessions" : "session"); while (NULL != first_session) { - fprintf(stderr, "#%d\t", first_session->id); + fprintf(stderr, "#%u\t", first_session->id); fprintf(stderr, "%s\t", type2string(first_session->type, 1)); fprintf(stderr, "%s\t", timestamp_to_string(&first_session->lastseen)); fprintf(stderr, "%15s:%-5d\t", @@ -417,15 +420,22 @@ nids_params.pcap_desc = p; nids_params.tcp_workarounds = 1; if (!nids_init()) { - fprintf(stderr, "nids_init: %s\n", nids_errbuf); - exit(-1); + error("%s(): %s", __func__, nids_errbuf); } + /* + * These conversions between function pointer and void pointer upset GCC, + * Clang and XL C. + * See also: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=83584 + */ + DIAG_OFF_PEDANTIC nids_register_ip(ip_callback); nids_register_udp(udp_callback); nids_register_tcp(tcp_callback); + DIAG_ON_PEDANTIC } -static struct session *sessions_add(uint8_t t, struct tuple4 *addr, struct session *parent) +static struct session * +sessions_add(const uint8_t t, const struct tuple4 *addr, const struct session *parent) { struct session *elt; static uint32_t counter = 0; @@ -461,7 +471,7 @@ first_session = elt; ++sessions_count; if (verbose && (!elt->parent_id || verbose > 1)) - printf("Session #%d (%s) opened at %s (active sessions total: %d)\n", + printf("Session #%u (%s) opened at %s (active sessions total: %u)\n", elt->parent_id ? elt->parent_id : elt->id, type2string(t, 1), timestamp_to_string(&nids_last_pcap_header->ts), @@ -477,7 +487,7 @@ return; --sessions_count; if ((bonus_time || verbose) && (!elt->parent_id || verbose > 1)) - printf("Session #%d (%s) closed at %s (active sessions total: %d)\n", + printf("Session #%u (%s) closed at %s (active sessions total: %u)\n", elt->parent_id ? elt->parent_id : elt->id, type2string(elt->type, 1), timestamp_to_string(&nids_last_pcap_header->ts), @@ -511,13 +521,14 @@ if (elt->type & TYPE_SIP) if (NULL != elt->u.sip_params.call_id) osip_call_id_free(elt->u.sip_params.call_id); -# endif +# endif /* HAVE_LIBOSIPPARSER2 */ dumper_close(elt->dumper); free(elt); } -static struct session *sessions_find(struct session *start, uint8_t t, uint32_t parent_id, struct tuple4 *addr) +static struct session * +sessions_find(struct session *start, const uint8_t t, const uint32_t parent_id, const struct tuple4 *addr) { struct session *elt; @@ -544,7 +555,8 @@ return NULL; } -static struct shared_dumper *dumper_open(enum type t, uint32_t id) +static struct shared_dumper * +dumper_open(const enum type t, const uint32_t id) { struct shared_dumper *d; @@ -578,11 +590,9 @@ (*d)->filedesc = pcap_dump_open(nids_params.pcap_desc, (*d)->filename); } if (NULL == (*d)->filedesc) { - fprintf(stderr, - "pcap_dump_open: %s: %s\n", + error("%s(): %s: %s", __func__, (*d)->filename, pcap_geterr(nids_params.pcap_desc)); - exit(-1); } } @@ -600,7 +610,8 @@ } } -static const char *type2string(enum type t, int upper) +static const char * +type2string(const enum type t, const int upper) { if (t & TYPE_SIP) return upper ? "SIP" : "sip"; @@ -613,7 +624,8 @@ return "???"; } -static void dump_frame(u_char *data, int len, struct shared_dumper *output) +static void +dump_frame(const u_char *data, const int len, struct shared_dumper *output) { u_char *frame; struct pcap_pkthdr ph; @@ -658,6 +670,9 @@ struct session *elt_next; unsigned int ip_data_offset = IPHDRLEN; + if (len < 0) + error("%s(): len < 0", __func__); + for (elt = first_session; NULL != elt; elt = elt_next) { elt_next = elt->next; if (elt->timeout && (nids_last_pcap_header->ts.tv_sec >= elt->timeout)) @@ -665,7 +680,7 @@ } if ((ip->ip_hl > 5) && ((ip->ip_hl * 4) <= len)) ip_data_offset = ip->ip_hl * 4; - if ((ip->ip_p != 6) || (len < (ip_data_offset + TCPHDRLEN))) + if ((ip->ip_p != 6) || ((unsigned)len < (ip_data_offset + TCPHDRLEN))) return; /* not TCP or too short */ tcp = (struct tcphdr *)((char *)ip + ip_data_offset); addr.saddr = *((u_int *)&ip->ip_src); @@ -718,7 +733,7 @@ * a new session object (`elt') might be created by the callback, * with a pointer to a different PCAP file. */ - if ((ip->ip_hl > 5) && ((ip->ip_hl * 4) < (udp_data_offset + udp_data_len))) + if ((ip->ip_hl > 5) && ((ip->ip_hl * 4U) < (udp_data_offset + udp_data_len))) udp_data_offset = ip->ip_hl * 4 + UDPHDRLEN; dump_frame((u_char *)ip, udp_data_offset + udp_data_len, elt->dumper); } @@ -767,12 +782,17 @@ } } -# ifdef HAVE_LIBOSIPPARSER2 -static int sip_get_address(osip_message_t *msg, u_int *host, u_short *port) +# ifndef HAVE_LIBOSIPPARSER2 +static struct session *sip_callback(struct session *sip, u_char *data _U_, uint32_t len _U_) +{ + return sip; +} +# else /* HAVE_LIBOSIPPARSER2 */ +static int +sip_get_address(const osip_message_t *msg, u_int *host, u_short *port) { osip_content_type_t *ctt; sdp_message_t *sdp; - char *tmp; int i; int j; @@ -787,7 +807,7 @@ for (i = 0; !osip_list_eol(&msg->bodies, i); ++i) { sdp = NULL; sdp_message_init(&sdp); - tmp = ((osip_body_t *)osip_list_get(&msg->bodies, i))->body; + char *tmp = ((osip_body_t *)osip_list_get(&msg->bodies, i))->body; if (sdp_message_parse(sdp, tmp)) { sdp_message_free(sdp); continue; @@ -904,14 +924,19 @@ osip_message_free(msg); return sip; } -# else -static struct session *sip_callback(struct session *sip, u_char *data _U_, uint32_t len _U_) +# endif /* HAVE_LIBOSIPPARSER2 */ + +# ifndef HAVE_LIBOOH323C +static struct session *h225_ras_callback(struct session *ras, u_char *data _U_, uint32_t len _U_) { - return sip; + return ras; } -# endif -# ifdef HAVE_LIBOOH323C +static struct session *h225_cs_callback(struct session *cs, u_char *data _U_, uint32_t len _U_) +{ + return cs; +} +# else /* HAVE_LIBOOH323C */ static struct session *h225_ras_callback(struct session *ras, u_char *data, uint32_t len) { OOCTXT ctxt; @@ -987,8 +1012,13 @@ return ras; } -static struct session *h225_cs_callback(struct session *cs, u_char *data, uint32_t len) +static struct session *h225_cs_callback(struct session *cs, u_char *data, uint32_t len _U_) { + /* ooCreateCall() for some reason declares its read-only first argument as + * "char *" instead of "const char *", wrap the string in an array in order + * not to upset the compiler. + */ + char callType[] = "incoming"; char callToken[20]; OOH323CallData *call; Q931Message q931; @@ -998,7 +1028,7 @@ struct tuple4 addr; ooGenerateCallToken(callToken, 20); - call = ooCreateCall("incoming", callToken); + call = ooCreateCall(callType, callToken); call->pH225Channel = (OOH323Channel*) memAllocZ (call->pctxt, sizeof (OOH323Channel)); if (OO_OK == ooQ931Decode(call, &q931, ntohs(*((u_short *)(data + 2))) - 4, data + 4)) { if (OO_OK == ooHandleH2250Message(call, &q931)) { @@ -1034,17 +1064,6 @@ ooCleanCall(call); return cs; } +# endif /* HAVE_LIBOOH323C */ -# else -static struct session *h225_ras_callback(struct session *ras, u_char *data _U_, uint32_t len _U_) -{ - return ras; -} - -static struct session *h225_cs_callback(struct session *cs, u_char *data _U_, uint32_t len _U_) -{ - return cs; -} -# endif - -#endif +#endif /* HAVE_LIBNIDS */ diff -Nru tcpslice-1.3/sessions.h tcpslice-1.5/sessions.h --- tcpslice-1.3/sessions.h 2020-08-19 18:16:16.000000000 +0000 +++ tcpslice-1.5/sessions.h 2021-10-07 12:13:20.000000000 +0000 @@ -25,10 +25,10 @@ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ -#ifndef _TCPSLICE_SESSIONS_H -# define _TCPSLICE_SESSIONS_H +#ifndef TCPSLICE_SESSIONS_H +# define TCPSLICE_SESSIONS_H -# include +# include "tcpslice.h" /* can be complicated. */ # include # include @@ -39,8 +39,8 @@ extern char *sessions_file_format; extern time_t sessions_expiration_delay; -void sessions_init(char *types); +void sessions_init(const char *types); void sessions_exit(void); void sessions_nids_init(pcap_t *p); -#endif +#endif /* TCPSLICE_SESSIONS_H */ diff -Nru tcpslice-1.3/tcpslice.c tcpslice-1.5/tcpslice.c --- tcpslice-1.3/tcpslice.c 2020-08-19 18:16:16.000000000 +0000 +++ tcpslice-1.5/tcpslice.c 2021-12-30 20:50:54.000000000 +0000 @@ -30,6 +30,7 @@ #include #include #include +#include #include #ifdef HAVE_FCNTL_H @@ -58,15 +59,20 @@ #ifdef HAVE_LIBNIDS #include -#endif +# ifdef HAVE_LIBOOH323C +# include +# endif /* HAVE_LIBOOH323C */ +#endif /* HAVE_LIBNIDS */ #include "tcpslice.h" #include "gmt2local.h" #include "machdep.h" #include "sessions.h" +/* For Solaris before 11. */ /* compute a + b, store in c */ -#define TV_ADD(a,b,c) { \ +#ifndef timeradd +#define timeradd(a, b, c) { \ (c)->tv_sec = (a)->tv_sec + (b)->tv_sec; \ (c)->tv_usec = (a)->tv_usec + (b)->tv_usec; \ if ((c)->tv_usec > 1000000) { \ @@ -74,9 +80,10 @@ (c)->tv_sec += 1; \ } \ } - +#endif /* timeradd */ /* compute a - b, store in c */ -#define TV_SUB(a,b,c) { \ +#ifndef timersub +#define timersub(a, b, c) { \ (c)->tv_sec = (a)->tv_sec - (b)->tv_sec; \ if ((a)->tv_usec < (b)->tv_usec) { \ (c)->tv_sec -= 1; /* need to borrow */ \ @@ -85,6 +92,7 @@ (c)->tv_usec = (a)->tv_usec - (b)->tv_usec; \ } \ } +#endif /* timersub */ /* The structure used to keep track of files being merged. */ struct state { @@ -134,17 +142,19 @@ static unsigned char timestamp_input_format_correct(const char *str); -static struct timeval parse_time(char *time_string, struct timeval base_time); -static void fill_tm(char *time_string, int is_delta, struct tm *t, time_t *usecs_addr); -static struct timeval lowest_start_time(struct state *states, int numfiles); -static struct timeval latest_end_time(struct state *states, int numfiles); -static struct state *open_files(char *filenames[], int numfiles); -static void extract_slice(struct state *states, int numfiles, +static struct timeval parse_time(const char *time_string, struct timeval base_time); +static void fill_tm(const char *time_string, const int is_delta, struct tm *t, time_t *usecs_addr); +static struct timeval lowest_start_time(const struct state *states, int numfiles); +static struct timeval latest_end_time(const struct state *states, int numfiles); +static struct state *open_files(char *filenames[], const int numfiles); +static u_char validate_files(struct state[], const int); +static void close_files(struct state[], const int); +static void extract_slice(struct state *states, const int numfiles, const char *write_file_name, - struct timeval *start_time, struct timeval *stop_time, - int keep_dups, int relative_time_merge, - struct timeval *base_time); -static void dump_times(struct state *states, int numfiles); + const struct timeval *start_time, struct timeval *stop_time, + const int keep_dups, const int relative_time_merge, + const struct timeval *base_time); +static void dump_times(const struct state *states, int numfiles); static void print_usage(FILE *); @@ -274,6 +284,9 @@ keep_dups = 1; /* no dups can occur, so don't do the work */ states = open_files(&argv[optind], numfiles); + /* validate_files() might identify multiple issues before returning. */ + if (validate_files(states, numfiles)) + exit(1); first_time = lowest_start_time(states, numfiles); if (start_time_string) @@ -306,6 +319,7 @@ &first_time); } + close_files (states, numfiles); return 0; } @@ -318,13 +332,13 @@ timestamp_raw_format_correct(const char *str) { enum { START, SECONDS, POINT, MICROSECONDS } fsm_state = START; - uint64_t s_value; - unsigned us_digits; + uint64_t s_value = 0; /* Initialize to squelch a warning. */ + unsigned us_digits = 0; /* Initialize to squelch a warning. */ while (1) { switch (fsm_state) { case START: /* Have not seen anything yet. */ - if (! isdigit(*str)) + if (! isdigit((u_char)*str)) return 0; s_value = *str - '0'; fsm_state = SECONDS; @@ -336,12 +350,12 @@ fsm_state = POINT; break; } - if (! isdigit(*str) || + if (! isdigit((u_char)*str) || (s_value = s_value * 10 + *str - '0') > TS_RAW_S_MAX_VALUE) return 0; break; case POINT: /* Have seen the decimal point. */ - if (! isdigit(*str)) + if (! isdigit((u_char)*str)) return 0; us_digits = 1; fsm_state = MICROSECONDS; @@ -349,7 +363,7 @@ case MICROSECONDS: /* Have seen one or more digits for the microseconds. */ if (*str == '\0') return 1; /* "uuuuuuuuu.ssssss" */ - if (! isdigit(*str) || ++us_digits > TS_RAW_US_MAX_DIGITS) + if (! isdigit((u_char)*str) || ++us_digits > TS_RAW_US_MAX_DIGITS) return 0; break; default: @@ -370,25 +384,25 @@ parse_token(const char *str, struct parseable_token_t *token) { enum { START, AMOUNT, UNIT } fsm_state = START; - uint64_t amount; - char char_unit; + uint64_t amount = 0; /* Initialize to squelch a warning. */ + char char_unit = 0; /* Initialize to squelch a warning. */ while (1) { switch (fsm_state) { case START: /* Have not seen anything yet. */ - if (! isdigit(*str)) + if (! isdigit((u_char)*str)) return NULL; amount = *str - '0'; fsm_state = AMOUNT; break; case AMOUNT: /* Have seen one or more digits for the amount. */ - if (isalpha(*str)) { + if (isalpha((u_char)*str)) { token->amount = amount; - char_unit = tolower(*str); + char_unit = tolower((u_char)*str); fsm_state = UNIT; break; } - if (! isdigit(*str) || + if (! isdigit((u_char)*str) || (amount = amount * 10 + *str - '0') > INT32_MAX) return NULL; break; @@ -507,16 +521,15 @@ error("minute %d is not valid\n", t.tm_min); if (t.tm_sec < 0 || t.tm_sec > 59) - error("seconds %d is not valid\n", t.tm_sec); + error("second %d is not valid\n", t.tm_sec); } /* Given a string specifying a time (or a time offset) and a "base time" * from which to compute offsets and fill in defaults, returns a timeval * containing the specified time. */ - static struct timeval -parse_time(char *time_string, struct timeval base_time) +parse_time(const char *time_string, struct timeval base_time) { struct tm *bt = localtime((time_t *) &base_time.tv_sec); struct tm t; @@ -548,7 +561,7 @@ result.tv_usec = 0; if ( is_delta ) - TV_ADD(&result, &base_time, &result); + timeradd(&result, &base_time, &result); return result; } @@ -611,17 +624,15 @@ return result; } - /* Fill in (or add to, if is_delta is true) the time values in the * tm struct "t" as specified by the time specified in the string * "time_string". "usecs_addr" is updated with the specified number * of microseconds, if any. */ static void -fill_tm(char *time_string, int is_delta, struct tm *t, time_t *usecs_addr) +fill_tm(const char *time_string, const int is_delta, struct tm *t, time_t *usecs_addr) { - char *t_start, *t_stop, format_ch; - int val; + const char *t_start, *t_stop; #define SET_VAL(lhs,rhs) \ if (is_delta) \ @@ -635,21 +646,21 @@ * the units. */ for (t_stop = t_start = time_string; *t_start; t_start = ++t_stop) { - if (! isdigit(*t_start)) + if (! isdigit((u_char)*t_start)) error("bad date format %s, problem starting at %s", time_string, t_start); - while (isdigit(*t_stop)) + while (isdigit((u_char)*t_stop)) ++t_stop; if (! (*t_stop)) error("bad date format %s, problem starting at %s", time_string, t_start); - val = atoi(t_start); + int val = atoi(t_start); - format_ch = *t_stop; - if ( isupper( format_ch ) ) - format_ch = tolower( format_ch ); + char format_ch = *t_stop; + if (isupper((u_char)format_ch)) + format_ch = tolower((u_char)format_ch); switch (format_ch) { case 'y': @@ -693,11 +704,9 @@ } } - - /* Of all the files, what is the lowest start time. */ static struct timeval -lowest_start_time(struct state *states, int numfiles) +lowest_start_time(const struct state *states, int numfiles) { struct timeval min_time = states->file_start_time; @@ -712,9 +721,9 @@ /* Of all the files, what is the latest end time. */ static struct timeval -latest_end_time(struct state *states, int numfiles) +latest_end_time(const struct state *states, int numfiles) { - struct timeval max_time = states->file_start_time; + struct timeval max_time = states->file_stop_time; while (numfiles--) { if (sf_timestamp_less_than(&max_time, &states->file_stop_time)) { @@ -730,10 +739,11 @@ * This routine also prevents time from going "backwards" * within a single file. */ - static void get_next_packet(struct state *s) { + struct timeval tvbuf; + do { s->pkt = pcap_next(s->p, &s->hdr); if (! s->pkt) { @@ -742,19 +752,20 @@ sessions_exit(); pcap_close(s->p); } + TIMEVAL_FROM_PKTHDR_TS(tvbuf, s->hdr.ts); } while ((! s->done) && - sf_timestamp_less_than(&s->hdr.ts, &s->last_pkt_time)); + sf_timestamp_less_than(&tvbuf, &s->last_pkt_time)); - s->last_pkt_time = s->hdr.ts; + s->last_pkt_time = tvbuf; } static struct state * -open_files(char *filenames[], int numfiles) +open_files(char *filenames[], const int numfiles) { struct state *states; struct state *s; char errbuf[PCAP_ERRBUF_SIZE]; - int i, this_snap; + int i; if (numfiles == 0) error("no input files specified"); @@ -774,18 +785,18 @@ if (track_sessions) sessions_nids_init(s->p); - this_snap = pcap_snapshot( s->p ); + int this_snap = pcap_snapshot( s->p ); if (this_snap > snaplen) { snaplen = this_snap; } s->start_pos = ftell64( pcap_file( s->p ) ); - if (pcap_next(s->p, &s->hdr) == 0) + if (pcap_next(s->p, &s->hdr) == NULL) error( "error reading packet in %s: %s", s->filename, pcap_geterr( s->p ) ); - s->file_start_time = s->hdr.ts; + TIMEVAL_FROM_PKTHDR_TS(s->file_start_time, s->hdr.ts); if ( ! sf_find_end( s->p, &s->file_start_time, &s->file_stop_time ) ) @@ -798,6 +809,44 @@ return states; } +/* Return 0 on no errors. */ +static u_char +validate_files(struct state states[], const int numfiles) +{ + u_char ret = 0; + int i, first_dlt, this_dlt; + + for (i = 0; i < numfiles; i++) { + this_dlt = pcap_datalink(states[i].p); + if (i == 0) + first_dlt = this_dlt; + else if (first_dlt != this_dlt) { + warning("file '%s' uses DLT %d, and the first file '%s' uses DLT %d", + states[i].filename, this_dlt, states[0].filename, first_dlt); + ret = 1; + } + + /* Do a minimal sanity check of the timestamps. */ + if (sf_timestamp_less_than(&states[i].file_stop_time, + &states[i].file_start_time)) { + warning("'%s' has the last timestamp before the first timestamp", + states[i].filename); + ret = 1; + } + } + return ret; +} + +static void +close_files(struct state states[], const int numfiles) +{ + int i; + + for (i = 0; i < numfiles; i++) + if (!states[i].done) + pcap_close(states[i].p); + free(states); +} /* * Extract from a given set of files all packets with timestamps between @@ -807,12 +856,11 @@ * Upon return, start_time is adjusted to reflect a time just after * that of the last packet written to the output. */ - static void -extract_slice(struct state *states, int numfiles, const char *write_file_name, - struct timeval *start_time, struct timeval *stop_time, - int keep_dups, int relative_time_merge, - struct timeval *base_time) +extract_slice(struct state *states, const int numfiles, const char *write_file_name, + const struct timeval *start_time, struct timeval *stop_time, + const int keep_dups, const int relative_time_merge, + const struct timeval *base_time) { struct state *s, *min_state; struct timeval temp1, temp2, relative_start, relative_stop; @@ -835,8 +883,15 @@ memset(last_pkt, 0, snaplen); - TV_SUB(start_time, base_time, &relative_start); - TV_SUB(stop_time, base_time, &relative_stop); + timersub(start_time, base_time, &relative_start); + timersub(stop_time, base_time, &relative_stop); + + /* Always write the output file, use the first input file's DLT. */ + global_dumper = pcap_dump_open(states[0].p, write_file_name); + if (!global_dumper) { + error("error creating output file '%s': %s", + write_file_name, pcap_geterr(states[0].p)); + } for (i = 0; i < numfiles; ++i) { s = &states[i]; @@ -844,7 +899,7 @@ /* compute the first packet time within *this* file */ if (relative_time_merge) { /* relative time within this file */ - TV_ADD(&s->file_start_time, &relative_start, &temp1); + timeradd(&s->file_start_time, &relative_start, &temp1); } else { /* absolute time */ temp1 = *start_time; @@ -876,15 +931,9 @@ get_next_packet(s); } - global_dumper = pcap_dump_open(states->p, write_file_name); - if (!global_dumper) { - error( "error creating output file %s: %s", - write_file_name, pcap_geterr( states->p ) ); - } - /* - * Now, loop thru all the packets in all the files, + * Now, loop through all the packets in all the files, * putting packets out in timestamp order. * * Quite often, the files will not have overlapping @@ -893,6 +942,8 @@ */ while (1) { + struct timeval tvbuf; + min_state = 0; for (i = 0; i < numfiles; ++i) { s = &states[i]; @@ -902,14 +953,14 @@ if (relative_time_merge) { /* compare *relative* times */ - TV_SUB(&s->hdr.ts, + timersub(&s->hdr.ts, &s->file_start_time, &temp1); - TV_SUB(&min_state->hdr.ts, + timersub(&min_state->hdr.ts, &min_state->file_start_time, &temp2); } else { /* compare *absolute* times */ - temp1 = s->hdr.ts; - temp2 = min_state->hdr.ts; + TIMEVAL_FROM_PKTHDR_TS(temp1, s->hdr.ts); + TIMEVAL_FROM_PKTHDR_TS(temp2, min_state->hdr.ts); } if (sf_timestamp_less_than( &temp1, &temp2)) min_state = s; @@ -921,12 +972,13 @@ if (relative_time_merge) { /* relative time w/in this file */ - TV_ADD(&min_state->file_start_time, &relative_stop, &temp1); + timeradd(&min_state->file_start_time, &relative_stop, &temp1); } else /* take absolute times */ temp1 = *stop_time; - if (sf_timestamp_less_than(&temp1, &min_state->hdr.ts)) { + TIMEVAL_FROM_PKTHDR_TS(tvbuf, min_state->hdr.ts); + if (sf_timestamp_less_than(&temp1, &tvbuf)) { if (!sessions_count) { /* We've gone beyond the end of the region * of interest ... We're done with this file. @@ -944,14 +996,24 @@ } if (relative_time_merge) { - TV_SUB(&min_state->hdr.ts, &min_state->file_start_time, &temp1); - TV_ADD(&temp1, base_time, &min_state->hdr.ts); + timersub(&min_state->hdr.ts, &min_state->file_start_time, &temp1); + timeradd(&temp1, base_time, &min_state->hdr.ts); } #ifdef HAVE_LIBNIDS /* Keep track of sessions, if specified by the user */ - if (track_sessions) - nids_pcap_handler((u_char *)min_state->p, &min_state->hdr, (u_char *)min_state->pkt); + if (track_sessions && min_state->hdr.caplen) { + /* + * Copy the packet buffer to deconstify it for the function. + */ + u_char *pkt_copy = malloc(min_state->hdr.caplen); + + if (!pkt_copy) + error("malloc() failed in %s()", __func__); + memcpy(pkt_copy, min_state->pkt, min_state->hdr.caplen); + nids_pcap_handler((u_char *)min_state->p, &min_state->hdr, pkt_copy); + free(pkt_copy); + } #endif /* Dump it, unless it's a duplicate. */ @@ -975,7 +1037,6 @@ free(last_pkt); } - /* Translates a timestamp to the time format specified by the user. * Returns a pointer to the translation residing in a static buffer. * There are two such buffers, which are alternated on subseqeuent @@ -983,13 +1044,13 @@ * about the results of the first call being overwritten by the * results of the second. */ - char * -timestamp_to_string(struct timeval *timestamp) +timestamp_to_string(const struct timeval *timestamp) { struct tm *t; #define NUM_BUFFERS 2 - static char buffers[NUM_BUFFERS][128]; +#define DATEBUFSIZE 128 + static char buffers[NUM_BUFFERS][DATEBUFSIZE]; static int buffer_to_use = 0; char *buf; @@ -999,20 +1060,20 @@ switch ( timestamp_style ) { case TIMESTAMP_RAW: - sprintf( buf, "%u.%06u", + snprintf( buf, DATEBUFSIZE, "%u.%06u", (u_int32_t)timestamp->tv_sec, (u_int32_t)timestamp->tv_usec ); break; case TIMESTAMP_READABLE: - t = localtime((time_t *) ×tamp->tv_sec); - strlcpy(buf, asctime(t), 128); - buf[24] = '\0'; /* nuke final newline */ + t = localtime((const time_t *) ×tamp->tv_sec); + /* Mimic asctime() with C99 format specifiers. */ + strftime(buf, DATEBUFSIZE, "%a %b %e %T %Y", t); break; case TIMESTAMP_PARSEABLE: - t = localtime((time_t *) ×tamp->tv_sec); - sprintf( buf, "%04dy%02dm%02dd%02dh%02dm%02ds%06uu", + t = localtime((const time_t *) ×tamp->tv_sec); + snprintf( buf, DATEBUFSIZE, "%04dy%02dm%02dd%02dh%02dm%02ds%06uu", t->tm_year + 1900, t->tm_mon + 1, t->tm_mday, t->tm_hour, t->tm_min, t->tm_sec, (u_int32_t)timestamp->tv_usec ); @@ -1023,13 +1084,11 @@ return buf; } - /* Given a pcap save filename, reports on the times of the first * and last packets in the file. */ - static void -dump_times(struct state *states, int numfiles) +dump_times(const struct state *states, int numfiles) { for (; numfiles--; states++) { printf( "%s\t%s\t%s\n", @@ -1060,15 +1119,19 @@ #ifdef HAVE_LIBNIDS (void)fprintf(f, "libnids version %u.%u\n", NIDS_MAJOR, NIDS_MINOR); -#endif /* HAVE_LIBNIDS */ #ifdef HAVE_LIBOSIPPARSER2 (void)fprintf(f, "libosip2 unknown version\n"); #endif /* HAVE_LIBOSIPPARSER2 */ +#ifdef HAVE_LIBOOH323C + (void)fprintf(f, "libooh323c %s\n", OOH323C_VERSION); +#endif /* HAVE_LIBOOH323C */ + +#endif /* HAVE_LIBNIDS */ + (void)fprintf(f, "Usage: tcpslice [-DdhlRrtv] [-w file]\n" " [ -s types [ -e seconds ] [ -f format ] ]\n" " [start-time [end-time]] file ... \n"); } - diff -Nru tcpslice-1.3/tcpslice.h tcpslice-1.5/tcpslice.h --- tcpslice-1.3/tcpslice.h 2020-08-19 18:16:16.000000000 +0000 +++ tcpslice-1.5/tcpslice.h 2021-12-30 20:50:44.000000000 +0000 @@ -19,6 +19,9 @@ * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ +#ifndef TCPSLICE_H +#define TCPSLICE_H + #include "compiler-tests.h" #include "varattrs.h" @@ -101,25 +104,38 @@ #define IS_LEAP_YEAR(year) \ (year % 4 == 0 && (year % 100 != 0 || year % 400 == 0)) +/* + * OpenBSD libpcap compensation: in struct pcap_pkthdr "ts" instead of struct + * timeval uses struct bpf_timeval, which declares members with the same names + * and a different type, which is a 32-bit unsigned, whilst on 64-bit systems + * struct timeval uses a 64-bit integer type. + */ +#define TIMEVAL_FROM_PKTHDR_TS(dst, src) { \ + (dst).tv_sec = (src).tv_sec; \ + (dst).tv_usec = (src).tv_usec; \ +} + extern const int days_in_month[]; -time_t gwtm2secs( struct tm *tm ); +time_t gwtm2secs( const struct tm *tm ); -int sf_find_end( struct pcap *p, struct timeval *first_timestamp, +int sf_find_end( struct pcap *p, const struct timeval *first_timestamp, struct timeval *last_timestamp ); -int sf_timestamp_less_than( struct timeval *t1, struct timeval *t2 ); +int sf_timestamp_less_than( const struct timeval *t1, const struct timeval *t2 ); int sf_find_packet( struct pcap *p, struct timeval *min_time, int64_t min_pos, struct timeval *max_time, int64_t max_pos, - struct timeval *desired_time ); + const struct timeval *desired_time ); -int fseek64(FILE *p, int64_t offset, int whence); +int fseek64(FILE *p, const int64_t offset, const int whence); int64_t ftell64(FILE *p); -extern char *timestamp_to_string(struct timeval *timestamp); +extern char *timestamp_to_string(const struct timeval *timestamp); #ifndef HAVE_STRLCPY extern size_t strlcpy(char *, const char *, size_t); #endif void error(const char *fmt, ...); +void warning(const char *fmt, ...); extern pcap_dumper_t *global_dumper; +#endif /* TCPSLICE_H */ diff -Nru tcpslice-1.3/.travis.yml tcpslice-1.5/.travis.yml --- tcpslice-1.3/.travis.yml 2020-08-19 18:16:16.000000000 +0000 +++ tcpslice-1.5/.travis.yml 1970-01-01 00:00:00.000000000 +0000 @@ -1,56 +0,0 @@ -git: - quiet: true - depth: 3 - -os: - - linux - - osx - -dist: bionic - -language: c - -compiler: - - gcc - - clang - -jobs: - fast_finish: true - exclude: - # GCC is a symlink to Clang in macOS - - os: osx - compiler: gcc - -env: - global: - # Parallel make is currently broken in tcpslice. - - MAKEFLAGS='-j 1' - -addons: - apt: - packages: - - libpcap-dev - -before_install: - - uname -a - - date - - if [ "$TRAVIS_OS_NAME" = osx ]; then brew update >/dev/null; fi - - if [ "$TRAVIS_OS_NAME" = linux ]; then apt list --installed 'lib*-dev'; fi - -script: - - touch .devel - - ./configure --prefix=/tmp - - echo '$ cat Makefile [...]'; echo travis_fold:start:script.cat_makefile - - cat Makefile | sed -n '1,/DO NOT DELETE THIS LINE -- mkdep uses it/p' - - echo -n travis_fold:end:script.cat_makefile - - echo '$ cat config.h'; echo travis_fold:start:script.cat_config_h - - cat config.h - - echo -n travis_fold:end:script.cat_config_h - - echo '$ cat config.log'; echo travis_fold:start:script.cat_config_log - - cat config.log - - echo -n travis_fold:end:script.cat_config_log - - make CFLAGS=-Werror - - ./tcpslice -h - - make install - - make releasetar - - if [ "$TRAVIS_OS_NAME" = osx ]; then sleep 10; fi diff -Nru tcpslice-1.3/util.c tcpslice-1.5/util.c --- tcpslice-1.3/util.c 2020-08-19 18:16:16.000000000 +0000 +++ tcpslice-1.5/util.c 2021-12-30 20:50:44.000000000 +0000 @@ -26,7 +26,6 @@ #include #include #include -#include #include #ifdef TIME_WITH_SYS_TIME @@ -39,21 +38,38 @@ #include "tcpslice.h" -/* VARARGS */ -void -error(const char *fmt, ...) +static void +complain(const char *fmt, va_list ap) { - va_list ap; - (void)fprintf(stderr, "tcpslice: "); - va_start(ap, fmt); (void)vfprintf(stderr, fmt, ap); - va_end(ap); if (*fmt) { fmt += strlen(fmt); if (fmt[-1] != '\n') (void)fputc('\n', stderr); } +} + +/* VARARGS */ +void +warning(const char *fmt, ...) +{ + va_list ap; + + va_start(ap, fmt); + complain(fmt, ap); + va_end(ap); +} + +/* VARARGS */ +void +error(const char *fmt, ...) +{ + va_list ap; + + va_start(ap, fmt); + complain(fmt, ap); + va_end(ap); exit(1); /* NOTREACHED */ } diff -Nru tcpslice-1.3/VERSION tcpslice-1.5/VERSION --- tcpslice-1.3/VERSION 2020-08-19 18:16:16.000000000 +0000 +++ tcpslice-1.5/VERSION 2021-12-30 20:53:05.000000000 +0000 @@ -1 +1 @@ -1.3 +1.5