Changeset 3128


Ignore:
Timestamp:
Sep 22, 2007, 12:36:37 AM (15 years ago)
Author:
charles
Message:

fix logic error in handshake that allowed unencrypted peers even when "ignore unencrypted peers" is checked

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/handshake.c

    r3122 r3128  
    6666    PadD_MAXLEN                    = 512,
    6767    VC_LENGTH                      = 8,
    68     KEY_LEN                        = 96
     68    KEY_LEN                        = 96,
     69    CRYPTO_PROVIDE_PLAINTEXT       = 1,
     70    CRYPTO_PROVIDE_CRYPTO          = 2
    6971};
    7072
     
    107109    unsigned int havePeerID                   : 1;
    108110    unsigned int haveSentBitTorrentHandshake  : 1;
    109     unsigned int shunUnencryptedPeers         : 1;
     111    unsigned int allowUnencryptedPeers        : 1;
    110112    tr_peerIo * io;
    111113    tr_crypto * crypto;
     
    364366        /* crypto_provide */
    365367        crypto_provide = 0;
    366         crypto_provide |= (1<<0); /* encryption */
    367         if( !handshake->shunUnencryptedPeers ) /* plaintext */
    368             crypto_provide |= (1<<1);
    369         assert( 1<=crypto_provide && crypto_provide<=3 );
     368        crypto_provide |= CRYPTO_PROVIDE_CRYPTO; /* always allow crypto */
     369        if( handshake->allowUnencryptedPeers ) /* sometimes allow plaintext */
     370            crypto_provide |= CRYPTO_PROVIDE_PLAINTEXT;
     371        fprintf( stderr, "crypto_provide is %d\n", (int)crypto_provide );
    370372
    371373        crypto_provide = htonl( crypto_provide );
     
    483485
    484486    tr_peerIoSetEncryption( handshake->io,
    485                                     handshake->crypto_select );
     487                            handshake->crypto_select );
    486488
    487489    setState( handshake, AWAITING_HANDSHAKE );
     
    853855     * try a plaintext handshake */
    854856    if(    ( ( handshake->state == AWAITING_YB ) || ( handshake->state == AWAITING_VC ) )
    855         && ( !handshake->shunUnencryptedPeers )
     857        && ( handshake->allowUnencryptedPeers )
    856858        && ( !tr_peerIoReconnect( handshake->io ) ) )
    857859    {
     
    887889    handshake->io = io;
    888890    handshake->crypto = tr_peerIoGetCrypto( io );
    889     handshake->shunUnencryptedPeers = encryption_mode==TR_ENCRYPTION_REQUIRED;
     891    handshake->allowUnencryptedPeers = encryption_mode!=TR_ENCRYPTION_REQUIRED;
    890892    handshake->doneCB = doneCB;
    891893    handshake->doneUserData = doneUserData;
Note: See TracChangeset for help on using the changeset viewer.