Changeset 82813 in vbox for trunk/src/VBox
- Timestamp:
- Jan 21, 2020 5:48:19 PM (5 years ago)
- Location:
- trunk/src/VBox/Runtime
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/generic/ftp-server.cpp
r82781 r82813 364 364 " UTF8" 365 365 366 /** Maximum length in characters a FTP server path can have (excluding termination). */ 367 #define RTFTPSERVER_MAX_PATH RTPATH_MAX 368 366 369 367 370 /********************************************************************************************************************************* … … 461 464 RTStrFree(psz); 462 465 466 return rc; 467 } 468 469 /** 470 * Sets the current working directory for a client. 471 * 472 * @returns VBox status code. 473 * @param pClient Client to set current working directory for. 474 * @param pcszPath Working directory to set. 475 */ 476 static int rtFtpSetCWD(PRTFTPSERVERCLIENT pClient, const char *pcszPath) 477 { 478 RTStrFree(pClient->State.pszCWD); 479 480 pClient->State.pszCWD = RTStrDup(pcszPath); 481 482 LogFlowFunc(("Current CWD is now '%s'\n", pClient->State.pszCWD)); 483 484 int rc = pClient->State.pszCWD ? VINF_SUCCESS : VERR_NO_MEMORY; 485 AssertRC(rc); 463 486 return rc; 464 487 } … … 1038 1061 1039 1062 if (RT_SUCCESS(rc)) 1063 { 1064 const size_t cbPath = sizeof(char) * RTFTPSERVER_MAX_PATH; 1065 char *pszPath = RTStrAlloc(cbPath); 1066 if (pszPath) 1067 { 1068 RTFTPSERVER_HANDLE_CALLBACK_VA(pfnOnPathGetCurrent, pszPath, cbPath); 1069 1070 if (RT_SUCCESS(rc)) 1071 rtFtpSetCWD(pClient, pszPath); 1072 1073 RTStrFree(pszPath); 1074 } 1075 else 1076 rc = VERR_NO_MEMORY; 1077 1040 1078 return rtFtpServerSendReplyRc(pClient, RTFTPSERVER_REPLY_OKAY); 1079 } 1041 1080 1042 1081 return rc; … … 1050 1089 int rc; 1051 1090 1052 RTFTPSERVER_HANDLE_CALLBACK_VA(pfnOnPathSetCurrent, apcszArgs[0]); 1053 1054 if (RT_SUCCESS(rc)) 1091 const char *pcszPath = apcszArgs[0]; 1092 1093 RTFTPSERVER_HANDLE_CALLBACK_VA(pfnOnPathSetCurrent, pcszPath); 1094 1095 if (RT_SUCCESS(rc)) 1096 { 1097 rtFtpSetCWD(pClient, pcszPath); 1098 1055 1099 return rtFtpServerSendReplyRc(pClient, RTFTPSERVER_REPLY_OKAY); 1100 } 1056 1101 1057 1102 return rc; … … 1711 1756 pState->pszUser = NULL; 1712 1757 1758 RTStrFree(pState->pszCWD); 1759 pState->pszCWD = NULL; 1760 1713 1761 pState->cFailedLoginAttempts = 0; 1714 1762 pState->tsLastCmdMs = RTTimeMilliTS(); -
trunk/src/VBox/Runtime/tools/RTFTPServer.cpp
r82772 r82813 256 256 Assert(pData->cbUser == sizeof(FTPSERVERDATA)); 257 257 258 const char *pcszStat = pcszPath ? pcszPath : pThis->szCWD; 259 260 RTPrintf("Stat for '%s'\n", pcszStat); 261 258 262 RTFILE hFile; 259 int rc = RTFileOpen(&hFile, pcsz Path ? pcszPath : pThis->szCWD,263 int rc = RTFileOpen(&hFile, pcszStat, 260 264 RTFILE_O_READ | RTFILE_O_OPEN | RTFILE_O_DENY_WRITE); 261 265 if (RT_SUCCESS(rc)) … … 294 298 RTPrintf("Current directory is: '%s'\n", pThis->szCWD); 295 299 296 RTStrPrintf(pszPWD, cbPWD, "%s", pThis->szCWD); 297 298 return VINF_SUCCESS; 300 return RTStrCopy(pszPWD, cbPWD, pThis->szCWD); 299 301 } 300 302
Note:
See TracChangeset
for help on using the changeset viewer.