Index: src/OFTCPSocket+SOCKS5.m ================================================================== --- src/OFTCPSocket+SOCKS5.m +++ src/OFTCPSocket+SOCKS5.m @@ -28,24 +28,22 @@ /* Reference for static linking */ int _OFTCPSocket_SOCKS5_reference; static void -send_or_exception(OFTCPSocket *self, int socket, char *buffer, size_t length) +send_or_exception(OFTCPSocket *self, of_socket_t socket, char *buffer, + int length) { - if (length > SSIZE_MAX) - @throw [OFOutOfRangeException exception]; - - if (send(socket, buffer, length, 0) != (ssize_t)length) + if (send(socket, buffer, length, 0) != length) @throw [OFWriteFailedException exceptionWithObject: self requestedLength: length errNo: of_socket_errno()]; } static void -recv_exact(OFTCPSocket *self, int socket, char *buffer, size_t length) +recv_exact(OFTCPSocket *self, of_socket_t socket, char *buffer, int length) { while (length > 0) { ssize_t ret = recv(socket, buffer, length, 0); if (ret < 0) @@ -98,12 +96,15 @@ request[0] = port >> 8; request[1] = port & 0xFF; [connectRequest addItems: request count: 2]; + if ([connectRequest count] > INT_MAX) + @throw [OFOutOfRangeException exception]; + send_or_exception(self, _socket, - [connectRequest items], [connectRequest count]); + [connectRequest items], (int)[connectRequest count]); objc_autoreleasePoolPop(pool); recv_exact(self, _socket, reply, 4);