]> git.sur5r.net Git - openldap/commitdiff
add more checks on input values
authorPierangelo Masarati <ando@openldap.org>
Tue, 20 Dec 2005 13:07:38 +0000 (13:07 +0000)
committerPierangelo Masarati <ando@openldap.org>
Tue, 20 Dec 2005 13:07:38 +0000 (13:07 +0000)
servers/slapd/syncrepl.c

index 355171986f31728b3cc04db755efee93e57533c2..0d05b951266cbc93b19ed39483e55222f6746a15 100644 (file)
@@ -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 );