Changeset 8092


Ignore:
Timestamp:
Mar 27, 2009, 1:31:17 AM (13 years ago)
Author:
jhujhiti
Message:

(trunk libT) make IPv6's two IPv4-compatible address formats invalid peer addresses

IPv4 peers should only be seen from an IPv4-connected tracker.

Location:
trunk/libtransmission
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/net.c

    r8091 r8092  
    171171}
    172172
    173 void
    174 tr_normalizeV4Mapped( tr_address * const addr )
    175 {
    176     assert( tr_isAddress( addr ) );
    177 
    178     if( addr->type == TR_AF_INET6 && IN6_IS_ADDR_V4MAPPED( &addr->addr.addr6 ) )
    179     {
    180         addr->type = TR_AF_INET;
    181         memcpy( &addr->addr.addr4.s_addr, addr->addr.addr6.s6_addr + 12, 4 );
    182     }
    183 }
    184 
    185173/*
    186174 * Compare two tr_address structures.
     
    430418
    431419static TR_INLINE tr_bool
     420isIPv4MappedOrCompatAddress( const tr_address * addr )
     421{
     422    if( addr->type == TR_AF_INET6 )
     423    {
     424        if( IN6_IS_ADDR_V4MAPPED( &addr->addr.addr6 ) ||
     425            IN6_IS_ADDR_V4COMPAT( &addr->addr.addr6 ) )
     426            return TRUE;
     427    }
     428    return FALSE;
     429}
     430
     431static TR_INLINE tr_bool
    432432isIPv6LinkLocalAddress( const tr_address * addr )
    433433{
    434434    if( addr->type == TR_AF_INET6 &&
    435             IN6_IS_ADDR_LINKLOCAL( &addr->addr.addr6 ))
     435        IN6_IS_ADDR_LINKLOCAL( &addr->addr.addr6 ) )
    436436        return TRUE;
    437437    return FALSE;
     
    441441tr_isValidPeerAddress( const tr_address * addr, tr_port port )
    442442{
    443     if( isMulticastAddress( addr ) || isIPv6LinkLocalAddress( addr ) )
     443    if( isMulticastAddress( addr ) || isIPv6LinkLocalAddress( addr ) ||
     444        isIPv4MappedOrCompatAddress( addr ) )
    444445        return FALSE;
    445446
     
    462463    assert( tr_isAddress( addr ) );
    463464
    464     if( isMulticastAddress( addr ) || isIPv6LinkLocalAddress( addr ))
     465    if( isMulticastAddress( addr ) || isIPv6LinkLocalAddress( addr ) )
    465466        return -EINVAL;
    466467
  • trunk/libtransmission/net.h

    r8091 r8092  
    8787int tr_compareAddresses( const tr_address * a,
    8888                         const tr_address * b);
    89 void tr_normalizeV4Mapped( tr_address * const addr );
    9089
    9190tr_bool tr_isValidPeerAddress( const tr_address * addr, tr_port port );
  • trunk/libtransmission/peer-mgr.c

    r8091 r8092  
    18311831        const struct peer_atom * atom = getExistingAtom( t, &peer->addr );
    18321832        tr_peer_stat *           stat = ret + i;
    1833         tr_address               norm_addr;
    1834 
    1835         norm_addr = peer->addr;
    1836         tr_normalizeV4Mapped( &norm_addr );
    1837         tr_ntop( &norm_addr, stat->addr, sizeof( stat->addr ) );
     1833
     1834        tr_ntop( &peer->addr, stat->addr, sizeof( stat->addr ) );
    18381835        tr_strlcpy( stat->client, ( peer->client ? peer->client : "" ),
    18391836                   sizeof( stat->client ) );
Note: See TracChangeset for help on using the changeset viewer.