NetBSD Problem Report #48063

From www@NetBSD.org  Thu Jul 18 23:10:06 2013
Return-Path: <www@NetBSD.org>
Received: from mail.netbsd.org (mail.netbsd.org [149.20.53.66])
	(using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))
	(Client CN "mail.NetBSD.org", Issuer "Postmaster NetBSD.org" (verified OK))
	by mollari.NetBSD.org (Postfix) with ESMTPS id B91AC71AE1
	for <gnats-bugs@gnats.NetBSD.org>; Thu, 18 Jul 2013 23:10:06 +0000 (UTC)
Message-Id: <20130718231004.05E3771C81@mollari.NetBSD.org>
Date: Thu, 18 Jul 2013 23:10:04 +0000 (UTC)
From: justin@specialbusservice.com
Reply-To: justin@specialbusservice.com
To: gnats-bugs@NetBSD.org
Subject: incorrect definition of socklen_t
X-Send-Pr-Version: www-1.0

>Number:         48063
>Category:       bin
>Synopsis:       incorrect definition of socklen_t
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    bin-bug-people
>State:          open
>Class:          sw-bug
>Submitter-Id:   net
>Arrival-Date:   Thu Jul 18 23:15:00 +0000 2013
>Last-Modified:  Sat Jul 20 10:30:00 +0000 2013
>Originator:     Justin Cormack
>Release:        head
>Organization:
>Environment:
>Description:
the fallback socklen_t definition in tools/compat/compat_defs.h is incorrect, should be unsigned not int (as required by POSIX).


>How-To-Repeat:
build in an environment where socklen_t not defined (!)
>Fix:
This patch fixes it
--- tools/compat/compat_defs.h-orig	2013-07-18 23:58:17.557596850 +0100
+++ tools/compat/compat_defs.h	2013-07-18 23:58:47.881595465 +0100
@@ -168,7 +168,7 @@
 #endif

 #if !HAVE_SOCKLEN_T
-typedef int socklen_t;
+typedef unsigned int socklen_t;
 #endif

 #if !HAVE_U_LONG

>Release-Note:

>Audit-Trail:

Responsible-Changed-From-To: install-manager->bin-bug-people
Responsible-Changed-By: dholland@NetBSD.org
Responsible-Changed-When: Fri, 19 Jul 2013 05:39:32 +0000
Responsible-Changed-Why:
not an installer bug


From: David Holland <dholland-bugs@netbsd.org>
To: gnats-bugs@NetBSD.org
Cc: 
Subject: Re: bin/48063: incorrect definition of socklen_t
Date: Fri, 19 Jul 2013 05:40:34 +0000

 On Thu, Jul 18, 2013 at 11:15:00PM +0000, justin@specialbusservice.com wrote:
  > the fallback socklen_t definition in tools/compat/compat_defs.h is
  > incorrect, should be unsigned not int (as required by POSIX).

 ...required? Since when?

 int is the correct type on nearly all (pre)historic systems from
 before socklen_t became common.

 -- 
 David A. Holland
 dholland@netbsd.org

From: Justin Cormack <justin@specialbusservice.com>
To: gnats-bugs@netbsd.org
Cc: 
Subject: Re: bin/48063: incorrect definition of socklen_t
Date: Fri, 19 Jul 2013 08:50:11 +0100

 http://pubs.opengroup.org/onlinepubs/7908799/xns/syssocket.h.html

 "<sys/socket.h> makes available a type, socklen_t, which is an
 unsigned opaque integral type of length of at least 32 bits"

 However, actually this is a slight red herring as it is defined on my
 system, but the configure script is broken as it is including
 rpc/types.h which is not present, hence the use of the fallback which
 then fails as socklen_t is redefined.

From: "Christos Zoulas" <christos@netbsd.org>
To: gnats-bugs@gnats.NetBSD.org
Cc: 
Subject: PR/48063 CVS commit: src/tools/compat
Date: Fri, 19 Jul 2013 08:00:30 -0400

 Module Name:	src
 Committed By:	christos
 Date:		Fri Jul 19 12:00:30 UTC 2013

 Modified Files:
 	src/tools/compat: compat_defs.h

 Log Message:
 PR/48063: Justin Cormack: incorrect definition of socklen_t


 To generate a diff of this commit:
 cvs rdiff -u -r1.88 -r1.89 src/tools/compat/compat_defs.h

 Please note that diffs are not public domain; they are subject to the
 copyright notices on the relevant files.

From: christos@zoulas.com (Christos Zoulas)
To: gnats-bugs@NetBSD.org, gnats-admin@netbsd.org, netbsd-bugs@netbsd.org, 
	justin@specialbusservice.com
Cc: 
Subject: Re: bin/48063: incorrect definition of socklen_t
Date: Fri, 19 Jul 2013 08:03:49 -0400

 On Jul 19,  5:45am, dholland-bugs@netbsd.org (David Holland) wrote:
 -- Subject: Re: bin/48063: incorrect definition of socklen_t

 |  ...required? Since when?
 |  
 |  int is the correct type on nearly all (pre)historic systems from
 |  before socklen_t became common.

 http://pubs.opengroup.org/onlinepubs/7908799/xns/syssocket.h.html

 christos

From: David Holland <dholland-bugs@netbsd.org>
To: gnats-bugs@NetBSD.org
Cc: Christos Zoulas <christos@netbsd.org>
Subject: Re: bin/48063: incorrect definition of socklen_t
Date: Sat, 20 Jul 2013 06:12:49 +0000

 On Fri, Jul 19, 2013 at 07:55:01AM +0000, Justin Cormack wrote:
  >  http://pubs.opengroup.org/onlinepubs/7908799/xns/syssocket.h.html
  >  
  >  "<sys/socket.h> makes available a type, socklen_t, which is an
  >  unsigned opaque integral type of length of at least 32 bits"

 That's not really relevant.

 socklen_t is the type of the pointer-to-length argument of accept(),
 getsockname(), getpeername(), and getsockopt(). When defining it for
 compat, it needs to match the host system's declarations of these
 functions, or code that calls these functions using socklen_t won't
 compile.

 Before POSIX invented socklen_t, the type was almost universally int.
 The reason socklen_t appeared was that somebody started using size_t
 and this caused problems. I think it was DU on Alpha, because there
 size_t is not the same size as int so it mattered.

 As a result of this, though, everything since then defines socklen_t.
 So when it's really not defined, the proper type to insert is "int".

 (Meanwhile, whether it's signed or not is almost totally irrelevant as
 it's only used for interfacing.)

  >  However, actually this is a slight red herring as it is defined on my
  >  system, but the configure script is broken as it is including
  >  rpc/types.h which is not present, hence the use of the fallback which
  >  then fails as socklen_t is redefined.

 That would be a different bug. Let's fix that instead.

 Christos, please revert...

 -- 
 David A. Holland
 dholland@netbsd.org

From: christos@zoulas.com (Christos Zoulas)
To: David Holland <dholland-bugs@netbsd.org>, gnats-bugs@NetBSD.org
Cc: 
Subject: Re: bin/48063: incorrect definition of socklen_t
Date: Sat, 20 Jul 2013 06:28:15 -0400

 On Jul 20,  6:12am, dholland-bugs@netbsd.org (David Holland) wrote:
 -- Subject: Re: bin/48063: incorrect definition of socklen_t

 | On Fri, Jul 19, 2013 at 07:55:01AM +0000, Justin Cormack wrote:
 |  >  http://pubs.opengroup.org/onlinepubs/7908799/xns/syssocket.h.html
 |  >  
 |  >  "<sys/socket.h> makes available a type, socklen_t, which is an
 |  >  unsigned opaque integral type of length of at least 32 bits"
 | 
 | That's not really relevant.
 | 
 | socklen_t is the type of the pointer-to-length argument of accept(),
 | getsockname(), getpeername(), and getsockopt(). When defining it for
 | compat, it needs to match the host system's declarations of these
 | functions, or code that calls these functions using socklen_t won't
 | compile.
 | 
 | Before POSIX invented socklen_t, the type was almost universally int.
 | The reason socklen_t appeared was that somebody started using size_t
 | and this caused problems. I think it was DU on Alpha, because there
 | size_t is not the same size as int so it mattered.
 | 
 | As a result of this, though, everything since then defines socklen_t.
 | So when it's really not defined, the proper type to insert is "int".
 | 
 | (Meanwhile, whether it's signed or not is almost totally irrelevant as
 | it's only used for interfacing.)
 | 
 |  >  However, actually this is a slight red herring as it is defined on my
 |  >  system, but the configure script is broken as it is including
 |  >  rpc/types.h which is not present, hence the use of the fallback which
 |  >  then fails as socklen_t is redefined.
 | 
 | That would be a different bug. Let's fix that instead.
 | 
 | Christos, please revert...

 Ok, I've ran into the rpc/types.h lossage before too (with amd). I agree,
 let's fix that instead.

 christos

>Unformatted:

NetBSD Home
NetBSD PR Database Search

(Contact us) $NetBSD: query-full-pr,v 1.39 2013/11/01 18:47:49 spz Exp $
$NetBSD: gnats_config.sh,v 1.8 2006/05/07 09:23:38 tsutsui Exp $
Copyright © 1994-2007 The NetBSD Foundation, Inc. ALL RIGHTS RESERVED.