Subject: Re: The ifconfig(8) unaligned access bug
To: Ross Harvey <ross@teraflop.com>
From: Jason Thorpe <thorpej@nas.nasa.gov>
List: port-alpha
Date: 05/01/1997 18:16:35
On Wed, 30 Apr 1997 19:06:49 -0700 (PDT) 
 Ross Harvey <ross@teraflop.com> wrote:

 > I can answer (2) but not (1). Addreq _is_ aligned properly. Its alignment
 > requirement will depend on the maximum alignment of any field in it.
 > Well, they are all chars or u_char fields.

...thanks for pointing this out... I didn't even think about that.. :-)

 > There is a bug, but it is in the struct sockaddr definition itself!
 > With 20-20 hindsight we could travel back in time and make sure all
 > the typecasting that the sockaddr gets hammered with goes in the direction
 > of strict alignment to loose alignment.

Well, unfortunately, we don't have a time machine.  However, we do
have gcc and <sys/cdefs.h>.  So, I've corrected the problem by
explicitly directing the compile to align the beginning of a
struct sockaddr to sizeof(long).  All is now well with ifconfig(8).

The fix will appear in tomorrow's SUP.

Ciao.

Jason R. Thorpe                                       thorpej@nas.nasa.gov
NASA Ames Research Center                               Home: 408.866.1912
NAS: M/S 258-6                                          Work: 415.604.0935
Moffett Field, CA 94035                                Pager: 415.428.6939