source: trunk/third-party/utp-01-ticket-5002.patch

Last change on this file was 14484, checked in by mikedld, 3 years ago

Add patch from #5002 (r13646) to fix crash in libutp for CMake-based builds

File size: 1.8 KB
  • utp.cpp

    diff --git a/utp.cpp b/utp.cpp
    a b  
    14871487        return acked_bytes;
    14881488}
    14891489
     1490enum { MAX_EACK = 128 };
     1491
    14901492void UTPSocket::selective_ack(uint base, const byte *mask, byte len)
    14911493{
    14921494        if (cur_window_packets == 0) return;
     
    14991501        // resends is a stack of sequence numbers we need to resend. Since we
    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
    15051507        LOG_UTPV("0x%08x: Got EACK [%032b] base:%u", this, *(uint32*)mask, base);
     
    15721574                if (((v - fast_resend_seq_nr) & ACK_NR_MASK) <= OUTGOING_BUFFER_MAX_SIZE &&
    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);
    15771585                } else {
     
    15801588                }
    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",
    15921599                                 this, base - 1, count, duplicate_ack, fast_resend_seq_nr);
Note: See TracBrowser for help on using the repository browser.