Changeset 2340 for zzuf/trunk


Ignore:
Timestamp:
May 19, 2008, 1:24:41 PM (12 years ago)
Author:
Sam Hocevar
Message:
  • Fix an invalid cast on the Alpha architecture caused by sockaddr_in* having larger alignment requirements than sockaddr*.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • zzuf/trunk/src/lib-fd.c

    r2326 r2340  
    262262        if(ret >= 0) \
    263263        { \
    264             const struct sockaddr_in* in = (const struct sockaddr_in *)addr; \
     264            struct sockaddr_in in; \
    265265            long int port; \
    266266            switch(addr->sa_family) \
     
    268268            case AF_INET: \
    269269            case_AF_INET6 \
    270                 port = ntohs(in->sin_port); \
     270                /* We need to copy rather than cast sockaddr* to sockaddr_in* \
     271                 * because sockaddr_in* has actually _larger_ alignment on \
     272                 * eg. Linux alpha. And we only need sin_port so we only copy \
     273                 * this member. */ \
     274                memcpy(&in.sin_port, \
     275                   (char const *)addr + ((char *)&in.sin_port - (char *)&in), \
     276                   sizeof(in.sin_port)); \
     277                port = ntohs(in.sin_port); \
    271278                if(_zz_portwatched(port)) \
    272279                    break; \
Note: See TracChangeset for help on using the changeset viewer.