X-Git-Url: https://git.sur5r.net/?a=blobdiff_plain;f=servers%2Fslapd%2Fresult.c;h=bb27c760f3638cbc3cd7872e5db45e9fea6d416d;hb=d1824b14ae78b128fb9ff6cf73d2ec4a0e756a90;hp=e412c6169eecf7a9f70113ac3bb33232c846c056;hpb=dfc8e7f6b8de021628046c004995843eaa78e0b7;p=openldap diff --git a/servers/slapd/result.c b/servers/slapd/result.c index e412c6169e..bb27c760f3 100644 --- a/servers/slapd/result.c +++ b/servers/slapd/result.c @@ -36,7 +36,6 @@ #include #include "slap.h" -#include "lutil.h" const struct berval slap_dummy_bv = BER_BVNULL; @@ -1467,9 +1466,43 @@ str2result( } if ( strncasecmp( s, "code", STRLENOF( "code" ) ) == 0 ) { - if ( c != NULL && lutil_atoi( code, c ) != 0 ) { - goto bailout; + 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( (unsigned char) 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( (unsigned char) 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; @@ -1479,7 +1512,6 @@ str2result( *info = c; } } else { -bailout:; Debug( LDAP_DEBUG_ANY, "str2result (%s) unknown\n", s, 0, 0 );