Fix compiling on GNU/Hurd. [skip appveyor]

GNU/Hurd does not define MAXHOSTNAMELEN because it does not define
HOST_NAME_MAX, even if __USE_POSIX is defined.  This causes the
following:

./print-bgp.c:1997:14: error: 'MAXHOSTNAMELEN' undeclared (first use in
  this function)
./print-bgp.c:2965:14: error: 'MAXHOSTNAMELEN' undeclared (first use in
  this function)
./print-icmp.c:502:11: error: 'MAXHOSTNAMELEN' undeclared (first use in
  this function)

However, the above code should not depend on this OS-specific detail to
size its temporary printing buffers, so just hard-code the sizes.
This commit is contained in:
Denis Ovsienko 2024-02-04 15:31:19 +00:00
parent ec780ab24a
commit 6cf3ea7d0f
4 changed files with 5 additions and 3 deletions

View File

@ -40,6 +40,7 @@ DayOfTheWeek, Month DD, YYYY / The Tcpdump Group
Detect OS IPv6 support using AF_INET6 only.
Remove all remaining support for BSD/OS, IRIX, {OSF/1, Digital Unix,
Tru64 Unix}, SINIX and Ultrix.
Fix compiling on GNU/Hurd.
DayOfTheWeek, Month DD, YYYY / The Tcpdump Group
Summary for 4.99.5 tcpdump release (so far!)

View File

@ -31,6 +31,7 @@ tcpdump compiles and works on at least the following platforms:
* Haiku
* HP-UX 11i
* illumos (OmniOS, OpenIndiana)
* GNU/Hurd
* GNU/Linux
* {Mac} OS X / macOS
* NetBSD

View File

@ -1994,7 +1994,7 @@ bgp_attr_print(netdissect_options *ndo,
int advance;
u_int tlen;
const u_char *tptr;
char buf[MAXHOSTNAMELEN + 100];
char buf[512];
u_int as_size;
int add_path4, add_path6;
int ret;
@ -2962,7 +2962,7 @@ bgp_update_print(netdissect_options *ndo,
{
const u_char *p;
u_int withdrawn_routes_len;
char buf[MAXHOSTNAMELEN + 100];
char buf[512];
int wpfx;
u_int len;
int i;

View File

@ -499,7 +499,7 @@ icmp_print(netdissect_options *ndo, const u_char *bp, u_int plen,
const char *str;
const uint8_t *obj_tptr;
u_int hlen;
char buf[MAXHOSTNAMELEN + 100];
char buf[512];
struct cksum_vec vec[1];
ndo->ndo_protocol = "icmp";