VirtualBox

Changeset 82364 in vbox


Ignore:
Timestamp:
Dec 4, 2019 7:31:09 AM (5 years ago)
Author:
vboxsync
Message:

Dev/E1000: Deal with potential overflow of nTxDFetched if we decide (unlikely) to enlarge TX cache beyond 255 entries in the future.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Devices/Network/DevE1000.cpp

    r82354 r82364  
    39333933    /* We've already loaded pThis->nTxDFetched descriptors past TDH. */
    39343934    unsigned nDescsAvailable    = e1kGetTxLen(pThis) - pThis->nTxDFetched;
     3935    /* The following two lines ensure that pThis->nTxDFetched never overflows. */
     3936    AssertCompile(E1K_TXD_CACHE_SIZE < (256 * sizeof(pThis->nTxDFetched)));
    39353937    unsigned nDescsToFetch      = RT_MIN(nDescsAvailable, E1K_TXD_CACHE_SIZE - pThis->nTxDFetched);
    39363938    unsigned nDescsTotal        = TDLEN / sizeof(E1KTXDESC);
     
    39603962                 TDBAH, TDBAL));
    39613963    }
    3962     pThis->nTxDFetched += nDescsToFetch;
     3964    pThis->nTxDFetched += (uint8_t)nDescsToFetch;
    39633965    return nDescsToFetch;
    39643966}
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette