refactor: network - harden TCP/IP and unify HTTP clients
This commit is contained in:
@@ -1382,7 +1382,8 @@ namespace Ipc {
|
||||
Net::Tcp::Connection* conn = socket->tcpConn;
|
||||
socket->socketLock.Release();
|
||||
if (conn == nullptr) return -1;
|
||||
return Net::Tcp::Send(conn, data, (uint16_t)len);
|
||||
if (len > 0x7FFFFFFFu) return -1;
|
||||
return Net::Tcp::Send(conn, data, len);
|
||||
}
|
||||
|
||||
int SocketRecvHandle(int handle, uint8_t* buffer, uint32_t maxLen) {
|
||||
@@ -1399,13 +1400,15 @@ namespace Ipc {
|
||||
socket->socketLock.Release();
|
||||
if (conn == nullptr) return -1;
|
||||
|
||||
int result = Net::Tcp::ReceiveNonBlocking(conn, buffer, (uint16_t)maxLen);
|
||||
uint16_t cappedLen = maxLen > 0xFFFFu ? 0xFFFFu : (uint16_t)maxLen;
|
||||
int result = Net::Tcp::ReceiveNonBlocking(conn, buffer, cappedLen);
|
||||
if (result != 0) NotifyObjectChanged((Object*)socket);
|
||||
return result;
|
||||
}
|
||||
|
||||
int SocketSendToHandle(int handle, const uint8_t* data, uint32_t len, uint32_t destIp, uint16_t destPort) {
|
||||
if (data == nullptr) return -1;
|
||||
if (len > 1472) return -1;
|
||||
if (len > 0 && !montauk::abi::UserMemory::Range((uint64_t)data, len, false)) return -1;
|
||||
|
||||
Socket* socket = nullptr;
|
||||
|
||||
Reference in New Issue
Block a user