Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 19 Aug 2003 15:02:48 -0700
From:      Marcel Moolenaar <marcel@xcllnt.net>
To:        Garrett Wollman <wollman@khavrinen.lcs.mit.edu>
Cc:        cvs-all@FreeBSD.org
Subject:   Re: cvs commit: src/include unistd.h
Message-ID:  <20030819220248.GA91232@athlon.pn.xcllnt.net>
In-Reply-To: <200308192132.h7JLWnZk035752@khavrinen.lcs.mit.edu>
References:  <200308192039.h7JKdni9081097@repoman.freebsd.org> <20030819210421.GA28597@athlon.pn.xcllnt.net> <200308192132.h7JLWnZk035752@khavrinen.lcs.mit.edu>

next in thread | previous in thread | raw e-mail | index | archive | help
On Tue, Aug 19, 2003 at 05:32:49PM -0400, Garrett Wollman wrote:
> <<On Tue, 19 Aug 2003 14:04:21 -0700, Marcel Moolenaar <marcel@xcllnt.net> said:
> 
> > Changing the type of the namelen argument from int to size_t in
> > at least the implementation of the function breaks the ABI on
> > 64-bit platforms. The problem is that sign-extension is moved
> > from the callee to the caller and previously compiled code will
> > not have said sign-extension.
> 
> Hmmm.  I hadn't thought of that, but you're absolutely right.
> Suggestions as to the best way to deal?  (I want the type to be
> correct going forward.)

If we care about it (we may not, because I don't think it
imposes a security problem) we could force the sign-extension
in gethostname() by assigning namelen before we do anything
else. Something like:

int
gethostname(name, namelen)
        char *name;
        size_t namelen;
{
        int mib[2];
        size_t size;

	/*
	 * Preserve behaviour for when namelen was an int.
	 * This avoids ABI breakages.
	 */
	namelen = (int)namelen;

	:
	:
}

I think that should do it.

-- 
 Marcel Moolenaar	  USPA: A-39004		 marcel@xcllnt.net



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