+2007-08-09 Wolfgang Sourdeau <WSourdeau@Inverse.CA>
+
+ * NGInternetSocketAddress.m: properly convert ports returned by
+ getservbyname() to host byteorder prior calling -initWithPort:onHost:
+ (fixes OGo bug #1896) (v4.7.53)
+
2007-08-07 Marcus Mueller <znek@mulle-kybernetik.com>
* NGInternetSocketAddress.m: do not define USE_GETHOSTBYNAME_R on
- (id)initWithService:(NSString *)_serviceName onHost:(id)_host
protocol:(NSString *)_protocol
{
+ /* careful: the port in servent is in network byteorder! */
NSException *exc = nil;
int port = -1;
#if defined(HAVE_GETSERVBYNAME_R)
[systemLock lock];
{
entry = getservbyname((char *)[_serviceName cString], [_protocol cString]);
- if (entry == NULL)
- exc = [[NGDidNotFindServiceException alloc] initWithServiceName:_serviceName];
+ if (entry == NULL) {
+ exc = [[NGDidNotFindServiceException alloc]
+ initWithServiceName:_serviceName];
+ }
else
port = entry->s_port;
}
[systemLock unlock];
#endif
- if (exc) {
+ if (exc != nil) {
self = [self autorelease];
[exc raise];
return nil;
}
- return [self initWithPort:port onHost:_host];
+ return [self initWithPort:ntohs(port) onHost:_host];
}
- (id)initWithPort:(int)_port {