]> git.sur5r.net Git - openldap/blobdiff - clients/gopher/go500gw.c
initialize Sockbuf * to NULL
[openldap] / clients / gopher / go500gw.c
index c1c5ab4a9ef47c556e3823f66d3ce195aedeb13f..efe5054d811d97c2bcb67c7e32d0f6f0c11fe69b 100644 (file)
 #include <ac/unistd.h>
 #include <ac/wait.h>
 
+#include <ac/param.h>
 #include <ac/setproctitle.h>
 
-#ifdef HAVE_SYS_PARAM_H
-#include <sys/param.h>
-#endif
-
 #ifdef HAVE_SYS_RESOURCE_H
 #include <sys/resource.h>
 #endif
@@ -179,11 +176,12 @@ main (int  argc, char **argv )
 #ifdef GO500GW_HOSTNAME
        strcpy( myhost, GO500GW_HOSTNAME );
 #else
-       if ( myhost[0] == '\0' && gethostname( myhost, sizeof(myhost) )
+       if ( myhost[0] == '\0' && gethostname( myhost, sizeof(myhost)-1 )
            == -1 ) {
                perror( "gethostname" );
                exit( EXIT_FAILURE );
        }
+       myhost[sizeof(myhost)-1] = '\0';
 #endif
 
        /* detach if stderr is redirected or no debugging */
@@ -207,7 +205,7 @@ main (int  argc, char **argv )
        if ( dosyslog ) {
 #ifdef LOG_LOCAL3
                openlog( myname, OPENLOG_OPTIONS, LOG_LOCAL3 );
-#else
+#elif LOG_DEBUG
                openlog( myname, OPENLOG_OPTIONS );
 #endif
        }
@@ -226,8 +224,8 @@ main (int  argc, char **argv )
                fromlen = sizeof(from);
                if ( getpeername( 0, (struct sockaddr *) &from, &fromlen )
                    == 0 ) {
-                       hp = gethostbyaddr( (char *) &(from.sin_addr.s_addr),
-                           sizeof(from.sin_addr.s_addr), AF_INET );
+                       hp = gethostbyaddr( (char *) &(from.sin_addr),
+                           sizeof(from.sin_addr), AF_INET );
                        Debug( LDAP_DEBUG_ARGS, "connection from %s (%s)\n",
                            (hp == NULL) ? "unknown" : hp->h_name,
                            inet_ntoa( from.sin_addr ), 0 );
@@ -239,7 +237,7 @@ main (int  argc, char **argv )
                        }
 
 #ifdef LDAP_PROCTITLE
-                       setproctitle( hp == NULL ? inet_ntoa( from.sin_addr ) :
+                       setproctitle( "%s", hp == NULL ? inet_ntoa( from.sin_addr ) :
                            hp->h_name );
 #endif
                }
@@ -272,8 +270,8 @@ main (int  argc, char **argv )
                        exit( EXIT_FAILURE );
                }
 
-               hp = gethostbyaddr( (char *) &(from.sin_addr.s_addr),
-                   sizeof(from.sin_addr.s_addr), AF_INET );
+               hp = gethostbyaddr( (char *) &(from.sin_addr),
+                   sizeof(from.sin_addr), AF_INET );
 
                if ( dosyslog ) {
                        syslog( LOG_INFO, "TCP connection from %s (%s)",
@@ -373,7 +371,7 @@ wait4child( int sig )
                ;       /* NULL */
 #endif
 
-       (void) SIGNAL( SIGCHLD, wait4child );
+       (void) SIGNAL_REINSTALL ( SIGCHLD, wait4child );
 }
 
 static void
@@ -556,7 +554,7 @@ isnonleaf( LDAP *ld, char **oclist, char *dn )
                timeout.tv_usec = 0;
                ldap_set_option(ld, LDAP_OPT_SIZELIMIT, &sizelimit);
                if ( (rc = ldap_search_st( ld, dn, LDAP_SCOPE_ONELEVEL,
-                   "(objectClass=*)", attrs, 0, &timeout, &res ))
+                   NULL, attrs, 0, &timeout, &res ))
                    == LDAP_SUCCESS || rc == LDAP_SIZELIMIT_EXCEEDED ) {
                        sizelimit = LDAP_NO_LIMIT;
                        ldap_set_option(ld, LDAP_OPT_SIZELIMIT, &sizelimit);
@@ -706,7 +704,7 @@ make_scope( LDAP *ld, char *dn )
 
        timeout.tv_sec = GO500GW_TIMEOUT;
        timeout.tv_usec = 0;
-       if ( ldap_search_st( ld, dn, LDAP_SCOPE_BASE, "objectClass=*",
+       if ( ldap_search_st( ld, dn, LDAP_SCOPE_BASE, NULL,
            attrs, 0, &timeout, &res ) != LDAP_SUCCESS ) {
                return( -1 );
        }