Structure alignment

Jouni Malinen jkmaline at cc.hut.fi
Sat Jun 4 12:53:18 EDT 2005


On Wed, Jun 01, 2005 at 06:02:36AM +0000, ?????? wrote:

> In wpa.h (0.4.1 release)
> 
> I have seen the following line
> 
> struct ieee802_1x_eapol_key {
>     u8 type;
>     u16 key_length;
>     ...
> }

Note that this last line is not actually complete. The correct line
would be: } __attribute__ ((packed));

> which in not 16bit aligned. If wpa_supplicant is built with visual c++ 6.0, It will cause problem

It looks like gcc is able to handle that unaligned access internally
since the structure is packed. Anyway, I would agree with changing this
to be explicitly done with u8 key_length[2] (and similarly, in struct
wpa_eapol_key).

Does Visual C++ allow structs to be packed? What kind of problems do you
see with it? The structure size is incorrect due to extra padding before
key_length? Unaligned read/write? Something else?

-- 
Jouni Malinen                                            PGP id EFC895FA



More information about the HostAP mailing list