Changeset 14542


Ignore:
Timestamp:
Jun 17, 2015, 8:32:33 PM (6 years ago)
Author:
mikedld
Message:

#5456: Fix encrypted communication with libevent 2.1.x

Recent versions of libevent changed the semantics of evbuffer_ptr_set
function in a way that it succeeds if pointer is set right after the end
of the buffer. This caused tr_cryptoEncrypt and tr_cryptoDecrypt to
be called twice for last buffer chunk since no checks for evbuffer_peek
return value were made while it was returning 0 on last loop cycle,
leaving iovec unchanged.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/libtransmission/peer-io.c

    r14526 r14542  
    10611061        evbuffer_ptr_set (buf, &pos, 0, EVBUFFER_PTR_SET);
    10621062        do {
    1063             evbuffer_peek (buf, -1, &pos, &iovec, 1);
     1063            if (evbuffer_peek (buf, -1, &pos, &iovec, 1) != 1)
     1064              break;
    10641065            tr_cryptoEncrypt (&io->crypto, iovec.iov_len, iovec.iov_base, iovec.iov_base);
    10651066        } while (!evbuffer_ptr_set (buf, &pos, iovec.iov_len, EVBUFFER_PTR_ADD));
     
    11481149        evbuffer_ptr_set (outbuf, &pos, old_length, EVBUFFER_PTR_SET);
    11491150        do {
    1150             evbuffer_peek (outbuf, byteCount, &pos, &iovec, 1);
     1151            if (evbuffer_peek (outbuf, byteCount, &pos, &iovec, 1) != 1)
     1152              break;
    11511153            tr_cryptoDecrypt (&io->crypto, iovec.iov_len, iovec.iov_base, iovec.iov_base);
    11521154            byteCount -= iovec.iov_len;
Note: See TracChangeset for help on using the changeset viewer.