Changeset 64585 in vbox
- Timestamp:
- Nov 4, 2016 8:52:10 PM (8 years ago)
- svn:sync-xref-src-repo-rev:
- 111774
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Devices/Network/slirp/tftp.c
r63621 r64585 259 259 int fWithArg = 0; 260 260 int idxOptionArg = 0; 261 261 262 AssertPtrReturn(pTftpSession, VERR_INVALID_PARAMETER); 262 263 AssertPtrReturn(pcTftpIpHeader, VERR_INVALID_PARAMETER); 263 264 AssertReturn(RT_N2H_U16(pcTftpIpHeader->u16TftpOpType) == TFTP_RRQ, VERR_INVALID_PARAMETER); 264 265 LogFlowFunc(("pTftpSession:%p, pcTftpIpHeader:%p\n", pTftpSession, pcTftpIpHeader)); 266 265 267 pszTftpRRQRaw = (char *)&pcTftpIpHeader->Core; 266 268 cbTftpRRQRaw = RT_H2N_U16(pcTftpIpHeader->UdpHdr.uh_ulen) + sizeof(struct ip) - RT_OFFSETOF(TFTPIPHDR, Core); … … 400 402 } 401 403 402 DECLINLINE(int) pftpSessionOpenFile(PNATState pData, PTFTPSESSION pTftpSession, PRTFILE pSessionFile)403 { 404 char aszSessionFileName[TFTP_FILENAME_MAX];405 s ize_t cbSessionFileName;406 int rc = VINF_SUCCESS;404 DECLINLINE(int) pftpSessionOpenFile(PNATState pData, PTFTPSESSION pTftpSession, bool fVerbose, PRTFILE pSessionFile) 405 { 406 char szSessionFilename[TFTP_FILENAME_MAX]; 407 ssize_t cchSessionFilename; 408 int rc; 407 409 LogFlowFuncEnter(); 408 cbSessionFileName = RTStrPrintf(aszSessionFileName, TFTP_FILENAME_MAX, "%s/%s", 409 410 if (c bSessionFileName >= TFTP_FILENAME_MAX)411 { 412 LogF lowFuncLeaveRC(VERR_INTERNAL_ERROR);413 return VERR_INTERNAL_ERROR;414 }415 LogFunc(("aszSessionFileName: %s\n", aszSessionFileName));416 417 if (!RTFileExists(aszSessionFileName))418 {419 LogFlowFuncLeaveRC(VERR_FILE_NOT_FOUND);420 return VERR_FILE_NOT_FOUND;421 }422 423 rc = RTFileOpen(pSessionFile, aszSessionFileName, RTFILE_O_READ | RTFILE_O_OPEN | RTFILE_O_DENY_WRITE);410 411 cchSessionFilename = RTStrPrintf2(szSessionFilename, TFTP_FILENAME_MAX, "%s/%s", tftp_prefix, pTftpSession->pszFilename); 412 if (cchSessionFilename > 0) 413 { 414 LogFunc(("szSessionFilename: %s\n", szSessionFilename)); 415 if (RTFileExists(szSessionFilename)) 416 { 417 rc = RTFileOpen(pSessionFile, szSessionFilename, RTFILE_O_READ | RTFILE_O_OPEN | RTFILE_O_DENY_WRITE); 418 } 419 else 420 rc = VERR_FILE_NOT_FOUND; 421 } 422 else 423 rc = VERR_FILENAME_TOO_LONG; 424 if (fVerbose) 425 LogRel(("NAT TFTP: %s/%s -> %Rrc\n", tftp_prefix, pTftpSession->pszFilename, rc)); 424 426 LogFlowFuncLeaveRC(rc); 425 427 return rc; … … 428 430 DECLINLINE(int) tftpSessionEvaluateOptions(PNATState pData, PTFTPSESSION pTftpSession) 429 431 { 430 int rc = VINF_SUCCESS;432 int rc; 431 433 RTFILE hSessionFile; 432 434 uint64_t cbSessionFile = 0; 433 435 LogFlowFunc(("pTftpSession:%p\n", pTftpSession)); 434 436 435 rc = pftpSessionOpenFile(pData, pTftpSession, &hSessionFile);437 rc = pftpSessionOpenFile(pData, pTftpSession, true /*fVerbose*/, &hSessionFile); 436 438 if (RT_FAILURE(rc)) 437 439 { … … 482 484 return rc; 483 485 } 484 DECLINLINE(int) tftpSendError(PNATState pData, PTFTPSESSION pTftpSession, uint16_t errorcode, const char *msg, PCTFTPIPHDR pcTftpIpHeaderRecv); 486 487 488 DECLINLINE(int) tftpSendError(PNATState pData, PTFTPSESSION pTftpSession, uint16_t errorcode, 489 const char *msg, PCTFTPIPHDR pcTftpIpHeaderRecv); /* gee wiz */ 485 490 486 491 DECLINLINE(int) tftpReadDataBlock(PNATState pData, … … 503 508 504 509 u16BlkSize = (uint16_t)pcTftpSession->OptionBlkSize.u64Value; 505 rc = pftpSessionOpenFile(pData, pcTftpSession, &hSessionFile);510 rc = pftpSessionOpenFile(pData, pcTftpSession, false /*fVerbose*/, &hSessionFile); 506 511 if (RT_FAILURE(rc)) 507 512 { … … 542 547 DECLINLINE(int) tftpAddOptionToOACK(PNATState pData, struct mbuf *pMBuf, const char *pszOptName, uint64_t u64OptValue) 543 548 { 544 char aszOptionBuffer[256];549 char szOptionBuffer[256]; 545 550 size_t iOptLength; 546 551 int rc = VINF_SUCCESS; … … 550 555 AssertPtrReturn(pszOptName, VERR_INVALID_PARAMETER); 551 556 552 RT_ZERO( aszOptionBuffer);553 iOptLength = RTStrPrintf( aszOptionBuffer, 256 , "%s", pszOptName) + 1;554 iOptLength += RTStrPrintf( aszOptionBuffer + iOptLength, 256 - iOptLength , "%llu", u64OptValue) + 1;557 RT_ZERO(szOptionBuffer); 558 iOptLength = RTStrPrintf(szOptionBuffer, 256 , "%s", pszOptName) + 1; 559 iOptLength += RTStrPrintf(szOptionBuffer + iOptLength, 256 - iOptLength , "%llu", u64OptValue) + 1; 555 560 if (iOptLength > M_TRAILINGSPACE(pMBuf)) 556 561 rc = VERR_BUFFER_OVERFLOW; /* buffer too small */ … … 558 563 { 559 564 pMBuf->m_len += (int)iOptLength; 560 m_copyback(pData, pMBuf, cbMBufCurrent, (int)iOptLength, aszOptionBuffer);565 m_copyback(pData, pMBuf, cbMBufCurrent, (int)iOptLength, szOptionBuffer); 561 566 } 562 567 LogFlowFuncLeaveRC(rc); … … 565 570 566 571 DECLINLINE(int) tftpSendOACK(PNATState pData, 567 PTFTPSESSION pTftpSession,568 PCTFTPIPHDR pcTftpIpHeaderRecv)572 PTFTPSESSION pTftpSession, 573 PCTFTPIPHDR pcTftpIpHeaderRecv) 569 574 { 570 575 struct mbuf *m; 571 576 PTFTPIPHDR pTftpIpHeader; 572 int rc = VINF_SUCCESS;577 int rc; 573 578 574 579 rc = tftpSessionEvaluateOptions(pData, pTftpSession);
Note:
See TracChangeset
for help on using the changeset viewer.