Subject: Re: sparc hp->h_addr_list alignment problems
To: Matthias Scheler <tron@lyssa.owl.de>
From: David Brownlee <abs@anim.dreamworks.com>
List: tech-net
Date: 07/19/1999 09:50:06
On Mon, 19 Jul 1999, Matthias Scheler wrote:

> On Mon, Jul 19, 1999 at 12:00:55AM -0700, David Brownlee wrote:
> > Its not ELF related. After the IPv6 integration it appears that
> > hp->h_addr_list is no longer suitably aligned for 32bit
> 
> From "/usr/include/netdb.h":
> 
> struct  hostent {
> [...]
>         char    **h_addr_list;  /* list of addresses from name server */
> [...]
> };
> 
> I'm pretty sure that it is aligned on a byte address. If you assume
> any futher alignment of a "char *" pointer your code is incorrect.
> Here is a correct piece of code taken from "src/usr.bin/ftp/fetch.c":
> 
	The assumption may be incorrect, but its present in the in tree
	copies of at least rarpd and sendmail. In -current on sparc
	sendmail will immediately Bus error if it extracts the hostname
	from /etc/hosts.

> 	hp = gethostbyname(host);
> 	if (hp == NULL) {
> 		warnx("%s: %s", host, hstrerror(h_errno));
> 		goto cleanup_fetch_url;
> 	}
> 	if (hp->h_addrtype != AF_INET) {
> 		warnx("`%s': not an Internet address?", host);
> 		goto cleanup_fetch_url;
> 	}
> 	memcpy(&sin.sin_addr, hp->h_addr, hp->h_length);
> 
	I have (less than totally elegant) patches for rarpd to do the
	right thing. I'll see if I can clean them up a little.

	Could I persuade you to look at sendmail? :)

	Thanks

		David/absolute

         -=- They took away my irony, but they left my deceit  -=-