From cian@hardy.cirt.eircom.net  Wed Feb 18 07:10:45 2004
Return-Path: <cian@hardy.cirt.eircom.net>
Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125])
	by hub.freebsd.org (Postfix) with ESMTP id CDA0716A4CE
	for <FreeBSD-gnats-submit@freebsd.org>; Wed, 18 Feb 2004 07:10:45 -0800 (PST)
Received: from mail10.svc.cra.dublin.eircom.net (mail10.svc.cra.dublin.eircom.net [159.134.118.26])
	by mx1.FreeBSD.org (Postfix) with SMTP id 59A3643D2D
	for <FreeBSD-gnats-submit@freebsd.org>; Wed, 18 Feb 2004 07:10:45 -0800 (PST)
	(envelope-from cian@hardy.cirt.eircom.net)
Received: (qmail 80354 messnum 9268892 invoked from network[159.134.222.104/unknown]); 18 Feb 2004 15:10:44 -0000
Received: from unknown (HELO hardy.cirt.eircom.net) (159.134.222.104)
  by mail10.svc.cra.dublin.eircom.net (qp 80354) with SMTP; 18 Feb 2004 15:10:44 -0000
Received: (from cian@localhost)
	by hardy.cirt.eircom.net (8.12.10/8.12.9/Submit) id i1IF7TgW079952;
	Wed, 18 Feb 2004 15:07:29 GMT
	(envelope-from cian)
Message-Id: <20040218150729.GA79940@hardy.cirt.eircom.net>
Date: Wed, 18 Feb 2004 15:07:29 +0000
From: Cian Synnott <cian.synnott@eircom.net>
Reply-To: Cian Synnott <cian.synnott@eircom.net>
To: FreeBSD-gnats-submit@freebsd.org
Cc: cirt@eircom.net
Subject: 'utsname' structure field 'nodename' is too short
X-Send-Pr-Version: 3.113

>Number:         63020
>Category:       misc
>Synopsis:       'utsname' structure field 'nodename' is too short
>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:   Wed Feb 18 07:20:14 PST 2004
>Closed-Date:    Sat Apr 24 00:56:23 PDT 2004
>Last-Modified:  Sat Apr 24 00:56:23 PDT 2004
>Originator:     Cian Synnott
>Release:        FreeBSD 4.9-STABLE i386
>Organization:
eircom.net Computer Incident Response Team
>Environment:
System: FreeBSD hardy.cirt.eircom.net 4.9-STABLE FreeBSD 4.9-STABLE #2: Fri Dec 19 14:38:17 GMT 2003 root@hardy.cirt.eircom.net:/usr/obj/usr/src/sys/HARDY i386


>Description:
	The utsname structure defined in the sys/utsname.h has a maximum of
	32 characters on all fields, including the 'nodename' - the network
	name of the machine. This could reasonably be expected by a
	programmer using the uname() call to be MAXHOSTNAMELEN in length.
	However, long hostnames returned from the wrapped sysctl() are
	truncated.
>How-To-Repeat:
	Compile up something like this:

	#include <stdio.h>
	#include <sys/utsname.h>

	int main()
	{
		struct utsname buf;
		uname (&buf);
		printf ("nodename: %s\n", buf.nodename);
		return 0;
	}

	Then set your hostname to, say
          verylongnameindeed.subdomain.domain.tld
        and run the code. Compare output with that of '/usr/bin/uname', which
        directly calls sysctl().

>Fix:
	Have your program use gethostname() rather than uname() to workaround.
	I expect a proper fix would be alter the utsname structure and uname()
	to use proper lengths on structure fields.


>Release-Note:
>Audit-Trail:

From: Valentin Nechayev <netch@ivb.nn.kiev.ua>
To: Cian Synnott <cian.synnott@eircom.net>
Cc: FreeBSD-gnats-submit@freebsd.org, cirt@eircom.net
Subject: Re: misc/63020: 'utsname' structure field 'nodename' is too short
Date: Sat, 27 Mar 2004 20:38:21 +0200

 CS> 	The utsname structure defined in the sys/utsname.h has a maximum of
 CS> 	32 characters on all fields, including the 'nodename' - the network
 CS> 	name of the machine. This could reasonably be expected by a
 CS> 	programmer using the uname() call to be MAXHOSTNAMELEN in length.
 CS> 	However, long hostnames returned from the wrapped sysctl() are
 CS> 	truncated.
 
 5.* fixes this using variable sized utsname. I think 4.* would not
 be fixed because their life is closed to finish.
 
 
 -netch-
State-Changed-From-To: open->closed 
State-Changed-By: kris 
State-Changed-When: Sat Apr 24 00:56:08 PDT 2004 
State-Changed-Why:  
Fixed in 5.x 

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