Rev 4738 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 4738 | Rev 4743 | ||
---|---|---|---|
Line 54... | Line 54... | ||
54 | 54 | ||
55 | int tl_get_address_port( const struct sockaddr * addr, int addrlen, uint16_t * port ){ |
55 | int tl_get_address_port( const struct sockaddr * addr, int addrlen, uint16_t * port ){ |
56 | const struct sockaddr_in * address_in; |
56 | const struct sockaddr_in * address_in; |
57 | const struct sockaddr_in6 * address_in6; |
57 | const struct sockaddr_in6 * address_in6; |
58 | 58 | ||
59 | if( addrlen < sizeof( struct sockaddr )) return EINVAL; |
59 | if(( addrlen <= 0 ) || (( size_t ) addrlen < sizeof( struct sockaddr ))) return EINVAL; |
60 | switch( addr->sa_family ){ |
60 | switch( addr->sa_family ){ |
61 | case AF_INET: |
61 | case AF_INET: |
62 | if( addrlen != sizeof( struct sockaddr_in )) return EINVAL; |
62 | if( addrlen != sizeof( struct sockaddr_in )) return EINVAL; |
63 | address_in = ( struct sockaddr_in * ) addr; |
63 | address_in = ( struct sockaddr_in * ) addr; |
64 | * port = ntohs( address_in->sin_port ); |
64 | * port = ntohs( address_in->sin_port ); |