int version = LDAP_VERSION3;
char *nullstr = "";
- srand(pid);
+ srand( pid );
ldap_initialize( &ld, uri );
if ( ld == NULL ) {
/* Ok, got list of DNs, now start binding to each */
for ( i = 0; i < maxloop; i++ ) {
- int j, k;
- struct berval cred = { 0, NULL };
+ int j;
+ struct berval cred = { 0, NULL };
- for ( j = 0, k = 0; k < ndns; k++) {
- j = rand() % ndns;
- }
+
+#if 0 /* use high-order bits for better randomness (Numerical Recipes in "C") */
+ j = rand() % ndns;
+#endif
+ j = ((double)ndns)*rand()/(RAND_MAX + 1.0);
if ( creds && !BER_BVISEMPTY( &creds[j] ) ) {
cred = creds[j];
}
+
if ( do_bind( uri, dns[j], &cred, 1, force, chaserefs, noinit, &ld )
&& !force )
{
char **values = NULL;
LDAPMessage *res = NULL, *e = NULL;
+ srand( pid );
+
attrs[ 0 ] = LDAP_NO_ATTRS;
attrs[ 1 ] = NULL;
}
for ( i = 0; i < innerloop; i++ ) {
- do_read( uri, manager, passwd, values[ rand() % nvalues ], &ld,
+#if 0 /* use high-order bits for better randomness (Numerical Recipes in "C") */
+ int r = rand() % nvalues;
+#endif
+ int r = ((double)nvalues)*rand()/(RAND_MAX + 1.0);
+
+ do_read( uri, manager, passwd, values[ r ], &ld,
noattrs, 1, maxretries, delay, force,
chaserefs );
}
char **values = NULL;
LDAPMessage *res = NULL, *e = NULL;
+ srand( pid );
+
attrs[ 0 ] = attr;
attrs[ 1 ] = NULL;
for ( i = 0; i < innerloop; i++ ) {
char buf[ BUFSIZ ];
+#if 0 /* use high-order bits for better randomness (Numerical Recipes in "C") */
+ int r = rand() % nvalues;
+#endif
+ int r = ((double)nvalues)*rand()/(RAND_MAX + 1.0);
- snprintf( buf, sizeof( buf ), "(%s=%s)", attr, values[ rand() % nvalues ] );
+ snprintf( buf, sizeof( buf ), "(%s=%s)", attr, values[ r ] );
do_search( uri, manager, passwd, sbase, buf, &ld, noattrs,
1, maxretries, delay, force, chaserefs );