ObjFW  Check-in [11a9f98b7a]

Overview
Comment:Fix lookup of service when getaddrinfo is unavailable.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA3-256: 11a9f98b7a7db13477c11b1765fab3f0bbc538a9cf377a9cda3bb40e67cbba71
User & Date: js on 2011-02-01 21:07:49
Other Links: manifest | tags
Context
2011-02-01
21:24
Reorder imports in ObjFW.h to get rid of a warning on Win32. check-in: c12598e3be user: js tags: trunk
21:07
Fix lookup of service when getaddrinfo is unavailable. check-in: 11a9f98b7a user: js tags: trunk
20:58
Use OFInvalidFormatException for -[(hexa)decimalValue] on bad strings. check-in: 58a082efe4 user: js tags: trunk
Changes

Modified src/OFTCPSocket.m from [7b6a248246] to [b23751c527].

122
123
124
125
126
127
128
129

130



131
132








133
134
135


136
137
138
139
140











141
142
143
144
145
146
147
122
123
124
125
126
127
128

129
130
131
132
133


134
135
136
137
138
139
140
141
142


143
144
145




146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163







-
+

+
+
+
-
-
+
+
+
+
+
+
+
+

-
-
+
+

-
-
-
-
+
+
+
+
+
+
+
+
+
+
+







# endif
		@throw [OFAddressTranslationFailedException
		    newWithClass: isa
			    node: node
			 service: service];
	}

	if ((se = getservbyname([service cString], "TCP")) != NULL)
	if ((se = getservbyname([service cString], "tcp")) != NULL)
		port = se->s_port;
	else {
		@try {
			intmax_t p = [service decimalValue];
	else if ((port = of_bswap16_if_le(strtol([service cString], NULL,
	    10))) == 0) {

			if (p < 1 || p > 65535)
				@throw [OFOutOfRangeException
				    newWithClass: isa];

			port = of_bswap16_if_le(p);
		} @catch (OFInvalidFormatException *e) {
			[e release];
# ifdef OF_THREADS
		[addrlist release];
		[mutex unlock];
			[addrlist release];
			[mutex unlock];
# endif
		@throw [OFAddressTranslationFailedException
		    newWithClass: isa
			    node: node
			 service: service];
			@throw [OFAddressTranslationFailedException
			    newWithClass: isa
				    node: node
				 service: service];
		} @catch (id e) {
# ifdef OF_THREADS
			[addrlist release];
			[mutex unlock];
# endif
			@throw e;
		}
	}

	memset(&addr, 0, sizeof(addr));
	addr.sin_family = AF_INET;
	addr.sin_port = port;

	if (he->h_addrtype != AF_INET ||
249
250
251
252
253
254
255
256

257



258
259








260
261

262
263
264
265
266










267
268
269
270
271
272
273
265
266
267
268
269
270
271

272
273
274
275
276


277
278
279
280
281
282
283
284
285

286
287




288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304







-
+

+
+
+
-
-
+
+
+
+
+
+
+
+

-
+

-
-
-
-
+
+
+
+
+
+
+
+
+
+







# endif
		@throw [OFAddressTranslationFailedException
		    newWithClass: isa
			    node: node
			 service: service];
	}

	if ((se = getservbyname([service cString], "TCP")) != NULL)
	if ((se = getservbyname([service cString], "tcp")) != NULL)
		port = se->s_port;
	else {
		@try {
			intmax_t p = [service decimalValue];
	else if ((port = of_bswap16_if_le(strtol([service cString], NULL,
	    10))) == 0) {

			if (p < 1 || p > 65535)
				@throw [OFOutOfRangeException
				    newWithClass: isa];

			port = of_bswap16_if_le(p);
		} @catch (OFInvalidFormatException *e) {
			[e release];
# ifdef OF_THREADS
		[mutex unlock];
			[mutex unlock];
# endif
		@throw [OFAddressTranslationFailedException
		    newWithClass: isa
			    node: node
			 service: service];
			@throw [OFAddressTranslationFailedException
			    newWithClass: isa
				    node: node
				 service: service];
		} @catch (id e) {
# ifdef OF_THREADS
			[mutex unlock];
# endif
			@throw e;
		}
	}

	memset(&addr, 0, sizeof(addr));
	addr.sin_family = AF_INET;
	addr.sin_port = port;

	if (he->h_addrtype != AF_INET || he->h_addr_list[0] == NULL) {