From giles@topaz.nemeton.com.au  Sat Mar 16 23:11:14 1996
Received: from topaz.nemeton.com.au (topaz.nemeton.com.au [203.8.3.18]) by nemeton.com.au (8.6.12/8.6.9) with ESMTP id RAA23390; Sun, 17 Mar 1996 17:26:40 +1100
Received: (from giles@localhost) by topaz.nemeton.com.au (8.6.12/8.6.12) id RAA16017; Sun, 17 Mar 1996 17:23:17 +1100
Message-Id: <199603170623.RAA16017@topaz.nemeton.com.au>
Date: Sun, 17 Mar 1996 17:23:17 +1100
From: Giles Lean <giles@topaz.nemeton.com.au>
Reply-To: giles@topaz.nemeton.com.au
To: FreeBSD-gnats-submit@freebsd.org
Cc: giles@nemeton.com.au
Subject: gethostname.pl returns trailing \0 character
X-Send-Pr-Version: 3.2

>Number:         1084
>Category:       bin
>Synopsis:       gethostname.pl returns trailing \0 character
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sat Mar 16 23:20:01 PST 1996
>Closed-Date:    Mon Mar 18 22:53:19 MET 1996
>Last-Modified:  Sat Mar 16 06:43:30 UTC 2013
>Originator:     Giles Lean
>Release:        -current (since the introduction of gethostname.pl)
>Organization:
Giles Lean                                             Nemeton Pty Ltd
<giles@nemeton.com.au>                           phone: +61 3 480 2118        
>Environment:

	FreeBSD-2.1.0 with gethostname.pl brought in from -current.

>Description:

	The gethostname.pl library is a good idea, but it doesn't
	trim the trailing \0 character.  The perl5 module Sys::Hostname
	does trim the \0.

>How-To-Repeat:

perl -e "require \"gethostname.pl\"; print &gethostname'gethostname" | od -c

>Fix:

	Apply the following diff:
*** gethostname.pl-old	Sun Mar 17 17:21:54 1996
--- gethostname.pl	Sun Mar 17 17:22:03 1996
***************
*** 31,37 ****
  	die "Cannot get hostname via sysctl(2), errno = $!\n";
  
      ($len) = unpack("L", $oldlen);
!     return substr($oldval, 0, $len);
  }
  
  1;
--- 31,37 ----
  	die "Cannot get hostname via sysctl(2), errno = $!\n";
  
      ($len) = unpack("L", $oldlen);
!     return substr($oldval, 0, $len - 1);
  }
  
  1;

>Release-Note:
>Audit-Trail:
State-Changed-From-To: open->closed 
State-Changed-By: joerg 
State-Changed-When: Mon Mar 18 22:53:19 MET 1996 
State-Changed-Why:  
Suggested fix applied in rev 1.2 of gethostname.pl. 

>Unformatted:

