]> git.sur5r.net Git - openldap/commitdiff
Oops, fp_parse_line tokenizes in place, so we need to take a copy of
authorJulio Sánchez Fernández <jsanchez@openldap.org>
Sun, 30 May 1999 00:07:40 +0000 (00:07 +0000)
committerJulio Sánchez Fernández <jsanchez@openldap.org>
Sun, 30 May 1999 00:07:40 +0000 (00:07 +0000)
input before letting fp_parse_line ruin it.

servers/slapd/config.c

index 1e39a65e8455c0a083275b78b5bd18a1267fd371..7243135fbd837e2766ceabeb90dec019ab8c761b 100644 (file)
@@ -40,7 +40,7 @@ int
 read_config( char *fname )
 {
        FILE    *fp;
-       char    *line, *savefname;
+       char    *line, *savefname, *saveline;
        int     cargc, savelineno;
        char    *cargv[MAXARGS];
        int     lineno, i;
@@ -69,6 +69,9 @@ read_config( char *fname )
 
                Debug( LDAP_DEBUG_CONFIG, "line %d (%s)\n", lineno, line, 0 );
 
+               /* fp_parse_line is destructive, we save a copy */
+               saveline = ch_strdup( line );
+
                if ( fp_parse_line( line, &cargc, cargv ) != 0 ) {
                        return( 1 );
                }
@@ -348,7 +351,7 @@ read_config( char *fname )
                } else if ( strcasecmp( cargv[0], "objectclass" ) == 0 ) {
                        if ( *cargv[1] == '(' ) {
                                char * p;
-                               p = strchr(line,'(');
+                               p = strchr(saveline,'(');
                                parse_oc( fname, lineno, p );
                        } else {
                                parse_oc_old( be, fname, lineno, cargc, cargv );
@@ -358,7 +361,7 @@ read_config( char *fname )
                } else if ( strcasecmp( cargv[0], "attribute" ) == 0 ) {
                        if ( *cargv[1] == '(' ) {
                                char * p;
-                               p = strchr(line,'(');
+                               p = strchr(saveline,'(');
                                parse_at( fname, lineno, p );
                        } else {
                                attr_syntax_config( fname, lineno, cargc - 1,
@@ -558,6 +561,7 @@ read_config( char *fname )
                                    fname, lineno, cargv[0] );
                        }
                }
+               free( saveline );
        }
        fclose( fp );
        return( 0 );