ObjFW  Check-in [c5e3f0094c]

Overview
Comment:OFTCPSocket+SOCKS5.m: Small type fixes
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: c5e3f0094c1233e30bd45f9f16d6ab709cb72b5689279bb5c0f3d4139a95d902
User & Date: js on 2016-05-28 15:26:28
Other Links: manifest | tags
Context
2016-05-28
19:42
OFStream: Free the right variable check-in: 28fe0a104d user: js tags: trunk
15:26
OFTCPSocket+SOCKS5.m: Small type fixes check-in: c5e3f0094c user: js tags: trunk
14:56
OFKernelEventObserver_select: Cast to of_socket_t check-in: e74fc30f5b user: js tags: trunk
Changes

Modified src/OFTCPSocket+SOCKS5.m from [5b08ee4ef4] to [785ede0c63].

26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53

#import "socket_helpers.h"

/* Reference for static linking */
int _OFTCPSocket_SOCKS5_reference;

static void
send_or_exception(OFTCPSocket *self, int socket, char *buffer, size_t length)
{
	if (length > SSIZE_MAX)
		@throw [OFOutOfRangeException exception];

	if (send(socket, buffer, length, 0) != (ssize_t)length)
		@throw [OFWriteFailedException
		    exceptionWithObject: self
			requestedLength: length
				  errNo: of_socket_errno()];
}

static void
recv_exact(OFTCPSocket *self, int socket, char *buffer, size_t length)
{
	while (length > 0) {
		ssize_t ret = recv(socket, buffer, length, 0);

		if (ret < 0)
			@throw [OFReadFailedException
			    exceptionWithObject: self







|
<
|
<
|
|







|







26
27
28
29
30
31
32
33

34

35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51

#import "socket_helpers.h"

/* Reference for static linking */
int _OFTCPSocket_SOCKS5_reference;

static void
send_or_exception(OFTCPSocket *self, of_socket_t socket, char *buffer,

    int length)

{
	if (send(socket, buffer, length, 0) != length)
		@throw [OFWriteFailedException
		    exceptionWithObject: self
			requestedLength: length
				  errNo: of_socket_errno()];
}

static void
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)
			@throw [OFReadFailedException
			    exceptionWithObject: self
96
97
98
99
100
101
102



103
104
105
106
107
108
109
110
111
			   count: request[0]];

	request[0] = port >> 8;
	request[1] = port & 0xFF;
	[connectRequest addItems: request
			   count: 2];




	send_or_exception(self, _socket,
	    [connectRequest items], [connectRequest count]);

	objc_autoreleasePoolPop(pool);

	recv_exact(self, _socket, reply, 4);

	if (reply[0] != 5 || reply[1] != 0 || reply[2] != 0) {
		[self close];







>
>
>

|







94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
			   count: request[0]];

	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], (int)[connectRequest count]);

	objc_autoreleasePoolPop(pool);

	recv_exact(self, _socket, reply, 4);

	if (reply[0] != 5 || reply[1] != 0 || reply[2] != 0) {
		[self close];