]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/syncrepl.c
make sure NULL pointers are not dereferenced
[openldap] / servers / slapd / syncrepl.c
index bf2f436b1af980f76f197a5319e0c051540b6ab4..19c31ec6e5058ba6ec4f4464ee66449a1c7e8110 100644 (file)
@@ -83,9 +83,6 @@ typedef struct syncinfo_s {
        int                                     si_syncdata;
        int                                     si_logstate;
        int                                     si_conn_setup;
-#ifdef HAVE_TLS
-       int                                     si_check_tls;
-#endif
        Avlnode                         *si_presentlist;
        LDAP                            *si_ld;
        LDAP_LIST_HEAD(np, nonpresent_entry) si_nonpresentlist;
@@ -440,8 +437,7 @@ do_syncrep1(
                (const void *)&op->o_protocol );
 
 #ifdef HAVE_TLS
-       if ( si->si_check_tls ) {
-               si->si_check_tls = 0;
+       if ( si->si_bindconf.sb_tls_do_init ) {
                rc = bindconf_tls_set( &si->si_bindconf, si->si_ld );
        } else if ( si->si_bindconf.sb_tls_ctx ) {
                rc = ldap_set_option( si->si_ld, LDAP_OPT_X_TLS_CTX,
@@ -2757,10 +2753,11 @@ syncinfo_free( syncinfo_t *sie )
 
 /* mandatory */
 #define GOT_ID                 0x0001
-#define GOT_PROVIDER           0x0002
+#define GOT_PROVIDER   0x0002
+#define        GOT_BASE                0x0004
 
 /* check */
-#define GOT_ALL                        (GOT_ID|GOT_PROVIDER)
+#define GOT_ALL                        (GOT_ID|GOT_PROVIDER|GOT_BASE)
 
 static struct {
        struct berval key;
@@ -2866,6 +2863,7 @@ parse_syncrepl_line(
                                Debug( LDAP_DEBUG_ANY, "%s: %s.\n", c->log, c->msg, 0 );
                                return -1;
                        }
+                       gots |= GOT_BASE;
                } else if ( !strncasecmp( c->argv[ i ], LOGBASESTR "=",
                                        STRLENOF( LOGBASESTR "=" ) ) )
                {
@@ -3182,7 +3180,10 @@ parse_syncrepl_line(
 
        if ( gots != GOT_ALL ) {
                snprintf( c->msg, sizeof( c->msg ),
-                       "Error: Malformed \"syncrepl\" line in slapd config file" );
+                       "Error: Malformed \"syncrepl\" line in slapd config file, missing%s%s%s",
+                       gots & GOT_ID ? "" : " "IDSTR,
+                       gots & GOT_PROVIDER ? "" : " "PROVIDERSTR,
+                       gots & GOT_BASE ? "" : " "SEARCHBASESTR );
                Debug( LDAP_DEBUG_ANY, "%s: %s.\n", c->log, c->msg, 0 );
                return -1;
        }
@@ -3233,10 +3234,6 @@ add_syncrepl(
        si->si_slimit = 0;
        si->si_conn_setup = 0;
 
-#ifdef HAVE_TLS
-       si->si_check_tls = 1;
-#endif
-
        si->si_presentlist = NULL;
        LDAP_LIST_INIT( &si->si_nonpresentlist );
        ldap_pvt_thread_mutex_init( &si->si_mutex );