From: helge Date: Tue, 14 Aug 2007 16:33:51 +0000 (+0000) Subject: fixed OGo bug #1896 X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=d56d4f818a831ad0a2f29bcb06df47836ae97249;p=sope fixed OGo bug #1896 git-svn-id: http://svn.opengroupware.org/SOPE/trunk@1524 e4a50df8-12e2-0310-a44c-efbce7f8a7e3 --- diff --git a/sope-core/NGStreams/ChangeLog b/sope-core/NGStreams/ChangeLog index 843c1b74..e6f6b1cd 100644 --- a/sope-core/NGStreams/ChangeLog +++ b/sope-core/NGStreams/ChangeLog @@ -1,3 +1,9 @@ +2007-08-09 Wolfgang Sourdeau + + * 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 * NGInternetSocketAddress.m: do not define USE_GETHOSTBYNAME_R on diff --git a/sope-core/NGStreams/NGInternetSocketAddress.m b/sope-core/NGStreams/NGInternetSocketAddress.m index 7634e803..6263eca3 100644 --- a/sope-core/NGStreams/NGInternetSocketAddress.m +++ b/sope-core/NGStreams/NGInternetSocketAddress.m @@ -417,6 +417,7 @@ static inline NSString *_nameOfLocalhost(void) { - (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) @@ -437,20 +438,22 @@ static inline NSString *_nameOfLocalhost(void) { [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 { diff --git a/sope-core/NGStreams/Version b/sope-core/NGStreams/Version index 063faafb..d124b50f 100644 --- a/sope-core/NGStreams/Version +++ b/sope-core/NGStreams/Version @@ -1,3 +1,3 @@ # version file -SUBMINOR_VERSION:=52 +SUBMINOR_VERSION:=53