Hello community, here is the log from the commit of package arping2 for openSUSE:Factory checked in at 2019-08-22 10:58:34 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Comparing /work/SRC/openSUSE:Factory/arping2 (Old) and /work/SRC/openSUSE:Factory/.arping2.new.22127 (New) ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Package is "arping2" Thu Aug 22 10:58:34 2019 rev:19 rq:725177 version:2.20 Changes: -------- --- /work/SRC/openSUSE:Factory/arping2/arping2.changes 2017-09-04 12:35:31.742207264 +0200 +++ /work/SRC/openSUSE:Factory/.arping2.new.22127/arping2.changes 2019-08-22 10:58:49.253647962 +0200 @@ -1,0 +2,6 @@ +Wed Aug 21 20:23:50 UTC 2019 - BenoƮt Monin <[email protected]> + +- update to version 2.20: no upstream changelog +- run spec-cleaner + +------------------------------------------------------------------- Old: ---- arping-2.19.tar.gz arping-2.19.tar.gz.asc New: ---- arping-2.20.tar.gz arping-2.20.tar.gz.asc ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ Other differences: ------------------ ++++++ arping2.spec ++++++ --- /var/tmp/diff_new_pack.vJQzba/_old 2019-08-22 10:58:50.633647777 +0200 +++ /var/tmp/diff_new_pack.vJQzba/_new 2019-08-22 10:58:50.657647774 +0200 @@ -1,7 +1,7 @@ # # spec file for package arping2 # -# Copyright (c) 2017 SUSE LINUX GmbH, Nuernberg, Germany. +# Copyright (c) 2019 SUSE LINUX GmbH, Nuernberg, Germany. # # All modifications and additions to the file contributed by third parties # remain the property of their copyright owners, unless otherwise agreed @@ -12,15 +12,15 @@ # license that conforms to the Open Source Definition (Version 1.9) # published by the Open Source Initiative. -# Please submit bugfixes or comments via http://bugs.opensuse.org/ +# Please submit bugfixes or comments via https://bugs.opensuse.org/ # Name: arping2 -Version: 2.19 +Version: 2.20 Release: 0 Summary: Layer-2 Ethernet pinger -License: GPL-2.0+ +License: GPL-2.0-or-later Group: Productivity/Networking/Diagnostic Url: http://www.habets.pp.se/synscan/programs.php?prog=arping ++++++ arping-2.19.tar.gz -> arping-2.20.tar.gz ++++++ ++++ 4443 lines of diff (skipped) ++++ retrying with extended exclude list diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/arping-2.19/.travis.yml new/arping-2.20/.travis.yml --- old/arping-2.19/.travis.yml 2017-07-09 19:52:08.000000000 +0200 +++ new/arping-2.20/.travis.yml 2019-08-18 13:17:04.000000000 +0200 @@ -5,4 +5,4 @@ script: ./bootstrap.sh && ./configure && make && make check before_install: - sudo apt-get update -qq - - sudo apt-get install -qq libpcap-dev libnet1-dev check + - sudo apt-get install -qq libpcap-dev libnet1-dev check libsubunit-dev diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/arping-2.19/INSTALL new/arping-2.20/INSTALL --- old/arping-2.19/INSTALL 2017-07-09 19:52:08.000000000 +0200 +++ new/arping-2.20/INSTALL 2019-08-18 13:17:04.000000000 +0200 @@ -18,7 +18,7 @@ Installing, short version ------------------------- -./configure +./configure # if "configure" doesn't exist, run "./bootstrap.sh" make # the binary will be created as src/arping make install diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/arping-2.19/compile new/arping-2.20/compile --- old/arping-2.19/compile 2017-07-09 19:52:12.000000000 +0200 +++ new/arping-2.20/compile 2019-08-18 13:17:06.000000000 +0200 @@ -1,9 +1,9 @@ #! /bin/sh # Wrapper for compilers which do not understand '-c -o'. -scriptversion=2012-10-14.11; # UTC +scriptversion=2018-03-07.03; # UTC -# Copyright (C) 1999-2014 Free Software Foundation, Inc. +# Copyright (C) 1999-2018 Free Software Foundation, Inc. # Written by Tom Tromey <[email protected]>. # # This program is free software; you can redistribute it and/or modify @@ -17,7 +17,7 @@ # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License -# along with this program. If not, see <http://www.gnu.org/licenses/>. +# along with this program. If not, see <https://www.gnu.org/licenses/>. # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a @@ -255,7 +255,8 @@ echo "compile $scriptversion" exit $? ;; - cl | *[/\\]cl | cl.exe | *[/\\]cl.exe ) + cl | *[/\\]cl | cl.exe | *[/\\]cl.exe | \ + icl | *[/\\]icl | icl.exe | *[/\\]icl.exe ) func_cl_wrapper "$@" # Doesn't return... ;; esac @@ -339,9 +340,9 @@ # Local Variables: # mode: shell-script # sh-indentation: 2 -# eval: (add-hook 'write-file-hooks 'time-stamp) +# eval: (add-hook 'before-save-hook 'time-stamp) # time-stamp-start: "scriptversion=" # time-stamp-format: "%:y-%02m-%02d.%02H" -# time-stamp-time-zone: "UTC" +# time-stamp-time-zone: "UTC0" # time-stamp-end: "; # UTC" # End: diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/arping-2.19/config.h.in new/arping-2.20/config.h.in --- old/arping-2.19/config.h.in 2017-07-09 19:52:11.000000000 +0200 +++ new/arping-2.20/config.h.in 2019-08-18 13:17:06.000000000 +0200 @@ -12,6 +12,9 @@ /* Define to 1 if you have the `getifaddrs' function. */ #undef HAVE_GETIFADDRS +/* Define to 1 if you have the <getopt.h> header file. */ +#undef HAVE_GETOPT_H + /* Define to 1 if you have the `gettimeofday' function. */ #undef HAVE_GETTIMEOFDAY @@ -72,6 +75,9 @@ /* Define to 1 if you have the `pcap_set_immediate_mode' function. */ #undef HAVE_PCAP_SET_IMMEDIATE_MODE +/* Define to 1 if you have the `pledge' function. */ +#undef HAVE_PLEDGE + /* Define to 1 if you have the <pwd.h> header file. */ #undef HAVE_PWD_H @@ -129,6 +135,9 @@ /* Define to 1 if you have the <unistd.h> header file. */ #undef HAVE_UNISTD_H +/* Define to 1 if you have the `unveil' function. */ +#undef HAVE_UNVEIL + /* Define to 1 if you have the <win32/libnet.h> header file. */ #undef HAVE_WIN32_LIBNET_H diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/arping-2.19/configure.ac new/arping-2.20/configure.ac --- old/arping-2.19/configure.ac 2017-07-09 19:52:08.000000000 +0200 +++ new/arping-2.20/configure.ac 2019-08-18 13:17:04.000000000 +0200 @@ -2,7 +2,7 @@ # Process this file with autoconf to produce a configure script. AC_PREREQ(2.61) -AC_INIT(arping, 2.19, [email protected]) +AC_INIT(arping, 2.20, [email protected]) AC_CANONICAL_SYSTEM AC_CONFIG_SRCDIR([src/arping.c]) AM_INIT_AUTOMAKE @@ -15,6 +15,12 @@ AC_PROG_INSTALL AC_PROG_MAKE_SET +# Required to define __USE_MISC, which in turn typedefs uint, which +# is used by libnet headers. +# This "just works" until running GCC with -std=c99, where uint is +# no longer defined by default. +CPPFLAGS="$CPPFLAGS -D_DEFAULT_SOURCE=1" + # Checks for libraries. AC_CHECK_LIB([m], [sqrt]) AC_CHECK_LIB([socket], [socket]) @@ -34,6 +40,7 @@ netinet/in.h \ stdlib.h \ sys/socket.h \ +getopt.h \ time.h \ grp.h \ sys/time.h \ @@ -67,7 +74,8 @@ AC_FUNC_SETVBUF_REVERSED AC_TYPE_SIGNAL AC_CHECK_FUNCS([gettimeofday memset select strchr strdup strerror strstr \ -getifaddrs cap_init pcap_create pcap_list_tstamp_types pcap_set_immediate_mode]) +getifaddrs cap_init pcap_create pcap_list_tstamp_types pcap_set_immediate_mode \ +pledge unveil]) if test x$ac_cv_func_getifaddrs = xyes; then AC_LIBOBJ([findif_getifaddrs]) @@ -90,12 +98,8 @@ AC_CACHE_CHECK([for libnet_init signature has const], ac_cv_have_libnet_init_const, [ - AC_TRY_RUN( - [ -#include<libnet.h> -libnet_t*libnet_init(int a,const char* b,char* c){} -int main(){return 0;} -], + AC_TRY_LINK([#include<libnet.h>], +[libnet_t*libnet_init(int a,const char* b,char* c);], [ ac_cv_have_libnet_init_const="yes" ], [ ac_cv_have_libnet_init_const="no" ]) ]) @@ -105,12 +109,8 @@ AC_CACHE_CHECK([for libnet_name2addr4 signature has const], ac_cv_have_libnet_name2addr4_const, [ - AC_TRY_RUN( - [ -#include<libnet.h> -uint32_t libnet_name2addr4(libnet_t*a,const char* b,uint8_t c){} -int main(){return 0;} -], + AC_TRY_LINK([#include<libnet.h>], +[uint32_t libnet_name2addr4(libnet_t*a, const char* b,uint8_t c);], [ ac_cv_have_libnet_name2addr4_const="yes" ], [ ac_cv_have_libnet_name2addr4_const="no" ]) ]) @@ -120,26 +120,27 @@ # check for CLOCK_MONOTONIC -AC_CACHE_CHECK([for CLOCK_MONOTONIC], - ac_cv_have_clock_monotonic, [ - AC_TRY_RUN( - [ -#include <time.h> -#include <sys/time.h> -int main() { -struct timespec ts; -exit(!!clock_gettime(CLOCK_MONOTONIC, &ts)); -} - ], - [ ac_cv_have_clock_monotonic="yes" ], - [ ac_cv_have_clock_monotonic="no" ] - ) -]) -AM_CONDITIONAL(HAVE_CLOCK_MONOTONIC, test x$ac_cv_have_clock_monotonic = xyes) -if test x$ac_cv_have_clock_monotonic = xyes; then +AC_CHECK_DECL([CLOCK_MONOTONIC], [], [], + [ + #include <time.h> + #include <sys/time.h> + ] +) +AM_CONDITIONAL(HAVE_CLOCK_MONOTONIC, test x$ac_cv_have_decl_CLOCK_MONOTONIC = xyes) +if test x$ac_cv_have_decl_CLOCK_MONOTONIC = xyes; then AC_DEFINE([HAVE_CLOCK_MONOTONIC], [1], [Monotonic clock]) fi +AC_ARG_ENABLE(hardened, AS_HELP_STRING([--enable-hardened], [Enable security build options]), + [ + CFLAGS+=" -pie -fPIE -fstack-protector-all --param ssp-buffer-size=1 -D_FORTIFY_SOURCE=2" + LDFLAGS+=" -pie -fPIE -Wl,-z,relro -Wl,-z,now -Wl,-z,noexecstack" + ]) +AC_ARG_ENABLE(warnings, AS_HELP_STRING([--enable-warnings], [Enable build warnings]), + [ + CFLAGS+=" -Wall -Wpedantic -Wextra -Wformat -Wstack-protector -Wformat-security -Werror=format-security" + ]) + AC_CONFIG_FILES([Makefile]) AC_CONFIG_FILES([src/Makefile]) AC_CONFIG_FILES([doc/Makefile]) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/arping-2.19/doc/arping.8 new/arping-2.20/doc/arping.8 --- old/arping-2.19/doc/arping.8 2017-07-09 19:52:08.000000000 +0200 +++ new/arping-2.20/doc/arping.8 2019-08-18 13:17:04.000000000 +0200 @@ -16,7 +16,7 @@ .PP When pinging an IP an ARP who\-has query is sent\&. When pinging a MAC address a directed broadcast ICMP Echo request is sent\&. For more -technical explaination and an FAQ, see the README file\&. +technical explanation and an FAQ, see the README file\&. .PP \fINote on timing\fP .PP diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/arping-2.19/doc/arping.yodl new/arping-2.20/doc/arping.yodl --- old/arping-2.19/doc/arping.yodl 2017-07-09 19:52:08.000000000 +0200 +++ new/arping-2.20/doc/arping.yodl 2019-08-18 13:17:04.000000000 +0200 @@ -16,7 +16,7 @@ When pinging an IP an ARP who-has query is sent. When pinging a MAC address a directed broadcast ICMP Echo request is sent. For more - technical explaination and an FAQ, see the README file. + technical explanation and an FAQ, see the README file. em(Note on timing) diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/arping-2.19/missing new/arping-2.20/missing --- old/arping-2.19/missing 2017-07-09 19:52:12.000000000 +0200 +++ new/arping-2.20/missing 2019-08-18 13:17:06.000000000 +0200 @@ -1,9 +1,9 @@ #! /bin/sh # Common wrapper for a few potentially missing GNU programs. -scriptversion=2013-10-28.13; # UTC +scriptversion=2018-03-07.03; # UTC -# Copyright (C) 1996-2014 Free Software Foundation, Inc. +# Copyright (C) 1996-2018 Free Software Foundation, Inc. # Originally written by Fran,cois Pinard <[email protected]>, 1996. # This program is free software; you can redistribute it and/or modify @@ -17,7 +17,7 @@ # GNU General Public License for more details. # You should have received a copy of the GNU General Public License -# along with this program. If not, see <http://www.gnu.org/licenses/>. +# along with this program. If not, see <https://www.gnu.org/licenses/>. # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a @@ -101,9 +101,9 @@ exit $st fi -perl_URL=http://www.perl.org/ -flex_URL=http://flex.sourceforge.net/ -gnu_software_URL=http://www.gnu.org/software +perl_URL=https://www.perl.org/ +flex_URL=https://github.com/westes/flex +gnu_software_URL=https://www.gnu.org/software program_details () { @@ -207,9 +207,9 @@ exit $st # Local variables: -# eval: (add-hook 'write-file-hooks 'time-stamp) +# eval: (add-hook 'before-save-hook 'time-stamp) # time-stamp-start: "scriptversion=" # time-stamp-format: "%:y-%02m-%02d.%02H" -# time-stamp-time-zone: "UTC" +# time-stamp-time-zone: "UTC0" # time-stamp-end: "; # UTC" # End: diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/arping-2.19/src/arping.c new/arping-2.20/src/arping.c --- old/arping-2.19/src/arping.c 2017-07-09 19:52:08.000000000 +0200 +++ new/arping-2.20/src/arping.c 2019-08-18 13:17:04.000000000 +0200 @@ -15,7 +15,7 @@ * */ /* - * Copyright (C) 2000-2017 Thomas Habets <[email protected]> + * Copyright (C) 2000-2019 Thomas Habets <[email protected]> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -45,6 +45,10 @@ #include <unistd.h> #endif +#if HAVE_GETOPT_H +#include <getopt.h> +#endif + #if HAVE_STDINT_H #include <stdint.h> #endif @@ -124,6 +128,8 @@ #define CLOCK_MONOTONIC CLOCK_REALTIME #endif +#define UNUSED(x) (void)(x) + /** * OS-specific interface finding using routing table. See findif_*.c * ebuf must be called with a size of at least @@ -160,7 +166,7 @@ static uint8_t dstmac[ETH_ALEN]; uint32_t srcip; /* autodetected, override with -S/-b/-0 */ -static uint8_t srcmac[ETH_ALEN]; /* autodetected, override with -s */ +uint8_t srcmac[ETH_ALEN]; /* autodetected, override with -s */ static int16_t vlan_tag = -1; /* 802.1Q tag to add to packets. -V */ static int16_t vlan_prio = -1; /* 802.1p prio to use with 802.1Q. -Q */ @@ -171,6 +177,7 @@ static int addr_must_be_same = 0; /* -A */ static int unsolicited = 0; /* -U */ static int send_reply = 0; /* Send reply instead of request. -P */ +static int promisc = 0; /* Use promisc mode. -p */ static int finddup = 0; /* finddup mode. -d */ static int dupfound = 0; /* set to 1 if dup found */ @@ -179,7 +186,6 @@ unsigned int numsent = 0; /* packets sent */ unsigned int numrecvd = 0; /* packets received */ static unsigned int max_replies = UINT_MAX; /* exit after -C replies */ -static unsigned int numdots = 0; /* dots that should be printed */ static const char* timestamp_type = NULL; /* Incoming packet measurement ts type (-m) */ static double stats_min_time = -1; @@ -199,6 +205,7 @@ static const uint8_t ethnull[ETH_ALEN] = {0, 0, 0, 0, 0, 0}; static const uint8_t ethxmas[ETH_ALEN] = {0xff, 0xff, 0xff, 0xff, 0xff, 0xff}; static const char* ip_broadcast = "255.255.255.255"; +static const uint32_t ip_broadcast_num = (uint32_t)-1; int verbose = 0; /* Increase with -v */ @@ -311,13 +318,13 @@ must_get_group(const char* ident) { // Special case empty string, because strtol. - int saved_errno; + int saved_errno = 0; if (*ident) { // First try it as a name. { struct group* gr; errno = 0; - if (gr = getgrnam(ident)) { + if ((gr = getgrnam(ident))) { return gr->gr_gid; } saved_errno = errno; @@ -349,6 +356,9 @@ /** * drop all privileges. + * + * To be called as early as possible. IOW: immediately after opening + * raw socket. */ static void drop_privileges(const char* drop_group) @@ -381,6 +391,41 @@ drop_fs_root(); drop_uid(uid, gid); drop_capabilities(); +#ifdef HAVE_UNVEIL + if (unveil("/", "")) { + fprintf(stderr, + "arping: failed to unveil(/, <>): %s\n", + strerror(errno)); + exit(1); + } + if (unveil(NULL, NULL)) { + fprintf(stderr, "arping: failed to unveil(NULL, NULL): %s\n", + strerror(errno)); + exit(1); + } + if (verbose > 1) { + printf("arping: Successfully unveiled\n"); + } +#endif +} + +/** + * drop even more privileges, where possible. + * + * After all setup is done and main loop is about to start. + */ +static void +drop_more_privileges() +{ +#ifdef HAVE_PLEDGE + if (pledge("stdio tty", "")) { + fprintf(stderr, "arping: failed to pledge(stdio, <empty>): %s\n", + strerror(errno)); + exit(1); + } else if (verbose > 1) { + printf("arping: Successfully pledged\n"); + } +#endif } @@ -570,7 +615,8 @@ return; } fprintf(stderr, "arping: libnet_init(LIBNET_LINK, %s): %s\n", - ifname ? ifname : "<null>", ebuf); + ifname ? ifname : "<null>", + *ebuf ? ebuf : "<no error message>"); if (getuid() && geteuid()) { fprintf(stderr, "arping: you may need to run as root\n"); @@ -585,6 +631,7 @@ void sigint(int i) { + UNUSED(i); time_to_die = 1; } @@ -595,13 +642,16 @@ getclock(struct timespec *ts) { #if HAVE_CLOCK_MONOTONIC - if (-1 == clock_gettime(CLOCK_MONOTONIC, ts)) { - fprintf(stderr, - "arping: clock_gettime(): %s\n", + static int clock_gettime_failed = 0; + if (!clock_gettime_failed) { + if (0 == clock_gettime(CLOCK_MONOTONIC, ts)) { + return; + } + fprintf(stderr, "arping: clock_gettime(): %s\n", strerror(errno)); - sigint(0); + clock_gettime_failed = 1; // Prevent duplicate error messages. } -#else +#endif struct timeval tv; if (-1 == gettimeofday(&tv, NULL)) { fprintf(stderr, "arping: gettimeofday(): %s\n", @@ -610,7 +660,6 @@ } ts->tv_sec = tv.tv_sec; ts->tv_nsec = tv.tv_usec * 1000; -#endif } /** @@ -928,7 +977,7 @@ 0, /* checksum */ id, /* id */ seq, /* seq */ - padding, /* payload */ + (uint8_t*)padding, /* payload */ sizeof padding, /* payload len */ libnet, icmp))) { @@ -1021,7 +1070,7 @@ (uint8_t*)&srcip, unsolicited ? (uint8_t*)ethxmas : (uint8_t*)ethnull, (uint8_t*)&dstip, - padding, + (uint8_t*)padding, sizeof padding, libnet, arp))) { @@ -1079,14 +1128,14 @@ * \param packet packet data */ void -pingip_recv(const char *unused, struct pcap_pkthdr *h, uint8_t *packet) +pingip_recv(const char *unused, struct pcap_pkthdr *h, const char * const packet) { const unsigned char *pkt_srcmac; const struct libnet_802_1q_hdr *veth; struct libnet_802_3_hdr *heth; struct libnet_arp_hdr *harp; struct timespec arrival; - int c; + UNUSED(unused); if (verbose > 2) { printf("arping: received response for IP ping\n"); @@ -1154,6 +1203,33 @@ printf("arping: ... sent by acceptable host\n"); } + // Special case: If we're not in promisc mode we could still + // get packets where DST mac is not us, if they're *sent* from + // the local host. This is an edge case but in general falls under "is promisc?". + // + // It may cause confusion because `-p` now means not just + // enable promisc mode (disable filter on card / in kernel), + // but also allow packets to any destination (disable filter + // in `arping`). + { + const uint8_t* p = (u_char*)harp + + sizeof(struct libnet_arp_hdr) + + ETH_ALEN + + IP_ALEN; + char buf[128]; + if (!promisc && memcmp(p, srcmac, ETH_ALEN)) { + format_mac(p, buf, sizeof buf); + if (verbose > 3) { + printf("arping: ... but sent from %s\n", buf); + } + return; + } + } + if (verbose > 3) { + printf("arping: ... destination is the source we used\n"); + } + + // Actually the IPv4 address we asked for. uint32_t ip; memcpy(&ip, (char*)harp + harp->ar_hln + LIBNET_ARP_H, 4); @@ -1228,7 +1304,7 @@ * \param packet packet data */ void -pingmac_recv(const char *unused, struct pcap_pkthdr *h, uint8_t *packet) +pingmac_recv(const char* unused, struct pcap_pkthdr *h, uint8_t *packet) { const unsigned char *pkt_dstmac; const unsigned char *pkt_srcmac; @@ -1237,7 +1313,7 @@ struct libnet_ipv4_hdr *hip; struct libnet_icmpv4_hdr *hicmp; struct timespec arrival; - int c; + UNUSED(unused); if(verbose>2) { printf("arping: received response for mac ping\n"); @@ -1356,7 +1432,7 @@ struct timespec endtime; char done = 0; int fd; - int old_received; + unsigned int old_received; if (verbose > 3) { printf("arping: receiving packets...\n"); @@ -1505,7 +1581,6 @@ { char ebuf[LIBNET_ERRBUF_SIZE + PCAP_ERRBUF_SIZE]; char *cp; - int promisc = 0; const char *srcip_opt = NULL; const char *dstip_opt = NULL; // `dstip_given` can be set even when there's no arg past flags on the @@ -1521,7 +1596,7 @@ const char* drop_group = NULL; // -g const char *parm; // First argument, meaning the target IP. int c; - unsigned int maxcount = -1; + int maxcount = -1; int dont_use_arping_lookupdev=0; struct bpf_program bp; pcap_t *pcap; @@ -1976,7 +2051,7 @@ memcpy(srcmac, cp, ETH_ALEN); } if (srcip_opt == NULL) { - if (-1 == (srcip = libnet_get_ipaddr4(libnet))) { + if (ip_broadcast_num == (srcip = libnet_get_ipaddr4(libnet))) { fprintf(stderr, "arping: Unable to get the IPv4 address of " "interface %s:\narping: %s" @@ -1996,6 +2071,7 @@ format_mac(srcmac, buf, sizeof(buf))); } + drop_more_privileges(); if (display == NORMAL) { printf("ARPING %s\n", parm); @@ -2010,11 +2086,9 @@ deadline += timespec2dbl(&ts); } if (mode == PINGIP) { - unsigned int c; - unsigned int r; - for (c = 0; c < maxcount && !time_to_die; c++) { + int c; + for (c = 0; (maxcount < 0 || c < maxcount) && !time_to_die; c++) { pingip_send(); - r = numrecvd; const uint32_t w = wait_time(deadline, packetwait); if (w == 0) { break; @@ -2022,11 +2096,9 @@ ping_recv(pcap, w, (pcap_handler)pingip_recv); } } else { /* PINGMAC */ - unsigned int c; - unsigned int r; - for (c = 0; c < maxcount && !time_to_die; c++) { + int c; + for (c = 0; (maxcount < 0 || c < maxcount) && !time_to_die; c++) { pingmac_send(rand(), c); - r = numrecvd; const uint32_t w = wait_time(deadline, packetwait); if (w == 0) { break; diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/arping-2.19/src/arping.h new/arping-2.20/src/arping.h --- old/arping-2.19/src/arping.h 2017-07-09 19:52:08.000000000 +0200 +++ new/arping-2.20/src/arping.h 2019-08-18 13:17:04.000000000 +0200 @@ -44,5 +44,5 @@ int arping_main(int argc, char **argv); -void pingip_recv(const char *unused, struct pcap_pkthdr *h, uint8_t *packet); +void pingip_recv(const char *unused, struct pcap_pkthdr *h, const char* const packet); void pingmac_recv(const char *unused, struct pcap_pkthdr *h, uint8_t *packet); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/arping-2.19/src/arping_test.c new/arping-2.20/src/arping_test.c --- old/arping-2.19/src/arping_test.c 2017-07-09 19:52:08.000000000 +0200 +++ new/arping-2.20/src/arping_test.c 2019-08-18 13:17:04.000000000 +0200 @@ -1,6 +1,6 @@ /* arping/src/arping_test.c * - * Copyright (C) 2015 Thomas Habets <[email protected]> + * Copyright (C) 2015-2019 Thomas Habets <[email protected]> * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -16,6 +16,7 @@ * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ +#include"config.h" #define _GNU_SOURCE #include<assert.h> #include<errno.h> @@ -31,6 +32,10 @@ #include"arping.h" +#ifndef ETH_ALEN +#define ETH_ALEN 6 +#endif + extern libnet_t* libnet; extern int mock_libnet_lo_ok; extern int mock_libnet_null_ok; @@ -387,6 +392,8 @@ MYTEST(pingip_interesting_packet) { struct pcap_pkthdr pkthdr; + extern uint8_t srcmac[ETH_ALEN]; + memcpy(srcmac, "\x11\x22\x33\x44\x55\x66", ETH_ALEN); uint8_t packet[] = { 0x11, 0x22, 0x33, 0x44, 0x55, 0x66, // dst 0x77, 0x88, 0x99, 0xaa, 0xbb, 0xcc, // src diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/arping-2.19/src/findif_getifaddrs.c new/arping-2.20/src/findif_getifaddrs.c --- old/arping-2.19/src/findif_getifaddrs.c 2017-07-09 19:52:08.000000000 +0200 +++ new/arping-2.20/src/findif_getifaddrs.c 2019-08-18 13:17:04.000000000 +0200 @@ -39,6 +39,8 @@ #include "arping.h" +#define UNUSED(x) (void)(x) + const char * arping_lookupdev(uint32_t srcip, uint32_t dstip, @@ -48,10 +50,10 @@ struct ifaddrs *cur; const char *ret = NULL; int match_count = 0; /* Matching interfaces */ + UNUSED(srcip); /* best match */ in_addr_t best_mask = 0; - in_addr_t best_addr; /* Results */ static char ifname[IFNAMSIZ]; @@ -92,7 +94,6 @@ if (ntohl(mask) > ntohl(best_mask)) { memset(ifname, 0, sizeof(ifname)); strncpy(ifname, cur->ifa_name, sizeof(ifname)-1); - best_addr = addr; best_mask = mask; } } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/arping-2.19/src/mock_libnet.c new/arping-2.20/src/mock_libnet.c --- old/arping-2.19/src/mock_libnet.c 2017-07-09 19:52:08.000000000 +0200 +++ new/arping-2.20/src/mock_libnet.c 2019-08-18 13:17:04.000000000 +0200 @@ -1,6 +1,7 @@ #include<libnet.h> #include"config.h" +#define UNUSED(x) (void)(x) int mock_libnet_null_ok = 1; int mock_libnet_lo_ok = 1; @@ -19,6 +20,8 @@ libnet_t* libnet_init(int injection_type, LIBNET_INIT_CONST char *device, char *err_buf) { + UNUSED(injection_type); + UNUSED(err_buf); if (device == NULL) { if (mock_libnet_null_ok) { return malloc(1); diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/arping-2.19/src/mock_libpcap.c new/arping-2.20/src/mock_libpcap.c --- old/arping-2.19/src/mock_libpcap.c 2017-07-09 19:52:08.000000000 +0200 +++ new/arping-2.20/src/mock_libpcap.c 2019-08-18 13:17:04.000000000 +0200 @@ -1,14 +1,22 @@ #include<pcap.h> +#define UNUSED(x) (void)(x) + int pcap_setfilter(pcap_t *pcap, struct bpf_program *prog) { + UNUSED(pcap); + UNUSED(prog); return 0; } int pcap_dispatch(pcap_t *pcap, int num, pcap_handler handler, u_char *packet) { + UNUSED(pcap); + UNUSED(num); + UNUSED(handler); + UNUSED(packet); return 0; } @@ -16,30 +24,45 @@ pcap_compile(pcap_t *pcap, struct bpf_program *prog, const char *x, int y, bpf_u_int32 z) { + UNUSED(pcap); + UNUSED(prog); + UNUSED(x); + UNUSED(y); + UNUSED(z); return 0; } pcap_t* pcap_open_live(const char *ifname, int a, int b, int c, char *d) { + UNUSED(ifname); + UNUSED(a); + UNUSED(b); + UNUSED(c); + UNUSED(d); return NULL; } int pcap_setnonblock(pcap_t *pcap, int a, char *b) { + UNUSED(pcap); + UNUSED(a); + UNUSED(b); return 0; } int pcap_get_selectable_fd(pcap_t *pcap) { + UNUSED(pcap); return 0; } char* pcap_lookupdev(char *ifname) { + UNUSED(ifname); return 0; } /* ---- Emacs Variables ---- diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/arping-2.19/src/unix.c new/arping-2.20/src/unix.c --- old/arping-2.19/src/unix.c 2017-07-09 19:52:08.000000000 +0200 +++ new/arping-2.20/src/unix.c 2019-08-18 13:17:04.000000000 +0200 @@ -26,12 +26,16 @@ #include "arping.h" +#define UNUSED(x) (void)(x) + /** * Fall back on getting device name from pcap. */ const char * arping_lookupdev_default(uint32_t srcip, uint32_t dstip, char *ebuf) { + UNUSED(srcip); + UNUSED(dstip); return pcap_lookupdev(ebuf); } diff -urN '--exclude=CVS' '--exclude=.cvsignore' '--exclude=.svn' '--exclude=.svnignore' --exclude Makefile.in --exclude configure --exclude config.guess --exclude '*.pot' --exclude mkinstalldirs --exclude aclocal.m4 --exclude config.sub --exclude depcomp --exclude install-sh --exclude ltmain.sh old/arping-2.19/test-driver new/arping-2.20/test-driver --- old/arping-2.19/test-driver 2017-07-09 19:52:12.000000000 +0200 +++ new/arping-2.20/test-driver 2019-08-18 13:17:06.000000000 +0200 @@ -1,9 +1,9 @@ #! /bin/sh # test-driver - basic testsuite driver script. -scriptversion=2013-07-13.22; # UTC +scriptversion=2018-03-07.03; # UTC -# Copyright (C) 2011-2014 Free Software Foundation, Inc. +# Copyright (C) 2011-2018 Free Software Foundation, Inc. # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by @@ -16,7 +16,7 @@ # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License -# along with this program. If not, see <http://www.gnu.org/licenses/>. +# along with this program. If not, see <https://www.gnu.org/licenses/>. # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a @@ -140,9 +140,9 @@ # Local Variables: # mode: shell-script # sh-indentation: 2 -# eval: (add-hook 'write-file-hooks 'time-stamp) +# eval: (add-hook 'before-save-hook 'time-stamp) # time-stamp-start: "scriptversion=" # time-stamp-format: "%:y-%02m-%02d.%02H" -# time-stamp-time-zone: "UTC" +# time-stamp-time-zone: "UTC0" # time-stamp-end: "; # UTC" # End:
