]> git.sur5r.net Git - openldap/blobdiff - libraries/libldap/os-ip.c
Fix ITS#1843, don't deref NULL string in ldap_pvt_str2upper
[openldap] / libraries / libldap / os-ip.c
index 396873459726dee61288383c461611e62bd9487e..0084743d8498fe922a32e9aade7835416abbe656 100644 (file)
@@ -152,7 +152,7 @@ ldap_pvt_is_socket_ready(LDAP *ld, int s)
 #if defined( notyet ) /* && defined( SO_ERROR ) */
 {
        int so_errno;
-       int dummy = sizeof(so_errno);
+       socklen_t dummy = sizeof(so_errno);
        if ( getsockopt( s, SOL_SOCKET, SO_ERROR, &so_errno, &dummy )
                == AC_SOCKET_ERROR )
        {
@@ -170,7 +170,7 @@ ldap_pvt_is_socket_ready(LDAP *ld, int s)
        /* error slippery */
        struct sockaddr_in sin;
        char ch;
-       int dummy = sizeof(sin);
+       socklen_t dummy = sizeof(sin);
        if ( getpeername( s, (struct sockaddr *) &sin, &dummy )
                == AC_SOCKET_ERROR )
        {
@@ -318,13 +318,18 @@ ldap_connect_to_host(LDAP *ld, Sockbuf *sb,
        char                    *ha_buf=NULL, *p, *q;
        int                     socktype;
 
-       osip_debug(ld, "ldap_connect_to_host: %s\n",host,0,0);
        
        switch(proto) {
-       case LDAP_PROTO_TCP: socktype = SOCK_STREAM; break;
-       case LDAP_PROTO_UDP: socktype = SOCK_DGRAM; break;
-       default: osip_debug(ld, "ldap_connect_to_host: unknown proto: %d\n",
-                               proto, 0, 0);
+       case LDAP_PROTO_TCP: socktype = SOCK_STREAM;
+               osip_debug(ld, "ldap_connect_to_host: TCP %s:%d\n",host,port,0);
+               break;
+       case LDAP_PROTO_UDP: socktype = SOCK_DGRAM;
+               osip_debug(ld, "ldap_connect_to_host: TCP %s:%d\n",host,port,0);
+               break;
+
+       default:
+               osip_debug(ld, "ldap_connect_to_host: unknown proto: %d\n",
+                       proto, 0, 0);
                return -1;
        }
 
@@ -339,7 +344,7 @@ ldap_connect_to_host(LDAP *ld, Sockbuf *sb,
                hints.ai_socktype = socktype;
 
                snprintf(serv, sizeof serv, "%d", port );
-               if ( err = getaddrinfo(host, serv, &hints, &res) ) {
+               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;
@@ -676,7 +681,11 @@ ldap_int_select( LDAP *ld, struct timeval *timeout )
 {
        struct selectinfo       *sip;
 
+#ifdef NEW_LOGGING
+       LDAP_LOG (( "os-ip", LDAP_LEVEL_ENTRY, "ldap_int_select\n" ));
+#else
        Debug( LDAP_DEBUG_TRACE, "ldap_int_select\n", 0, 0, 0 );
+#endif
 
        if ( ldap_int_tblsize == 0 )
                ldap_int_ip_init();