From: Pierangelo Masarati Date: Tue, 2 Oct 2007 23:45:50 +0000 (+0000) Subject: s/strtoul/strtol/ (ITS#5165) X-Git-Tag: OPENLDAP_REL_ENG_2_4_9~20^2~565 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=471cd1d8488e0b44d9c631f0c8c575e7ea711014;p=openldap s/strtoul/strtol/ (ITS#5165) --- diff --git a/servers/slapd/ldapsync.c b/servers/slapd/ldapsync.c index 8fca2903e6..d04aa260f2 100644 --- a/servers/slapd/ldapsync.c +++ b/servers/slapd/ldapsync.c @@ -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; } diff --git a/servers/slapd/syncrepl.c b/servers/slapd/syncrepl.c index 92a5f4c30e..b0680cad9b 100644 --- a/servers/slapd/syncrepl.c +++ b/servers/slapd/syncrepl.c @@ -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 );