ObjFW  Check-in [dbb71903e0]

Overview
Comment:Minor style fix
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: dbb71903e0e4e3fa6adbf2de6285b6b7f8a3f411407d546f0869683dab8ce4f1
User & Date: js on 2017-10-22 17:05:21
Other Links: manifest | tags
Context
2017-10-22
18:31
OFMethodSignature: Correctly handle Darwin/PPC ABI check-in: f641fc7faa user: js tags: trunk
17:05
Minor style fix check-in: dbb71903e0 user: js tags: trunk
15:05
Make Apple GCC with -Wshadow happy check-in: a06354b42a user: js tags: trunk
Changes

Modified src/OFTCPSocket+SOCKS5.m from [7ec0dff4e0] to [8ea4b1f704].

28
29
30
31
32
33
34
35

36
37
38
39
40
41
42
43
28
29
30
31
32
33
34

35

36
37
38
39
40
41
42







-
+
-








#import "socket_helpers.h"

/* Reference for static linking */
int _OFTCPSocket_SOCKS5_reference;

static void
send_or_exception(OFTCPSocket *self, of_socket_t sock, char *buffer,
sendOrThrow(OFTCPSocket *self, of_socket_t sock, char *buffer, int length)
    int length)
{
#ifndef OF_WINDOWS
	ssize_t bytesWritten;
#else
	int bytesWritten;
#endif

52
53
54
55
56
57
58
59

60
61
62
63
64
65
66
51
52
53
54
55
56
57

58
59
60
61
62
63
64
65







-
+







		@throw [OFWriteFailedException exceptionWithObject: self
						   requestedLength: length
						      bytesWritten: bytesWritten
							     errNo: 0];
}

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

		if (ret < 0)
			@throw [OFReadFailedException
			    exceptionWithObject: self
81
82
83
84
85
86
87
88

89
90

91
92
93
94
95
96
97
80
81
82
83
84
85
86

87
88

89
90
91
92
93
94
95
96







-
+

-
+







	void *pool;
	OFMutableData *connectRequest;

	if ([host UTF8StringLength] > 255)
		@throw [OFOutOfRangeException exception];

	/* 5 1 0 -> no authentication */
	send_or_exception(self, _socket, request, 3);
	sendOrThrow(self, _socket, request, 3);

	recv_exact(self, _socket, reply, 2);
	recvExact(self, _socket, reply, 2);

	if (reply[0] != 5 || reply[1] != 0) {
		[self close];
		@throw [OFConnectionFailedException
		    exceptionWithHost: host
				 port: port
			       socket: self
114
115
116
117
118
119
120
121

122
123
124
125
126

127
128
129
130
131
132
133
113
114
115
116
117
118
119

120
121
122
123
124

125
126
127
128
129
130
131
132







-
+




-
+







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

	if ([connectRequest count] > INT_MAX)
		@throw [OFOutOfRangeException exception];

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

	objc_autoreleasePoolPop(pool);

	recv_exact(self, _socket, reply, 4);
	recvExact(self, _socket, reply, 4);

	if (reply[0] != 5 || reply[2] != 0) {
		[self close];
		@throw [OFConnectionFailedException
		    exceptionWithHost: host
				 port: port
			       socket: self
171
172
173
174
175
176
177
178

179
180
181
182


183
184
185

186
187
188
189
190
191
192
193
194
195
196

197
198
170
171
172
173
174
175
176

177
178
179


180
181
182
183

184
185
186
187
188
189
190
191
192
193
194

195
196
197







-
+


-
-
+
+


-
+










-
+


							       socket: self
								errNo: errNo];
	}

	/* Skip the rest of the reply */
	switch (reply[3]) {
	case 1: /* IPv4 */
		recv_exact(self, _socket, reply, 4);
		recvExact(self, _socket, reply, 4);
		break;
	case 3: /* Domain name */
		recv_exact(self, _socket, reply, 1);
		recv_exact(self, _socket, reply, reply[0]);
		recvExact(self, _socket, reply, 1);
		recvExact(self, _socket, reply, reply[0]);
		break;
	case 4: /* IPv6 */
		recv_exact(self, _socket, reply, 16);
		recvExact(self, _socket, reply, 16);
		break;
	default:
		[self close];
		@throw [OFConnectionFailedException
		    exceptionWithHost: host
				 port: port
			       socket: self
				errNo: EPROTONOSUPPORT];
	}

	recv_exact(self, _socket, reply, 2);
	recvExact(self, _socket, reply, 2);
}
@end