cvs commit: src/include unistd.h

Marcel Moolenaar marcel at xcllnt.net
Tue Aug 19 15:02:50 PDT 2003


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 at 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 at xcllnt.net


More information about the cvs-src mailing list