Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 16 Mar 1996 23:20:02 -0800 (PST)
From:      GNU GNATS <gnats>
To:        undisclosed-recipients:;
Subject:   bin/1084: gethostname.pl returns trailing \0 character
Message-ID:  <199603170720.XAA27222@freefall.freebsd.org>
Resent-Message-ID: <199603170720.XAA27222@freefall.freebsd.org>

next in thread | raw e-mail | index | archive | help

>Number:         1084
>Category:       bin
>Synopsis:       gethostname.pl returns trailing \0 character
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sat Mar 16 23:20:01 PST 1996
>Last-Modified:
>Originator:     Giles Lean
>Organization:
Giles Lean                                             Nemeton Pty Ltd
<giles@nemeton.com.au>                           phone: +61 3 480 2118        
>Release:        -current (since the introduction of gethostname.pl)
>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;

>Audit-Trail:
>Unformatted:
>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 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
Date: Sun, 17 Mar 1996 17:23:17 +1100
From: Giles Lean <giles@topaz.nemeton.com.au>
Message-Id: <199603170623.RAA16017@topaz.nemeton.com.au>
To: FreeBSD-gnats-submit@freebsd.org
cc: giles@nemeton.com.au
Subject: gethostname.pl returns trailing \0 character
Reply-To: giles@topaz.nemeton.com.au
X-send-pr-version: 3.2
Content-Type: text





Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199603170720.XAA27222>