Changeset 76782 in vbox for trunk/src/VBox/Devices/Network/slirp
- Timestamp:
- Jan 11, 2019 4:36:34 PM (6 years ago)
- svn:sync-xref-src-repo-rev:
- 128112
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Network/slirp/tftp.c
r76775 r76782 274 274 while (cbTftpRRQRaw) 275 275 { 276 idxTftpRRQRaw = RTStrNLen(pszTftpRRQRaw, 512 - idxTftpRRQRaw) + 1; 276 rc = RTStrNLenEx(pszTftpRRQRaw, cbTftpRRQRaw, &idxTftpRRQRaw); 277 if (RT_SUCCESS(rc)) 278 ++idxTftpRRQRaw; /* count the NUL too */ 279 else 280 break; 281 277 282 if (RTStrNLen((char *)pTftpSession->pszFilename, TFTP_FILENAME_MAX) == 0) 278 283 { … … 300 305 { 301 306 if (!RTStrICmp("blksize", g_TftpDesc[idxOptionArg].pszName)) 302 {303 307 rc = tftpSessionParseAndMarkOption(pszTftpRRQRaw, &pTftpSession->OptionBlkSize); 304 if (pTftpSession->OptionBlkSize.u64Value > UINT16_MAX)305 rc = VERR_INVALID_PARAMETER;306 }307 308 308 309 if ( RT_SUCCESS(rc) … … 455 456 } 456 457 458 int cOptions = 0; 459 457 460 if (pTftpSession->OptionTSize.fRequested) 458 461 { 459 462 pTftpSession->OptionTSize.u64Value = cbSessionFile; 460 } 461 if ( !pTftpSession->OptionBlkSize.u64Value 462 && !pTftpSession->OptionBlkSize.fRequested) 463 { 464 pTftpSession->OptionBlkSize.u64Value = 1428; 465 } 463 ++cOptions; 464 } 465 466 if (pTftpSession->OptionBlkSize.fRequested) 467 { 468 if (pTftpSession->OptionBlkSize.u64Value < 8) 469 { 470 /* 471 * we cannot make a counter-offer larger than the client's 472 * value, so just pretend we didn't recognize it and use 473 * default block size 474 */ 475 pTftpSession->OptionBlkSize.fRequested = 0; 476 pTftpSession->OptionBlkSize.u64Value = 512; 477 } 478 else if (pTftpSession->OptionBlkSize.u64Value > 1428) 479 { 480 pTftpSession->OptionBlkSize.u64Value = 1428; 481 ++cOptions; 482 } 483 } 484 else 485 { 486 pTftpSession->OptionBlkSize.u64Value = 512; 487 } 488 489 rc = cOptions > 0 ? VINF_SUCCESS : VWRN_NOT_FOUND; 466 490 LogFlowFuncLeaveRC(rc); 467 491 return rc; … … 506 530 AssertPtrReturn(pu8Data, VERR_INVALID_PARAMETER); 507 531 AssertPtrReturn(pcbReadData, VERR_INVALID_PARAMETER); 508 AssertReturn(pcTftpSession->OptionBlkSize.u64Value < UINT16_MAX, VERR_INVALID_PARAMETER);509 532 LogFlowFunc(("pcTftpSession:%p, pu8Data:%p, pcbReadData:%p\n", 510 533 pcTftpSession, … … 602 625 603 626 if (pTftpSession->OptionBlkSize.fRequested) 604 { 605 if (pTftpSession->OptionBlkSize.u64Value > UINT16_MAX) 606 rc = VERR_INVALID_PARAMETER; 607 else 608 rc = tftpAddOptionToOACK(pData, m, "blksize", pTftpSession->OptionBlkSize.u64Value); 609 } 627 rc = tftpAddOptionToOACK(pData, m, "blksize", pTftpSession->OptionBlkSize.u64Value); 628 610 629 if ( RT_SUCCESS(rc) 611 630 && pTftpSession->OptionTSize.fRequested) … … 683 702 pTftpIpHeader->Core.u16TftpOpCode = RT_H2N_U16(pTftpSession->cTftpAck); 684 703 685 rc = tftpReadDataBlock(pData, pTftpSession, (uint8_t *)&pTftpIpHeader->Core.u16TftpOpCode + sizeof(uint16_t), &cbRead); 704 if (RT_LIKELY(M_TRAILINGSPACE(m) >= pTftpSession->OptionBlkSize.u64Value)) 705 { 706 uint8_t *pu8Data = (uint8_t *)&pTftpIpHeader->Core.u16TftpOpCode + sizeof(uint16_t); 707 rc = tftpReadDataBlock(pData, pTftpSession, pu8Data, &cbRead); 708 } 709 else 710 rc = VERR_BUFFER_OVERFLOW; 686 711 687 712 if (RT_SUCCESS(rc))
Note:
See TracChangeset
for help on using the changeset viewer.