]> git.sur5r.net Git - openldap/blobdiff - servers/slapd/tools/slapadd.c
Don't reeval expression
[openldap] / servers / slapd / tools / slapadd.c
index e993da5fa8fb9f35aab4c156f8a537dd1887114d..1f31d57735385f4f5b0195d30c424622e6c173b9 100644 (file)
@@ -59,8 +59,12 @@ main( int argc, char **argv )
                Entry *e = str2entry( buf );
                struct berval bvtext;
 
+               /*
+                * Initialize text buffer
+                */
                bvtext.bv_len = textlen;
                bvtext.bv_val = textbuf;
+               bvtext.bv_val[0] = '\0';
 
                if( e == NULL ) {
                        fprintf( stderr, "%s: could not parse entry (line=%d)\n",
@@ -152,12 +156,12 @@ main( int argc, char **argv )
                if ( SLAP_LASTMOD(be) ) {
                        struct tm *ltm;
                        time_t now = slap_get_time();
-                       char uuidbuf[40];
-                       struct berval vals[2];
+                       char uuidbuf[ LDAP_LUTIL_UUIDSTR_BUFSIZE ];
+                       struct berval vals[ 2 ];
 
                        struct berval name, timestamp, csn;
-                       char timebuf[22];
-                       char csnbuf[64];
+                       char timebuf[ LDAP_LUTIL_GENTIME_BUFSIZE ];
+                       char csnbuf[ LDAP_LUTIL_CSNSTR_BUFSIZE ];
 
                        ltm = gmtime(&now);
                        lutil_gentime( timebuf, sizeof(timebuf), ltm );
@@ -188,7 +192,7 @@ main( int argc, char **argv )
                        if( attr_find( e->e_attrs, slap_schema.si_ad_creatorsName )
                                == NULL )
                        {
-                               ber_dupbv( &vals[0], &name );
+                               vals[0] = name;
                                vals[1].bv_len = 0;
                                vals[1].bv_val = NULL;
                                attr_merge( e, slap_schema.si_ad_creatorsName, vals);
@@ -197,7 +201,7 @@ main( int argc, char **argv )
                        if( attr_find( e->e_attrs, slap_schema.si_ad_modifiersName )
                                == NULL )
                        {
-                               ber_dupbv( &vals[0], &name );
+                               vals[0] = name;
                                vals[1].bv_len = 0;
                                vals[1].bv_val = NULL;
                                attr_merge( e, slap_schema.si_ad_modifiersName, vals);
@@ -206,7 +210,7 @@ main( int argc, char **argv )
                        if( attr_find( e->e_attrs, slap_schema.si_ad_createTimestamp )
                                == NULL )
                        {
-                               ber_dupbv( &vals[0], &timestamp );
+                               vals[0] = timestamp;
                                vals[1].bv_len = 0;
                                vals[1].bv_val = NULL;
                                attr_merge( e, slap_schema.si_ad_createTimestamp, vals );
@@ -215,7 +219,7 @@ main( int argc, char **argv )
                        if( attr_find( e->e_attrs, slap_schema.si_ad_modifyTimestamp )
                                == NULL )
                        {
-                               ber_dupbv( &vals[0], &timestamp );
+                               vals[0] = timestamp;
                                vals[1].bv_len = 0;
                                vals[1].bv_val = NULL;
                                attr_merge( e, slap_schema.si_ad_modifyTimestamp, vals );
@@ -224,7 +228,7 @@ main( int argc, char **argv )
                        if( attr_find( e->e_attrs, slap_schema.si_ad_entryCSN )
                                == NULL )
                        {
-                               ber_dupbv( &vals[0], &csn );
+                               vals[0] = csn;
                                vals[1].bv_len = 0;
                                vals[1].bv_val = NULL;
                                attr_merge( e, slap_schema.si_ad_entryCSN, vals );