From Jim.Pirzyk@disney.com  Fri Jan 26 12:33:06 2001
Return-Path: <Jim.Pirzyk@disney.com>
Received: from mail.disney.com (mail.disney.com [204.128.192.15])
	by hub.freebsd.org (Postfix) with ESMTP id 8FAE437B401
	for <FreeBSD-gnats-submit@freebsd.org>; Fri, 26 Jan 2001 12:33:06 -0800 (PST)
Received: from pain10.corp.disney.com (root@pain10.corp.disney.com [153.7.110.100])
	by mail.disney.com (Switch-2.0.1/Switch-2.0.1) with SMTP id f0QKWdp03083
	for <FreeBSD-gnats-submit@freebsd.org>; Fri, 26 Jan 2001 12:32:39 -0800 (PST)
Received: from louie.fa.disney.com by pain.corp.disney.com with ESMTP for FreeBSD-gnats-submit@freebsd.org; Fri, 26 Jan 2001 12:33:42 -0800
Received: from plio.fan.fa.disney.com (plio.fan.fa.disney.com [153.7.118.2])
	by louie.fa.disney.com (8.9.2/8.9.2) with ESMTP id MAA13189
	for <FreeBSD-gnats-submit@freebsd.org>; Fri, 26 Jan 2001 12:33:04 -0800 (PST)
	(envelope-from Jim.Pirzyk@fa.disney.com)
Received: from snoopy.fan.fa.disney.com (snoopy.fan.fa.disney.com [153.7.117.170])
	by plio.fan.fa.disney.com (8.9.2/8.9.2) with ESMTP id MAA28576
	for <FreeBSD-gnats-submit@freebsd.org>; Fri, 26 Jan 2001 12:33:03 -0800 (PST)
	(envelope-from Jim.Pirzyk@fa.disney.com)
Received: (from Jim.Pirzyk@localhost)
	by snoopy.fan.fa.disney.com (8.11.1/8.9.3) id f0QKX3x09073;
	Fri, 26 Jan 2001 12:33:03 -0800 (PST)
	(envelope-from Jim.Pirzyk@fa.disney.com)
Message-Id: <200101262033.f0QKX3x09073@snoopy.fan.fa.disney.com>
Date: Fri, 26 Jan 2001 12:33:03 -0800 (PST)
From: Jim.Pirzyk@disney.com
Reply-To: Jim.Pirzyk@disney.com
To: FreeBSD-gnats-submit@freebsd.org
Subject: realhostname_sa does not call trimdomain before IP number is stored
X-Send-Pr-Version: 3.2

>Number:         24659
>Category:       bin
>Synopsis:       realhostname_sa does not call trimdomain for IPv4 addresses
>Confidential:   no
>Severity:       serious
>Priority:       medium
>Responsible:    brian
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Fri Jan 26 12:40:01 PST 2001
>Closed-Date:    Sun Jan 28 13:51:49 PST 2001
>Last-Modified:  Sun Jan 28 13:52:32 PST 2001
>Originator:     Jim Pirzyk
>Release:        FreeBSD 4.2-RELEASE i386
>Organization:
>Environment:

	Using ssh to login to remote FreeBSD boxes and hostnames > 16 characters
	in the local domain.

>Description:

	in the realhostname_sa routine (libutil), if the hostname of the remote
	system is > 16 characters long, the IP number is stored in the wtmp
	file.  This happens even for hosts that are in the same DNS Domain.
	Conversely, in the login program, which does not call realhostname_sa,
	it trims the hostname before writing the hostname into the file.
	realhostname_sa is called by sshd. 

>How-To-Repeat:

	Login to a remote FreeBSD host from a host that has a long hostname.
	First login with rsh, then do a finger -sh, it should show a short
	hostname for 'Where'.  Then login via ssh, do the finger -sh and it
	will show the IP number instead.

>Fix:

*** realhostname.c.orig Tue Jul 18 03:25:37 2000
--- realhostname.c      Fri Jan 26 12:23:46 2001
***************
*** 131,150 ****
                                                freeaddrinfo(ores);
                                                goto numeric;
                                        }
!                                       if (strlen(ores->ai_canonname) > hsize) {
                                                if (addr->sa_family == AF_INET) {
                                                        freeaddrinfo(ores);
                                                        goto numeric;
                                                }
!                                               strncpy(buf,
!                                                       ores->ai_canonname,
!                                                       sizeof(buf));
!                                               trimdomain(buf, hsize);
!                                               strncpy(host, buf, hsize);
!                                       } else
!                                               strncpy(host,
!                                                       ores->ai_canonname,
!                                                       hsize);
                                        break;
                                }
                                ((struct sockinet *)addr)->si_port = port;
--- 134,150 ----
                                                freeaddrinfo(ores);
                                                goto numeric;
                                        }
!                                       strncpy(buf,
!                                               ores->ai_canonname,
!                                               sizeof(buf));
!                                       trimdomain(buf, hsize);
!                                       strncpy(host, buf, hsize);
!                                       if (strlen(host) > hsize) {
                                                if (addr->sa_family == AF_INET) {
                                                        freeaddrinfo(ores);
                                                        goto numeric;
                                                }
!                                       }
                                        break;
                                }
                                ((struct sockinet *)addr)->si_port = port;



>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-bugs->brian 
Responsible-Changed-By: brian 
Responsible-Changed-When: Fri Jan 26 13:35:28 PST 2001 
Responsible-Changed-Why:  
I'll fix (apply?) this. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=24659 
State-Changed-From-To: open->closed 
State-Changed-By: brian 
State-Changed-When: Sun Jan 28 13:51:49 PST 2001 
State-Changed-Why:  
Fixed in -current.  I'll MFC in 2 weeks if there are no problems. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=24659 
>Unformatted:
