]> The Tcpdump Group git mirrors - tcpdump/commitdiff
libdnet has bugs, do not use it.
authorDenis Ovsienko <[email protected]>
Mon, 23 Jul 2018 22:28:24 +0000 (23:28 +0100)
committerDenis Ovsienko <[email protected]>
Sun, 3 Nov 2019 23:46:28 +0000 (23:46 +0000)
The only function tcpdump used in libdnet was dnet_htoa(), which tries
to translate a binary DECnet address to a nodename through a lookup in
/etc/decnet.conf. The translation is slow and has a bug, so stop using
the function and remove the dependency on libdnet.

This makes tcpdump always print DECnet addresses in numeric format, if
anybody needs the translation back they are welcome to fix libdnet or
(more realistically) add an implementation of dnet_htoa() to the tcpdump
source code and use it.

(This is a forward-port of commit 9a6eb27 from tcpdump-4.9 to master.
Sadly, together with libdnet this change removes the fine work that Guy
had done in the master branch in commits ebf3f19 and 4ef8d63 to put
libdnet usage right whilst my original "do not use libdnet" commit was
aging in the pipeline.)

.travis.yml
CMakeLists.txt
addrtoname.c
cmakeconfig.h.in
config.h.in
configure
configure.ac
netdissect.h
print-decnet.c
tcpdump.c

index 798afe5cc2b12194bf5e0602825acb29c2ce60c2..ae9d06ee2a7e59b13e4ce5d6de28e4f57447b09f 100644 (file)
@@ -74,7 +74,6 @@ addons:
       - libibverbs-dev
       - libssl-dev
       - libssl1.0.0
-      - libdnet-dev
       - libsmi2-dev
       - libcap-ng-dev
       - libpcap-dev
index 3d2ab6541e45c52e50d47f14e071cccd9ee75273..59ecbf92020593883444df54b4d578c6dbd556a0 100644 (file)
@@ -482,45 +482,6 @@ if(HAVE_ETHER_NTOHOST)
 endif()
 cmake_pop_check_state()
 
-check_function_exists(dnet_htoa STDLIBS_HAVE_DNET_HTOA)
-if(STDLIBS_HAVE_DNET_HTOA)
-    set(HAVE_DNET_HTOA TRUE)
-else(STDLIBS_HAVE_DNET_HTOA)
-    check_library_exists(dnet dnet_htoa "" HAVE_DNET_HTOA)
-    if(HAVE_DNET_HTOA)
-        set(TCPDUMP_LINK_LIBRARIES dnet ${TCPDUMP_LINK_LIBRARIES})
-    endif(HAVE_DNET_HTOA)
-endif(STDLIBS_HAVE_DNET_HTOA)
-if(HAVE_DNET_HTOA)
-    #
-    # OK, we have dnet_htoa().  Do we have netdnet/dnetdb.h?
-    #
-    check_include_files("sys/types.h;netdnet/dnetdb.h" HAVE_NETDNET_DNETDB_H)
-    if(HAVE_NETDNET_DNETDB_H)
-        #
-        # Yes.  Does it declare dnet_htoa()?
-        #
-        cmake_push_check_state()
-        set(CMAKE_REQUIRED_LIBRARIES dnet)
-        check_symbol_exists(dnet_htoa "sys/types.h;netdnet/dnetdb.h" NETDNET_DNETDB_H_DECLARES_DNET_HTOA)
-        cmake_pop_check_state()
-    endif(HAVE_NETDNET_DNETDB_H)
-
-    #
-    # Do we have netdnet/dn.h?
-    #
-    check_include_file(netdnet/dn.h HAVE_NETDNET_DN_H)
-    if(HAVE_NETDNET_DN_H)
-        #
-        # Yes.  Does it declare struct dn_naddr?
-        #
-        cmake_push_check_state()
-        set(CMAKE_EXTRA_INCLUDE_FILES netdnet/dn.h)
-        check_type_size("struct dn_naddr" STRUCT_DN_NADDR)
-        cmake_pop_check_state()
-    endif(HAVE_NETDNET_DN_H)
-endif(HAVE_DNET_HTOA)
-
 #
 # Data types.
 #
index aa43be768c1efa8270842707405ac8ae701e812e..ce05903bac35b58bb25e5b46d657d449099c2cc2 100644 (file)
@@ -1280,10 +1280,7 @@ dnaddr_string(netdissect_options *ndo, u_short dnaddr)
 
        tp->addr = dnaddr;
        tp->nxt = newhnamemem(ndo);
-       if (ndo->ndo_nflag)
-               tp->name = dnnum_string(ndo, dnaddr);
-       else
-               tp->name = dnname_string(ndo, dnaddr);
+       tp->name = dnnum_string(ndo, dnaddr);
 
        return(tp->name);
 }
index 5c7532847ece40a70e2ba2f90673ad6317085a18..38925d7ba316adeb39069660ca29662cd7162cca 100644 (file)
@@ -30,9 +30,6 @@
 /* Define to 1 if you have the declaration of `ether_ntohost' */
 #cmakedefine HAVE_DECL_ETHER_NTOHOST 1
 
-/* define if you have the dnet_htoa function */
-#cmakedefine HAVE_DNET_HTOA 1
-
 /* Define to 1 if you have the `ether_ntohost' function. */
 #cmakedefine HAVE_ETHER_NTOHOST 1
 
 /* Define to 1 if you have the <memory.h> header file. */
 #cmakedefine HAVE_MEMORY_H 1
 
-/* Define to 1 if you have the <netdnet/dnetdb.h> header file. */
-#cmakedefine HAVE_NETDNET_DNETDB_H 1
-
-/* Define to 1 if you have the <netdnet/dn.h> header file. */
-#cmakedefine HAVE_NETDNET_DN_H 1
-
 /* Define to 1 if you have the <net/if.h> header file. */
 #cmakedefine HAVE_NET_IF_H 1
 
 /* Define to 1 if you have the `strsep' function. */
 #cmakedefine HAVE_STRSEP 1
 
-/* Define to 1 if the system has the type `struct dn_naddr'. */
-#cmakedefine HAVE_STRUCT_DN_NADDR 1
-
 /* Define to 1 if the system has the type `struct ether_addr'. */
 #cmakedefine HAVE_STRUCT_ETHER_ADDR 1
 
 /* define if libpcap has yydebug */
 #cmakedefine HAVE_YYDEBUG 1
 
-/* Define to 1 if netenet/dnetdb.h declares `dnet_htoa' */
-#cmakedefine NETDNET_DNETDB_H_DECLARES_DNET_HTOA 1
-
 /* Define to 1 if netinet/ether.h declares `ether_ntohost' */
 #cmakedefine NETINET_ETHER_H_DECLARES_ETHER_NTOHOST 1
 
index e40e1089eb23cc2021cbd0c0a7da2f7ab468a942..4b22e15ca810b12fb115df60e1f7daa7310a83a1 100644 (file)
@@ -30,9 +30,6 @@
 /* Define to 1 if you have the declaration of `ether_ntohost' */
 #undef HAVE_DECL_ETHER_NTOHOST
 
-/* define if you have the dnet_htoa function */
-#undef HAVE_DNET_HTOA
-
 /* Define to 1 if you have the `ether_ntohost' function. */
 #undef HAVE_ETHER_NTOHOST
 
 /* Define to 1 if you have the <memory.h> header file. */
 #undef HAVE_MEMORY_H
 
-/* Define to 1 if you have the <netdnet/dnetdb.h> header file. */
-#undef HAVE_NETDNET_DNETDB_H
-
-/* Define to 1 if you have the <netdnet/dn.h> header file. */
-#undef HAVE_NETDNET_DN_H
-
 /* Define to 1 if you have the <net/if.h> header file. */
 #undef HAVE_NET_IF_H
 
 /* Define to 1 if you have the `strsep' function. */
 #undef HAVE_STRSEP
 
-/* Define to 1 if the system has the type `struct dn_naddr'. */
-#undef HAVE_STRUCT_DN_NADDR
-
 /* Define to 1 if the system has the type `struct ether_addr'. */
 #undef HAVE_STRUCT_ETHER_ADDR
 
 /* define if libpcap has yydebug */
 #undef HAVE_YYDEBUG
 
-/* Define to 1 if netenet/dnetdb.h declares `dnet_htoa' */
-#undef NETDNET_DNETDB_H_DECLARES_DNET_HTOA
-
 /* Define to 1 if netinet/ether.h declares `ether_ntohost' */
 #undef NETINET_ETHER_H_DECLARES_ETHER_NTOHOST
 
index 0660441f108487bf6b7e239a03fec31d50362ef6..3b2041c9a2016cb870f476e9e3b432bd146c08f6 100755 (executable)
--- a/configure
+++ b/configure
@@ -4927,135 +4927,6 @@ if test "$ipv6" = "yes" -a "$ipv6lib" != "none"; then
        fi
 fi
 
-{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing dnet_htoa" >&5
-$as_echo_n "checking for library containing dnet_htoa... " >&6; }
-if ${ac_cv_search_dnet_htoa+:} false; then :
-  $as_echo_n "(cached) " >&6
-else
-  ac_func_search_save_LIBS=$LIBS
-cat confdefs.h - <<_ACEOF >conftest.$ac_ext
-/* end confdefs.h.  */
-
-/* Override any GCC internal prototype to avoid an error.
-   Use char because int might match the return type of a GCC
-   builtin and then its argument prototype would still apply.  */
-#ifdef __cplusplus
-extern "C"
-#endif
-char dnet_htoa ();
-int
-main ()
-{
-return dnet_htoa ();
-  ;
-  return 0;
-}
-_ACEOF
-for ac_lib in '' dnet; do
-  if test -z "$ac_lib"; then
-    ac_res="none required"
-  else
-    ac_res=-l$ac_lib
-    LIBS="-l$ac_lib  $ac_func_search_save_LIBS"
-  fi
-  if ac_fn_c_try_link "$LINENO"; then :
-  ac_cv_search_dnet_htoa=$ac_res
-fi
-rm -f core conftest.err conftest.$ac_objext \
-    conftest$ac_exeext
-  if ${ac_cv_search_dnet_htoa+:} false; then :
-  break
-fi
-done
-if ${ac_cv_search_dnet_htoa+:} false; then :
-
-else
-  ac_cv_search_dnet_htoa=no
-fi
-rm conftest.$ac_ext
-LIBS=$ac_func_search_save_LIBS
-fi
-{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_dnet_htoa" >&5
-$as_echo "$ac_cv_search_dnet_htoa" >&6; }
-ac_res=$ac_cv_search_dnet_htoa
-if test "$ac_res" != no; then :
-  test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
-
-
-$as_echo "#define HAVE_DNET_HTOA 1" >>confdefs.h
-
-       #
-       # OK, we have dnet_htoa().  Do we have netdnet/dnetdb.h?
-       #
-       for ac_header in netdnet/dnetdb.h
-do :
-  ac_fn_c_check_header_mongrel "$LINENO" "netdnet/dnetdb.h" "ac_cv_header_netdnet_dnetdb_h" "$ac_includes_default"
-if test "x$ac_cv_header_netdnet_dnetdb_h" = xyes; then :
-  cat >>confdefs.h <<_ACEOF
-#define HAVE_NETDNET_DNETDB_H 1
-_ACEOF
-
-fi
-
-done
-
-       if test "$ac_cv_header_netdnet_dnetdb_h" = "yes"; then
-               #
-               # Yes.  Does it declare dnet_htoa()?
-               #
-               ac_fn_c_check_decl "$LINENO" "dnet_htoa" "ac_cv_have_decl_dnet_htoa" "
-$ac_includes_default
-#include <netdnet/dnetdb.h>
-
-"
-if test "x$ac_cv_have_decl_dnet_htoa" = xyes; then :
-
-                       # Yes.
-
-$as_echo "#define NETDNET_DNETDB_H_DECLARES_DNET_HTOA /**/" >>confdefs.h
-
-
-fi
-
-       fi
-
-       #
-       # Do we have netdnet/dn.h?
-       #
-       for ac_header in netdnet/dn.h
-do :
-  ac_fn_c_check_header_mongrel "$LINENO" "netdnet/dn.h" "ac_cv_header_netdnet_dn_h" "$ac_includes_default"
-if test "x$ac_cv_header_netdnet_dn_h" = xyes; then :
-  cat >>confdefs.h <<_ACEOF
-#define HAVE_NETDNET_DN_H 1
-_ACEOF
-
-fi
-
-done
-
-       if test "$ac_cv_header_netdnet_dn_h" = "yes"; then
-               #
-               # Yes.  Does it declare struct dn_naddr?
-               #
-               ac_fn_c_check_type "$LINENO" "struct dn_naddr" "ac_cv_type_struct_dn_naddr" "
-#include <netdnet/dn.h>
-
-"
-if test "x$ac_cv_type_struct_dn_naddr" = xyes; then :
-
-cat >>confdefs.h <<_ACEOF
-#define HAVE_STRUCT_DN_NADDR 1
-_ACEOF
-
-
-fi
-
-       fi
-
-fi
-
-
 ac_fn_c_check_func "$LINENO" "strlcat" "ac_cv_func_strlcat"
 if test "x$ac_cv_func_strlcat" = xyes; then :
   $as_echo "#define HAVE_STRLCAT 1" >>confdefs.h
index ed3e14e375881f3f8e48471e6d37484fb748db66..26c1b3a8c0ccd5f644265fe2933c93de24a86753 100644 (file)
@@ -385,45 +385,6 @@ if test "$ipv6" = "yes" -a "$ipv6lib" != "none"; then
        fi
 fi
 
-AC_SEARCH_LIBS(dnet_htoa, dnet,
-[
-       AC_DEFINE(HAVE_DNET_HTOA, 1,
-           [define if you have the dnet_htoa function])
-       #
-       # OK, we have dnet_htoa().  Do we have netdnet/dnetdb.h?
-       #
-       AC_CHECK_HEADERS(netdnet/dnetdb.h)
-       if test "$ac_cv_header_netdnet_dnetdb_h" = "yes"; then
-               #
-               # Yes.  Does it declare dnet_htoa()?
-               #
-               AC_CHECK_DECL(dnet_htoa,
-               [
-                       # Yes.
-                       AC_DEFINE(NETDNET_DNETDB_H_DECLARES_DNET_HTOA,,
-                           [Define to 1 if netenet/dnetdb.h declares `dnet_htoa'])
-               ],,
-               [
-AC_INCLUDES_DEFAULT
-#include <netdnet/dnetdb.h>
-               ])
-       fi
-
-       #
-       # Do we have netdnet/dn.h?
-       #
-       AC_CHECK_HEADERS(netdnet/dn.h)
-       if test "$ac_cv_header_netdnet_dn_h" = "yes"; then
-               #
-               # Yes.  Does it declare struct dn_naddr?
-               #
-               AC_CHECK_TYPES(struct dn_naddr,,,
-               [
-#include <netdnet/dn.h>
-               ])
-       fi
-])
-
 AC_REPLACE_FUNCS(strlcat strlcpy strdup strsep getservent getopt_long)
 AC_CHECK_FUNCS(fork vfork strftime)
 AC_CHECK_FUNCS(setlinebuf)
index d3e38a80ca279c9ba7501c7cc17f7ebcc153c1cf..7267cff851482d1a26e2cded5264624c9599df38 100644 (file)
@@ -718,7 +718,6 @@ extern void nd_print_invalid(netdissect_options *);
 extern int mask2plen(uint32_t);
 extern int mask62plen(const u_char *);
 
-extern const char *dnname_string(netdissect_options *, u_short);
 extern const char *dnnum_string(netdissect_options *, u_short);
 
 extern int decode_prefix4(netdissect_options *, const u_char *, u_int, char *, size_t);
index 31166e3f31df60d09924d7563a332da562642760..047916d30f6d305626bc327fd80f04d0e9b721df 100644 (file)
 #include <stdlib.h>
 #include <string.h>
 
-#ifdef HAVE_DNET_HTOA
-  #ifdef HAVE_NETDNET_DN_H
-    #include <netdnet/dn.h>
-  #endif
-  #ifndef HAVE_STRUCT_DN_NADDR
-#define DN_MAXADDL     20              /* max size of DECnet address */
-struct dn_naddr {
-       unsigned short  a_len;          /* length of address */
-       unsigned char   a_addr[DN_MAXADDL]; /* address as bytes */
-};
-  #endif /* HAVE_STRUCT_DN_NADDR */
-  #ifdef HAVE_NETDNET_DNETDB_H
-    #include <netdnet/dnetdb.h>
-  #endif
-  #ifndef NETDNET_DNETDB_H_DECLARES_DNET_HTOA
-    extern char *dnet_htoa(struct dn_naddr *);
-  #endif
-#endif
-
 #include "netdissect.h"
 #include "extract.h"
 #include "addrtoname.h"
@@ -1248,22 +1229,3 @@ dnnum_string(netdissect_options *ndo, u_short dnaddr)
        snprintf(str, siz, "%u.%u", area, node);
        return(str);
 }
-
-const char *
-dnname_string(netdissect_options *ndo, u_short dnaddr)
-{
-#ifdef HAVE_DNET_HTOA
-       struct dn_naddr dna;
-       char *dnname;
-
-       dna.a_len = sizeof(short);
-       memcpy((char *)dna.a_addr, (char *)&dnaddr, sizeof(short));
-       dnname = dnet_htoa(&dna);
-       if(dnname != NULL)
-               return (strdup(dnname));
-       else
-               return(dnnum_string(ndo, dnaddr));
-#else
-       return(dnnum_string(ndo, dnaddr));      /* punt */
-#endif
-}
index bf4f2ef5057e81167b98713817360e55ce819ca5..a63cdcf0bd6ecb83700da1bf0e47a5900c458570 100644 (file)
--- a/tcpdump.c
+++ b/tcpdump.c
@@ -3065,9 +3065,6 @@ print_version(void)
        smi_version_string = nd_smi_version_string();
        if (smi_version_string != NULL)
                (void)fprintf (stderr, "SMI-library: %s\n", smi_version_string);
-#ifdef HAVE_DNET_HTOA
-       (void)fprintf(stderr, "libdnet unknown version\n");
-#endif
 
 #if defined(__SANITIZE_ADDRESS__)
        (void)fprintf (stderr, "Compiled with AddressSanitizer/GCC.\n");