mirror of
https://git.openldap.org/openldap/openldap.git
synced 2025-12-24 16:49:39 -05:00
re-fix ITS#4495 working around atoi() limitations
This commit is contained in:
parent
5181a522c1
commit
19c5f261e5
1 changed files with 36 additions and 2 deletions
|
|
@ -1466,9 +1466,43 @@ str2result(
|
|||
}
|
||||
|
||||
if ( strncasecmp( s, "code", STRLENOF( "code" ) ) == 0 ) {
|
||||
if ( c != NULL ) {
|
||||
*code = atoi( c );
|
||||
char *next = NULL;
|
||||
long retcode;
|
||||
|
||||
if ( c == NULL ) {
|
||||
Debug( LDAP_DEBUG_ANY, "str2result (%s) missing value\n",
|
||||
s, 0, 0 );
|
||||
rc = -1;
|
||||
continue;
|
||||
}
|
||||
|
||||
while ( isspace( c[ 0 ] ) ) c++;
|
||||
if ( c[ 0 ] == '\0' ) {
|
||||
Debug( LDAP_DEBUG_ANY, "str2result (%s) missing or empty value\n",
|
||||
s, 0, 0 );
|
||||
rc = -1;
|
||||
continue;
|
||||
}
|
||||
|
||||
retcode = strtol( c, &next, 10 );
|
||||
if ( next == NULL || next == c ) {
|
||||
Debug( LDAP_DEBUG_ANY, "str2result (%s) unable to parse value\n",
|
||||
s, 0, 0 );
|
||||
rc = -1;
|
||||
continue;
|
||||
}
|
||||
|
||||
while ( isspace( next[ 0 ] ) ) next++;
|
||||
if ( next[ 0 ] != '\0' ) {
|
||||
Debug( LDAP_DEBUG_ANY, "str2result (%s) extra cruft after value\n",
|
||||
s, 0, 0 );
|
||||
rc = -1;
|
||||
continue;
|
||||
}
|
||||
|
||||
/* FIXME: what if it's larger that max int? */
|
||||
*code = (int)retcode;
|
||||
|
||||
} else if ( strncasecmp( s, "matched", STRLENOF( "matched" ) ) == 0 ) {
|
||||
if ( c != NULL ) {
|
||||
*matched = c;
|
||||
|
|
|
|||
Loading…
Reference in a new issue