s/strtoul/strtol/ (ITS#5165)

This commit is contained in:
Pierangelo Masarati 2007-10-02 23:45:50 +00:00
parent 5653ab8338
commit 471cd1d848
2 changed files with 11 additions and 13 deletions

View 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;
}

View 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 );