Changeset 90196 in vbox for trunk/include
- Timestamp:
- Jul 14, 2021 8:00:10 PM (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/VBox/vmm/pdmnetinline.h
r90175 r90196 144 144 { /* likely */ } else return false; 145 145 if (RT_LIKELY( cbFrame - pGso->cbHdrsTotal >= pGso->cbMaxSeg )) 146 { /* likely */ } else return false; 147 148 /* Make sure the segment size is enough to fit a UDP header. */ 149 if (RT_LIKELY(enmType != PDMNETWORKGSOTYPE_IPV4_UDP || pGso->cbMaxSeg >= RTNETUDP_MIN_LEN)) 146 150 { /* likely */ } else return false; 147 151 … … 450 454 case PDMNETWORKGSOTYPE_IPV4_UDP: 451 455 if (iSeg == 0) 456 { 457 /* uh_ulen shall not exceed cbFrame - pGso->offHdr2 (offset of UDP header) */ 458 PRTNETUDP pUdpHdr = (PRTNETUDP)&pbFrame[pGso->offHdr2]; 459 Assert(pGso->offHdr2 + RT_UOFFSET_AFTER(RTNETUDP, uh_ulen) <= cbFrame); 460 if ((unsigned)(pGso->offHdr2 + RT_BE2H_U16(pUdpHdr->uh_ulen)) > cbFrame) 461 { 462 size_t cbUdp = cbFrame - pGso->offHdr2; 463 if (cbUdp >= UINT16_MAX) 464 pUdpHdr->uh_ulen = UINT16_MAX; 465 else 466 pUdpHdr->uh_ulen = RT_H2BE_U16((uint16_t)cbUdp); 467 } 468 /* uh_ulen shall be at least the size of UDP header */ 469 if (RT_BE2H_U16(pUdpHdr->uh_ulen) < sizeof(RTNETUDP)) 470 pUdpHdr->uh_ulen = RT_H2BE_U16(sizeof(RTNETUDP)); 452 471 pdmNetGsoUpdateUdpHdrUfo(RTNetIPv4PseudoChecksum((PRTNETIPV4)&pbFrame[pGso->offHdr1]), 453 472 pbSegHdrs, pbFrame, pGso->offHdr2); 473 } 454 474 pdmNetGsoUpdateIPv4HdrUfo(pbSegHdrs, pGso->offHdr1, cbSegPayload, iSeg * pGso->cbMaxSeg, 455 475 pdmNetSegHdrLen(pGso, iSeg), iSeg + 1 == cSegs); … … 560 580 pUdpHdr->uh_ulen = RT_H2BE_U16((uint16_t)cbUdp); 561 581 } 582 /* uh_ulen shall be at least the size of UDP header */ 583 if (RT_BE2H_U16(pUdpHdr->uh_ulen) < sizeof(RTNETUDP)) 584 pUdpHdr->uh_ulen = RT_H2BE_U16(sizeof(RTNETUDP)); 562 585 pdmNetGsoUpdateUdpHdrUfo(RTNetIPv4PseudoChecksum((PRTNETIPV4)&pbFrame[pGso->offHdr1]), 563 586 pbSegHdrs, pbFrame, pGso->offHdr2);
Note:
See TracChangeset
for help on using the changeset viewer.