[Tcsh] [PATCH] REMOTEHOST causes hang with IPv6 addresses

Jamie Landeg-Jones jamie at catflap.org
Fri Feb 24 13:04:20 UTC 2023


Jamie Landeg-Jones <jamie at catflap.org> wrote:

> I didn't have the delay, though - it turns out that no DNS lookups are
> done on startup here.

Looking further at this (using the latest code from github):

|     /* Look for host:display.screen */
|     /*
|      * There is conflict with IPv6 address and X DISPLAY.  So,
|      * we assume there is no IPv6 address in utmp and don't
|      * touch here.
|      */
|
|     if ((sptr = strchr(name, ':')) != NULL)
| 	*sptr = '\0';
|     /* Leave IPv4 address as is */
|     /*
|      * we use inet_addr here, not inet_aton because many systems
|      * have not caught up yet.
|      */
|     addr.s_addr = inet_addr(name);
|     if (addr.s_addr != (unsigned int)~0)
|     {
| 	host = name;
|     }
|     else {
| 	if (sptr != name) {

As Chuck discovered, the "if ((sptr = strchr(name, ':')) != NULL)"
itself causes "name" to be truncated for IPv6 addresses.

Later on, the following "inet_addr" function is now run on the truncated
name.

With me, on a 2001:...... address, this meant calling inet_addr on the
value "2001", which doesn't fail, as it's a valid IP4 address. Hence
"host" gets set to "2001".

In Chucks case, he was using a "fdd1:...." address - the hex part, I
assume, would cause the inet_addr to fail, and as sptr was now set to
NULL, the following part that does the DNS lookup was attempted in his case.

So, to replicate his issue, connect to the machine on a link-local IP
address that doesn't have a PTR DNS record!

Hope this helps a bit,

Cheers, Jamie


More information about the Tcsh mailing list