Skip to content

Commit

Permalink
(for 4.9.3) libdnet has bugs, do not use it.
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
infrastation authored and fxlb committed Aug 27, 2019
1 parent 9ba9138 commit 9a6eb27
Show file tree
Hide file tree
Showing 7 changed files with 3 additions and 149 deletions.
1 change: 0 additions & 1 deletion .travis.yml
Expand Up @@ -47,7 +47,6 @@ addons:
packages:
- libssl-dev
- libssl1.0.0
- libdnet-dev
- libsmi2-dev
- libcap-ng-dev
- libpcap-dev
Expand Down
5 changes: 1 addition & 4 deletions addrtoname.c
Expand Up @@ -1226,10 +1226,7 @@ dnaddr_string(netdissect_options *ndo, u_short dnaddr)

tp->addr = dnaddr;
tp->nxt = newhnamemem(ndo);
if (ndo->ndo_nflag)
tp->name = dnnum_string(ndo, dnaddr);
else
tp->name = dnname_string(ndo, dnaddr);
tp->name = dnnum_string(ndo, dnaddr);

return(tp->name);
}
Expand Down
9 changes: 0 additions & 9 deletions config.h.in
Expand Up @@ -28,9 +28,6 @@
don't. */
#undef HAVE_DECL_ETHER_NTOHOST

/* define if you have the dnet_htoa function */
#undef HAVE_DNET_HTOA

/* Define to 1 if you have the `ether_ntohost' function. */
#undef HAVE_ETHER_NTOHOST

Expand Down Expand Up @@ -67,12 +64,6 @@
/* Define to 1 if you have the <memory.h> header file. */
#undef HAVE_MEMORY_H

/* Define to 1 if you have the <netdnet/dnetdb.h> header file. */
#undef HAVE_NETDNET_DNETDB_H

/* define if you have a dnet_htoa declaration in <netdnet/dnetdb.h> */
#undef HAVE_NETDNET_DNETDB_H_DNET_HTOA

/* Define to 1 if you have the <netinet/ether.h> header file. */
#undef HAVE_NETINET_ETHER_H

Expand Down
88 changes: 1 addition & 87 deletions configure
Expand Up @@ -4193,7 +4193,7 @@ fi
done
for ac_header in fcntl.h rpc/rpc.h rpc/rpcent.h netdnet/dnetdb.h
for ac_header in fcntl.h rpc/rpc.h rpc/rpcent.h
do :
as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
ac_fn_c_check_header_mongrel "$LINENO" "$ac_header" "$as_ac_Header" "$ac_includes_default"
Expand Down Expand Up @@ -5057,33 +5057,6 @@ if test "$ipv6" = "yes" -a "$ipv6lib" != "none"; then
fi
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for dnet_htoa declaration in netdnet/dnetdb.h" >&5
$as_echo_n "checking for dnet_htoa declaration in netdnet/dnetdb.h... " >&6; }
if ${td_cv_decl_netdnet_dnetdb_h_dnet_htoa+:} false; then :
$as_echo_n "(cached) " >&6
else
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
#include <netdnet/dnetdb.h>
_ACEOF
if (eval "$ac_cpp conftest.$ac_ext") 2>&5 |
$EGREP "dnet_htoa" >/dev/null 2>&1; then :
td_cv_decl_netdnet_dnetdb_h_dnet_htoa=yes
else
td_cv_decl_netdnet_dnetdb_h_dnet_htoa=no
fi
rm -f conftest*
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $td_cv_decl_netdnet_dnetdb_h_dnet_htoa" >&5
$as_echo "$td_cv_decl_netdnet_dnetdb_h_dnet_htoa" >&6; }
if test "$td_cv_decl_netdnet_dnetdb_h_dnet_htoa" = yes; then
$as_echo "#define HAVE_NETDNET_DNETDB_H_DNET_HTOA 1" >>confdefs.h
fi
ac_fn_c_check_func "$LINENO" "vfprintf" "ac_cv_func_vfprintf"
if test "x$ac_cv_func_vfprintf" = xyes; then :
$as_echo "#define HAVE_VFPRINTF 1" >>confdefs.h
Expand Down Expand Up @@ -5291,65 +5264,6 @@ done
;;
esac
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for library containing dnet_htoa" >&5
$as_echo_n "checking for library containing dnet_htoa... " >&6; }
if ${ac_cv_search_dnet_htoa+:} false; then :
$as_echo_n "(cached) " >&6
else
ac_func_search_save_LIBS=$LIBS
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
/* Override any GCC internal prototype to avoid an error.
Use char because int might match the return type of a GCC
builtin and then its argument prototype would still apply. */
#ifdef __cplusplus
extern "C"
#endif
char dnet_htoa ();
int
main ()
{
return dnet_htoa ();
;
return 0;
}
_ACEOF
for ac_lib in '' dnet; do
if test -z "$ac_lib"; then
ac_res="none required"
else
ac_res=-l$ac_lib
LIBS="-l$ac_lib $ac_func_search_save_LIBS"
fi
if ac_fn_c_try_link "$LINENO"; then :
ac_cv_search_dnet_htoa=$ac_res
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext
if ${ac_cv_search_dnet_htoa+:} false; then :
break
fi
done
if ${ac_cv_search_dnet_htoa+:} false; then :
else
ac_cv_search_dnet_htoa=no
fi
rm conftest.$ac_ext
LIBS=$ac_func_search_save_LIBS
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_search_dnet_htoa" >&5
$as_echo "$ac_cv_search_dnet_htoa" >&6; }
ac_res=$ac_cv_search_dnet_htoa
if test "$ac_res" != no; then :
test "$ac_res" = "none required" || LIBS="$ac_res $LIBS"
$as_echo "#define HAVE_DNET_HTOA 1" >>confdefs.h
fi
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for main in -lrpc" >&5
$as_echo_n "checking for main in -lrpc... " >&6; }
if ${ac_cv_lib_rpc_main+:} false; then :
Expand Down
15 changes: 1 addition & 14 deletions configure.ac
Expand Up @@ -32,7 +32,7 @@ if test "$ac_cv___attribute__" = "yes"; then
fi
fi

AC_CHECK_HEADERS(fcntl.h rpc/rpc.h rpc/rpcent.h netdnet/dnetdb.h)
AC_CHECK_HEADERS(fcntl.h rpc/rpc.h rpc/rpcent.h)
AC_CHECK_HEADERS(net/pfvar.h, , , [#include <sys/types.h>
#include <sys/socket.h>
#include <net/if.h>])
Expand Down Expand Up @@ -385,16 +385,6 @@ if test "$ipv6" = "yes" -a "$ipv6lib" != "none"; then
fi
fi

AC_CACHE_CHECK([for dnet_htoa declaration in netdnet/dnetdb.h],
[td_cv_decl_netdnet_dnetdb_h_dnet_htoa],
[AC_EGREP_HEADER(dnet_htoa, netdnet/dnetdb.h,
td_cv_decl_netdnet_dnetdb_h_dnet_htoa=yes,
td_cv_decl_netdnet_dnetdb_h_dnet_htoa=no)])
if test "$td_cv_decl_netdnet_dnetdb_h_dnet_htoa" = yes; then
AC_DEFINE(HAVE_NETDNET_DNETDB_H_DNET_HTOA, 1,
[define if you have a dnet_htoa declaration in <netdnet/dnetdb.h>])
fi

AC_REPLACE_FUNCS(vfprintf strlcat strlcpy strdup strsep getopt_long)
AC_CHECK_FUNCS(fork vfork strftime)
AC_CHECK_FUNCS(setlinebuf alarm)
Expand All @@ -408,9 +398,6 @@ fi

AC_LBL_TYPE_SIGNAL

AC_SEARCH_LIBS(dnet_htoa, dnet,
AC_DEFINE(HAVE_DNET_HTOA, 1, [define if you have the dnet_htoa function]))

AC_CHECK_LIB(rpc, main) dnl It's unclear why we might need -lrpc

dnl Some platforms may need -lnsl for getrpcbynumber.
Expand Down
1 change: 0 additions & 1 deletion netdissect.h
Expand Up @@ -641,7 +641,6 @@ extern int nextproto6_cksum(netdissect_options *, const struct ip6_hdr *, const
extern int mask2plen(uint32_t);
extern int mask62plen(const u_char *);

extern const char *dnname_string(netdissect_options *, u_short);
extern const char *dnnum_string(netdissect_options *, u_short);

extern char *smb_errstr(int, int);
Expand Down
33 changes: 0 additions & 33 deletions print-decnet.c
Expand Up @@ -30,10 +30,6 @@
struct mbuf;
struct rtentry;

#ifdef HAVE_NETDNET_DNETDB_H
#include <netdnet/dnetdb.h>
#endif

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
Expand Down Expand Up @@ -75,12 +71,6 @@ typedef union etheraddress etheraddr; /* Ethernet address */
#define AREASHIFT 10 /* bit-offset for area field */
#define NODEMASK 01777 /* mask for node address field */

#define DN_MAXADDL 20 /* max size of DECnet address */
struct dn_naddr {
uint16_t a_len; /* length of address */
uint8_t a_addr[DN_MAXADDL]; /* address as bytes */
};

/*
* Define long and short header formats.
*/
Expand Down Expand Up @@ -492,10 +482,6 @@ static int print_elist(const char *, u_int);
static int print_nsp(netdissect_options *, const u_char *, u_int);
static void print_reason(netdissect_options *, int);

#ifndef HAVE_NETDNET_DNETDB_H_DNET_HTOA
extern char *dnet_htoa(struct dn_naddr *);
#endif

void
decnet_print(netdissect_options *ndo,
register const u_char *ap, register u_int length,
Expand Down Expand Up @@ -1252,22 +1238,3 @@ dnnum_string(netdissect_options *ndo, u_short dnaddr)
snprintf(str, siz, "%d.%d", area, node);
return(str);
}

const char *
dnname_string(netdissect_options *ndo, u_short dnaddr)
{
#ifdef HAVE_DNET_HTOA
struct dn_naddr dna;
char *dnname;

dna.a_len = sizeof(short);
memcpy((char *)dna.a_addr, (char *)&dnaddr, sizeof(short));
dnname = dnet_htoa(&dna);
if(dnname != NULL)
return (strdup(dnname));
else
return(dnnum_string(ndo, dnaddr));
#else
return(dnnum_string(ndo, dnaddr)); /* punt */
#endif
}

0 comments on commit 9a6eb27

Please sign in to comment.