[PATCH 7/7] libbb.h: Handle missing HOST_NAME_MAX; ensure MAXFOOLEN agrees with FOO_MAX

James Clarke jrtc27 at jrtc27.com
Tue Oct 31 15:49:22 UTC 2017


On 31 Oct 2017, at 15:06, Denys Vlasenko <vda.linux at googlemail.com> wrote:
> 
> How about this?
> 
> --- a/networking/traceroute.c
> +++ b/networking/traceroute.c
> @@ -709,6 +709,9 @@ packet_ok(int read_len, len_and_sockaddr *from_lsa,
> 
> # if ENABLE_FEATURE_TRACEROUTE_VERBOSE
>        if (verbose) {
> +#  ifndef MAXHOSTNAMELEN
> +#   define MAXHOSTNAMELEN 80
> +#  endif

80 is definitely not the right fallback value to use. As mentioned by Kang-Che
earlier in the thread, 255 is the POSIX defined minimum[0] for HOST_NAME_MAX.
In fact, it should really be using INET6_ADDRSTRLEN here since it's just being
used as the destination for inet_ntop with AF_INET6, and this has to be defined
in <netinet/in.h>, though the spec says it must be 46 so we could just use that
as a fallback if it isn't even defined.[1]

>                unsigned char *p;
>                char pa1[MAXHOSTNAMELEN];
>                char pa2[MAXHOSTNAMELEN];
> diff --git a/util-linux/fdisk_osf.c b/util-linux/fdisk_osf.c
> index 1141b78..1328c1f 100644
> --- a/util-linux/fdisk_osf.c
> +++ b/util-linux/fdisk_osf.c
> @@ -709,6 +709,9 @@ sync_disks(void)
> static void
> xbsd_write_bootstrap(void)
> {
> +#ifndef MAXPATHLEN
> +# define MAXPATHLEN 1024
> +#endif

This is linux-specific, which has MAXPATHLEN, so there's no point doing this.

>        char path[MAXPATHLEN];
>        const char *bootdir = BSD_LINUX_BOOTDIR;
>        const char *dkbasename;

Regards,
James

[0] http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/limits.h.html
[1] http://pubs.opengroup.org/onlinepubs/000095399/basedefs/netinet/in.h.html



More information about the busybox mailing list