From: Pierangelo Masarati Date: Tue, 20 Dec 2005 13:07:38 +0000 (+0000) Subject: add more checks on input values X-Git-Tag: OPENLDAP_REL_ENG_2_4_BP~546 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=46a88603dda26fd6fc1fc723f7827e60adbd17ed;p=openldap add more checks on input values --- diff --git a/servers/slapd/syncrepl.c b/servers/slapd/syncrepl.c index 355171986f..0d05b95126 100644 --- a/servers/slapd/syncrepl.c +++ b/servers/slapd/syncrepl.c @@ -3011,7 +3011,9 @@ parse_syncrepl_line( j++; break; } else { - if ( lutil_atoi( &si->si_retrynum_init[j], retry_list[j*2+1] ) != 0 ) { + if ( lutil_atoi( &si->si_retrynum_init[j], retry_list[j*2+1] ) != 0 + || si->si_retrynum_init[j] <= 0 ) + { snprintf( c->msg, sizeof( c->msg ), "Error: invalid initial retry number \"%s\" (#%d)", retry_list[j*2+1], j ); @@ -3019,7 +3021,9 @@ parse_syncrepl_line( /* do some cleanup */ return 1; } - if ( lutil_atoi( &si->si_retrynum[j], retry_list[j*2+1] ) != 0 ) { + if ( lutil_atoi( &si->si_retrynum[j], retry_list[j*2+1] ) != 0 + || si->si_retrynum[j] <= 0 ) + { snprintf( c->msg, sizeof( c->msg ), "Error: invalid retry number \"%s\" (#%d)", retry_list[j*2+1], j ); @@ -3054,7 +3058,10 @@ parse_syncrepl_line( STRLENOF( SLIMITSTR "=") ) ) { val = c->argv[ i ] + STRLENOF( SLIMITSTR "=" ); - if ( lutil_atoi( &si->si_slimit, val ) != 0 ) { + if ( strcasecmp( val, "unlimited" ) == 0 ) { + si->si_slimit = 0; + + } else if ( lutil_atoi( &si->si_slimit, val ) != 0 || val < 0 ) { snprintf( c->msg, sizeof( c->msg ), "invalid size limit value \"%s\".\n", val ); @@ -3065,7 +3072,10 @@ parse_syncrepl_line( STRLENOF( TLIMITSTR "=" ) ) ) { val = c->argv[ i ] + STRLENOF( TLIMITSTR "=" ); - if ( lutil_atoi( &si->si_tlimit, val ) != 0 ) { + if ( strcasecmp( val, "unlimited" ) == 0 ) { + si->si_tlimit = 0; + + } else if ( lutil_atoi( &si->si_tlimit, val ) != 0 || val < 0 ) { snprintf( c->msg, sizeof( c->msg ), "invalid time limit value \"%s\".\n", val );