mirror of
https://github.com/yuanyuanxiang/SimpleRemoter.git
synced 2026-01-22 07:14:15 +08:00
Revert #242 and improve security when sending files to client
This commit is contained in:
@@ -593,35 +593,45 @@ BOOL IOCPClient::SendWithSplit(const char* src, ULONG srcSize, ULONG ulSplitLeng
|
||||
|
||||
// 依次发送
|
||||
for (i = ulLength; i >= (int)actualSplitLength; i -= actualSplitLength) {
|
||||
int j = 0;
|
||||
for (; j < ulSendRetry; ++j) {
|
||||
iReturn = SendTo(Travel, actualSplitLength, 0);
|
||||
if (iReturn > 0) {
|
||||
int remaining = actualSplitLength;
|
||||
while (remaining > 0) {
|
||||
int j = 0;
|
||||
for (; j < ulSendRetry; ++j) {
|
||||
iReturn = SendTo(Travel, remaining, 0);
|
||||
if (iReturn > 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (j == ulSendRetry) {
|
||||
isFail = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (j == ulSendRetry) {
|
||||
isFail = true;
|
||||
break;
|
||||
}
|
||||
|
||||
ulSended += iReturn;
|
||||
Travel += actualSplitLength;
|
||||
ulSended += iReturn;
|
||||
Travel += iReturn;
|
||||
remaining -= iReturn;
|
||||
}
|
||||
if (isFail) break;
|
||||
}
|
||||
// 发送最后的部分
|
||||
if (!isFail && i>0) { //1024
|
||||
int j = 0;
|
||||
for (; j < ulSendRetry; j++) {
|
||||
iReturn = SendTo((char*)Travel,i,0);
|
||||
|
||||
if (iReturn > 0) {
|
||||
int remaining = i;
|
||||
while (remaining > 0) {
|
||||
int j = 0;
|
||||
for (; j < ulSendRetry; j++) {
|
||||
iReturn = SendTo((char*)Travel, remaining, 0);
|
||||
if (iReturn > 0) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (j == ulSendRetry) {
|
||||
isFail = true;
|
||||
break;
|
||||
}
|
||||
ulSended += iReturn;
|
||||
Travel += iReturn;
|
||||
remaining -= iReturn;
|
||||
}
|
||||
if (j == ulSendRetry) {
|
||||
isFail = true;
|
||||
}
|
||||
ulSended += iReturn;
|
||||
}
|
||||
if (szBuffer != src)
|
||||
SAFE_DELETE_ARRAY(szBuffer);
|
||||
|
||||
@@ -418,13 +418,13 @@ void RunFileReceiver(CScreenManager *mgr, const std::string &folder, const std::
|
||||
if (pClient->ConnectServer(mgr->m_ClientObject->ServerIP().c_str(), mgr->m_ClientObject->ServerPort())) {
|
||||
pClient->setManagerCallBack(mgr, CManager::DataProcess, CManager::ReconnectProcess);
|
||||
// 发送目录并准备接收文件
|
||||
int len = 1 + folder.length() + files.length() + 2;
|
||||
int len = 1 + folder.length() + files.length() + 1;
|
||||
char* cmd = new char[len];
|
||||
cmd[0] = COMMAND_GET_FILE;
|
||||
memcpy(cmd + 1, folder.c_str(), folder.length());
|
||||
cmd[1 + folder.length()] = 0;
|
||||
memcpy(cmd + 1 + folder.length() + 1, files.data(), files.length());
|
||||
cmd[1 + folder.length() + files.length() + 1] = 0;
|
||||
cmd[1 + folder.length() + files.length()] = 0;
|
||||
pClient->Send2Server(cmd, len);
|
||||
SAFE_DELETE_ARRAY(cmd);
|
||||
pClient->RunEventLoop(TRUE);
|
||||
|
||||
Reference in New Issue
Block a user