]> git.sur5r.net Git - openldap/commitdiff
Check if inet_addr() returns 0xffffffff as well as -1.
authorHallvard Furuseth <hallvard@openldap.org>
Thu, 12 Nov 1998 02:24:43 +0000 (02:24 +0000)
committerHallvard Furuseth <hallvard@openldap.org>
Thu, 12 Nov 1998 02:24:43 +0000 (02:24 +0000)
It returns (int)0xffffffff on OSF1 which has 64-bit long, so
`unsigned long address; ... if((address = inet_addr(str)) == -1)' fails.

libraries/libldap/cldap.c
libraries/libldap/os-ip.c

index c12859b858ddf9dffe5f906441df2b2ba1eb20dc..9403c090c04089e1d710d53862a89d8bf565753d 100644 (file)
@@ -105,7 +105,10 @@ cldap_open( char *host, int port )
                }
            }
 
-           if ( (address = inet_addr( host )) == (unsigned long) -1L ) {
+           address = inet_addr( host );
+           /* This was just a test for -1 until OSF1 let inet_addr return
+              unsigned int, which is narrower than 'unsigned long address' */
+           if ( address == 0xffffffff || address == (unsigned long) -1 ) {
                if ( (hp = gethostbyname( host )) == NULL ) {
                    errno = EHOSTUNREACH;
                    continue;
index 4642144b20d46cab062319fa5b65d6ac35d99026..56aa3deecf87925452b3819c3088c2d0c966d788 100644 (file)
@@ -54,7 +54,11 @@ ldap_connect_to_host( Sockbuf *sb, char *host, unsigned long address,
 
        connected = use_hp = 0;
 
-       if ( host != NULL && ( address = inet_addr( host )) == (unsigned long) -1L ) {
+       if ( host != NULL ) {
+           address = inet_addr( host );
+           /* This was just a test for -1 until OSF1 let inet_addr return
+              unsigned int, which is narrower than 'unsigned long address' */
+           if ( address == 0xffffffff || address == (unsigned long) -1 ) {
                if ( (hp = gethostbyname( host )) == NULL ) {
 #ifdef HAVE_WINSOCK
                        errno = WSAGetLastError();
@@ -64,6 +68,7 @@ ldap_connect_to_host( Sockbuf *sb, char *host, unsigned long address,
                        return( -1 );
                }
                use_hp = 1;
+           }
        }
 
        rc = -1;