Changeset 13646


Ignore:
Timestamp:
Dec 11, 2012, 4:08:26 AM (4 years ago)
Author:
jordan
Message:

(trunk, libutp) #5002 'crash in UTP_ProcessIncoming()' -- patch ef69847aaa from upstream

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/third-party/libutp/utp.cpp

    r13620 r13646  
    14881488}
    14891489
     1490enum { MAX_EACK = 128 };
     1491
    14901492void UTPSocket::selective_ack(uint base, const byte *mask, byte len)
    14911493{
     
    15001502        // iterate in reverse over the acked packets, at the end, the top packets
    15011503        // are the ones we want to resend
    1502         int resends[32];
     1504        int resends[MAX_EACK];
    15031505        int nr = 0;
    15041506
     
    15731575                        count >= DUPLICATE_ACKS_BEFORE_RESEND &&
    15741576                        duplicate_ack < DUPLICATE_ACKS_BEFORE_RESEND) {
     1577                        // resends is a stack, and we're mostly interested in the top of it
     1578                        // if we're full, just throw away the lower half
     1579                        if (nr >= MAX_EACK - 2) {
     1580                                memmove(resends, &resends[MAX_EACK/2], MAX_EACK/2 * sizeof(resends[0]));
     1581                                nr -= MAX_EACK / 2;
     1582                        }
    15751583                        resends[nr++] = v;
    15761584                        LOG_UTPV("0x%08x: no ack for %u", this, v);
     
    15811589        } while (--bits >= -1);
    15821590
    1583         if (((base - 1 - fast_resend_seq_nr) & ACK_NR_MASK) < 256 &&
    1584                 count >= DUPLICATE_ACKS_BEFORE_RESEND &&
    1585                 duplicate_ack < DUPLICATE_ACKS_BEFORE_RESEND) {
     1591        if (((base - 1 - fast_resend_seq_nr) & ACK_NR_MASK) <= OUTGOING_BUFFER_MAX_SIZE &&
     1592                count >= DUPLICATE_ACKS_BEFORE_RESEND) {
    15861593                // if we get enough duplicate acks to start
    15871594                // resending, the first packet we should resend
    15881595                // is base-1
    1589                 resends[nr++] = base - 1;
     1596                resends[nr++] = (base - 1) & ACK_NR_MASK;
    15901597        } else {
    15911598                LOG_UTPV("0x%08x: not resending %u count:%d dup_ack:%u fast_resend_seq_nr:%u",
Note: See TracChangeset for help on using the changeset viewer.