]> git.sur5r.net Git - openldap/commitdiff
s/strtoul/strtol/ (ITS#5165)
authorPierangelo Masarati <ando@openldap.org>
Tue, 2 Oct 2007 23:45:50 +0000 (23:45 +0000)
committerPierangelo Masarati <ando@openldap.org>
Tue, 2 Oct 2007 23:45:50 +0000 (23:45 +0000)
servers/slapd/ldapsync.c
servers/slapd/syncrepl.c

index 8fca2903e668fd2fc3a59c2a015d9efb00448d04..d04aa260f2030f0848a068227ab6c4cf87450ff1 100644 (file)
@@ -146,8 +146,8 @@ slap_parse_csn_sid( struct berval *csnp )
 
        csn.bv_len = q - p;
 
-       i = (int)strtoul( p, &q, 16 );
-       if ( p == q || q != p + csn.bv_len || i > SLAP_SYNC_SID_MAX ) {
+       i = strtol( p, &q, 16 );
+       if ( p == q || q != p + csn.bv_len || i < 0 || i > SLAP_SYNC_SID_MAX ) {
                i = -1;
        }
 
index 92a5f4c30eed042005394fc5060c5402d3c32b79..b0680cad9ba5a340066d6a5b041d480447b3506f 100644 (file)
@@ -3583,12 +3583,10 @@ parse_syncrepl_line(
                                si->si_interval = 0;
                        } else if ( strchr( val, ':' ) != NULL ) {
                                char *next, *ptr = val;
-                               unsigned dd, hh, mm, ss;
+                               int dd, hh, mm, ss;
 
-                               /* NOTE: the test for ptr[ 0 ] == '-'
-                                * should go before the call to strtoul() */
-                               dd = strtoul( ptr, &next, 10 );
-                               if ( ptr[ 0 ] == '-' || next == ptr || next[0] != ':' ) {
+                               dd = strtol( ptr, &next, 10 );
+                               if ( next == ptr || next[0] != ':' || dd < 0 ) {
                                        snprintf( c->cr_msg, sizeof( c->cr_msg ),
                                                "Error: parse_syncrepl_line: "
                                                "invalid interval \"%s\", unable to parse days", val );
@@ -3596,8 +3594,8 @@ parse_syncrepl_line(
                                        return -1;
                                }
                                ptr = next + 1;
-                               hh = strtoul( ptr, &next, 10 );
-                               if ( ptr[ 0 ] == '-' || next == ptr || next[0] != ':' || hh > 24 ) {
+                               hh = strtol( ptr, &next, 10 );
+                               if ( next == ptr || next[0] != ':' || hh < 0 || hh > 24 ) {
                                        snprintf( c->cr_msg, sizeof( c->cr_msg ),
                                                "Error: parse_syncrepl_line: "
                                                "invalid interval \"%s\", unable to parse hours", val );
@@ -3605,8 +3603,8 @@ parse_syncrepl_line(
                                        return -1;
                                }
                                ptr = next + 1;
-                               mm = strtoul( ptr, &next, 10 );
-                               if ( ptr[ 0 ] == '-' || next == ptr || next[0] != ':' || mm > 60 ) {
+                               mm = strtol( ptr, &next, 10 );
+                               if ( next == ptr || next[0] != ':' || mm < 0 || mm > 60 ) {
                                        snprintf( c->cr_msg, sizeof( c->cr_msg ),
                                                "Error: parse_syncrepl_line: "
                                                "invalid interval \"%s\", unable to parse minutes", val );
@@ -3614,8 +3612,8 @@ parse_syncrepl_line(
                                        return -1;
                                }
                                ptr = next + 1;
-                               ss = strtoul( ptr, &next, 10 );
-                               if ( ptr[ 0 ] == '-' || next == ptr || next[0] != '\0' || ss > 60 ) {
+                               ss = strtol( ptr, &next, 10 );
+                               if ( next == ptr || next[0] != '\0' || ss < 0 || ss > 60 ) {
                                        snprintf( c->cr_msg, sizeof( c->cr_msg ),
                                                "Error: parse_syncrepl_line: "
                                                "invalid interval \"%s\", unable to parse seconds", val );