forwarded message from mouring at etoh.eviladmin.org

Markus Friedl markus.friedl at informatik.uni-erlangen.de
Tue Jul 24 04:55:53 EST 2001


this patch looks fine,

however, i don't want to see a magic numer 401 in openssh's code.

why not just define MAXHOSTNAMELEN for HURD ?

-m

On Mon, Jul 23, 2001 at 03:41:04AM +0200, Marcus Brinkmann wrote:
> Hi,
> 
> I just looked in the mail archive to see what patch was posted
> (http://marc.theaimsgroup.com/?l=openssh-unix-dev&m=99580473611227&w=2)
> 
> This piece of the patch is not good, because it is not defined if the
> truncated name will be null terminated.  This can be fixed by null
> terminating the reult no matter what, I think.
> 
> However, I really suggest to just put a get_host_name implementation in ssh,
> that works on all systems and returns a malloced buffer.  This can then be
> used everywhere were gethostname is used.
> 
> A good implementation is for example in GNU inetutils
> (libinetutils/localhost.c)
> 
> Thanks,
> Marcus
> 
> diff -ur openssh-2.9p2-/channels.c openssh-2.9p2/channels.c
> --- openssh-2.9p2-/channels.c   Sat Mar 17 01:47:55 2001
> +++ openssh-2.9p2/channels.c    Thu Jun 28 20:11:02 2001
> @@ -1965,7 +1965,7 @@
>         char strport[NI_MAXSERV];
>         int gaierr, n, num_socks = 0, socks[NUM_SOCKS];
>         char display[512];
> -       char hostname[MAXHOSTNAMELEN];
> +       char hostname[401];     /* we only use the first 400 bytes anyway*/
> 
>         for (display_number = x11_display_offset;
>              display_number < MAX_DISPLAYS;
> @@ -2037,7 +2037,8 @@
>         }
> 
>         /* Set up a suitable value for the DISPLAY variable. */
> -       if (gethostname(hostname, sizeof(hostname)) < 0)
> +       if (gethostname(hostname, sizeof(hostname)) < 0
> +           && errno != ENAMETOOLONG)
>                 fatal("gethostname: %.100s", strerror(errno));
> 
>  #ifdef IPADDR_IN_DISPLAY
> 
> 
> -- 
> `Rhubarb is no Egyptian god.' Debian http://www.debian.org brinkmd at debian.org
> Marcus Brinkmann              GNU    http://www.gnu.org    marcus at gnu.org
> Marcus.Brinkmann at ruhr-uni-bochum.de
> http://www.marcus-brinkmann.de



More information about the openssh-unix-dev mailing list