Commit 98356629 authored by Ondřej Kuzník's avatar Ondřej Kuzník
Browse files

ITS#9160 OOM handling in test programs

parent 28828e1b
......@@ -412,11 +412,19 @@ do_base( struct tester_conn_args *config, char *dn, char *base, char *filter, ch
case LDAP_RES_SEARCH_ENTRY:
rc = ldap_get_dn_ber( ld, msg, &ber, &bv );
dns = realloc( dns, (ndns + 1)*sizeof(char *) );
if ( !dns ) {
tester_error( "realloc failed" );
exit( EXIT_FAILURE );
}
dns[ndns] = ber_strdup( bv.bv_val );
if ( pwattr != NULL ) {
struct berval **values = ldap_get_values_len( ld, msg, pwattr );
creds = realloc( creds, (ndns + 1)*sizeof(struct berval) );
if ( !creds ) {
tester_error( "realloc failed" );
exit( EXIT_FAILURE );
}
if ( values == NULL ) {
novals:;
creds[ndns].bv_len = 0;
......
......@@ -125,6 +125,10 @@ do_modrdn( struct tester_conn_args *config,
DNs[0] = entry;
DNs[1] = strdup( entry );
if ( DNs[1] == NULL ) {
tester_error( "strdup failed" );
exit( EXIT_FAILURE );
}
/* reverse the RDN, make new DN */
p1 = strchr( entry, '=' ) + 1;
......@@ -132,6 +136,10 @@ do_modrdn( struct tester_conn_args *config,
*p2 = '\0';
rdns[1] = strdup( entry );
if ( rdns[1] == NULL ) {
tester_error( "strdup failed" );
exit( EXIT_FAILURE );
}
*p2-- = ',';
for (i = p1 - entry;p2 >= p1;)
......@@ -139,6 +147,10 @@ do_modrdn( struct tester_conn_args *config,
DNs[1][i] = '\0';
rdns[0] = strdup( DNs[1] );
if ( rdns[0] == NULL ) {
tester_error( "strdup failed" );
exit( EXIT_FAILURE );
}
DNs[1][i] = ',';
i = 0;
......
......@@ -531,6 +531,10 @@ do_random( LDAP *ld,
}
values = malloc( ( nvalues + 1 ) * sizeof( char * ) );
if (values == NULL) {
thread_error( idx, "(failed to malloc)");
exit( EXIT_FAILURE );
}
for ( i = 0, e = ldap_first_entry( ld, res ); e != NULL; i++, e = ldap_next_entry( ld, e ) )
{
values[ i ] = ldap_get_dn( ld, e );
......
......@@ -202,6 +202,10 @@ do_random( struct tester_conn_args *config, char *sbase, char *filter,
}
values = malloc( ( nvalues + 1 ) * sizeof( char * ) );
if ( !values ) {
tester_error( "malloc failed" );
exit( EXIT_FAILURE );
}
for ( i = 0, e = ldap_first_entry( ld, res ); e != NULL; i++, e = ldap_next_entry( ld, e ) )
{
values[ i ] = ldap_get_dn( ld, e );
......@@ -251,6 +255,10 @@ do_read( struct tester_conn_args *config, char *entry, LDAP **ldp,
/* make room for msgid */
if ( swamp > 1 ) {
msgids = (int *)calloc( sizeof(int), maxloop );
if ( !msgids ) {
tester_error( "calloc failed" );
exit( EXIT_FAILURE );
}
}
retry:;
......
......@@ -226,6 +226,10 @@ do_random( struct tester_conn_args *config,
int j;
values = realloc( values, ( nvalues + n + 1 )*sizeof( char * ) );
if ( !values ) {
tester_error( "realloc failed" );
exit( EXIT_FAILURE );
}
for ( j = 0; j < n; j++ ) {
values[ nvalues + j ] = strdup( v[ j ]->bv_val );
}
......@@ -298,6 +302,10 @@ do_search( struct tester_conn_args *config,
/* make room for msgid */
if ( swamp > 1 ) {
msgids = (int *)calloc( sizeof(int), innerloop );
if ( !msgids ) {
tester_error( "calloc failed" );
exit( EXIT_FAILURE );
}
}
retry:;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment