]> git.sur5r.net Git - openldap/blobdiff - libraries/libldap/os-ip.c
Fix off by one bug
[openldap] / libraries / libldap / os-ip.c
index 49f5a15a3278541cecf71e702c32ee200f7e8325..8cef102b3ec4fc27b57d37b99f05f7467a9e73a4 100644 (file)
@@ -152,7 +152,7 @@ ldap_pvt_is_socket_ready(LDAP *ld, int s)
        int so_errno;
        int dummy = sizeof(so_errno);
        if ( getsockopt( s, SOL_SOCKET, SO_ERROR, &so_errno, &dummy )
-               == SOCKET_ERROR )
+               == AC_SOCKET_ERROR )
        {
                return -1;
        }
@@ -170,7 +170,7 @@ ldap_pvt_is_socket_ready(LDAP *ld, int s)
        char ch;
        int dummy = sizeof(sin);
        if ( getpeername( s, (struct sockaddr *) &sin, &dummy )
-               == SOCKET_ERROR )
+               == AC_SOCKET_ERROR )
        {
                /* XXX: needs to be replace with ber_stream_read() */
                read(s, &ch, 1);
@@ -209,7 +209,7 @@ ldap_pvt_connect(LDAP *ld, ber_socket_t s,
        if ( ldap_pvt_ndelay_on(ld, s) == -1 )
                return ( -1 );
 
-       if ( connect(s, sin, addrlen) != SOCKET_ERROR )
+       if ( connect(s, sin, addrlen) != AC_SOCKET_ERROR )
        {
                if ( ldap_pvt_ndelay_off(ld, s) == -1 )
                        return ( -1 );
@@ -242,7 +242,7 @@ ldap_pvt_connect(LDAP *ld, ber_socket_t s,
 #else
                    z,
 #endif
-                   opt_tv ? &tv : NULL) == SOCKET_ERROR )
+                   opt_tv ? &tv : NULL) == AC_SOCKET_ERROR )
        {
                return ( -1 );
        }
@@ -299,6 +299,7 @@ ldap_connect_to_host(LDAP *ld, Sockbuf *sb,
        if (host != NULL) {
 #ifdef HAVE_GETADDRINFO
                char serv[7];
+               int err;
                struct addrinfo hints, *res, *sai;
 
                memset( &hints, '\0', sizeof(hints) );
@@ -306,8 +307,8 @@ ldap_connect_to_host(LDAP *ld, Sockbuf *sb,
                hints.ai_socktype = SOCK_STREAM;
 
                snprintf(serv, sizeof serv, "%d", ntohs(port));
-               if ( getaddrinfo(host, serv, &hints, &res) ) {
-                       osip_debug(ld, "ldap_connect_to_host:getaddrinfo failed\n",0,0,0);
+               if ( err = getaddrinfo(host, serv, &hints, &res) ) {
+                       osip_debug(ld, "ldap_connect_to_host: getaddrinfo failed: %s\n", AC_GAI_STRERROR(err), 0, 0);
                        return -1;
                }
                sai = res;