From: Kurt Zeilenga Date: Fri, 18 Jun 2004 20:14:28 +0000 (+0000) Subject: Add LDAP_MAXINT macro X-Git-Tag: OPENDLAP_REL_ENG_2_2_MP~243 X-Git-Url: https://git.sur5r.net/?a=commitdiff_plain;h=0b3f8c23039baee675781b312925a5ad224607e0;p=openldap Add LDAP_MAXINT macro Add additional error checks Fix a few typos and cleanup --- diff --git a/clients/tools/ldapsearch.c b/clients/tools/ldapsearch.c index 071da08047..d1ec9dc0c0 100644 --- a/clients/tools/ldapsearch.c +++ b/clients/tools/ldapsearch.c @@ -438,20 +438,18 @@ handle_private_option( int i ) timelimit = 0; } else if ( strcasecmp( optarg, "max" ) == 0 ) { - /* RFC 2251: - maxInt INTEGER ::= 2147483647 -- (2^^31 - 1) -- - */ - timelimit = 2147483647; + timelimit = LDAP_MAXINT; } else { ival = strtol( optarg, &next, 10 ); if ( next == NULL || next[0] != '\0' ) { - fprintf( stderr, _("Unable to parse time limit \"%s\"\n"), optarg ); + fprintf( stderr, + _("Unable to parse time limit \"%s\"\n"), optarg ); exit( EXIT_FAILURE ); } timelimit = ival; } - if( timelimit < 0 ) { + if( timelimit < 0 || timelimit > LDAP_MAXINT ) { fprintf( stderr, _("%s: invalid timelimit (%d) specified\n"), prog, timelimit ); exit( EXIT_FAILURE ); @@ -496,22 +494,20 @@ handle_private_option( int i ) sizelimit = 0; } else if ( strcasecmp( optarg, "max" ) == 0 ) { - /* RFC 2251: - maxInt INTEGER ::= 2147483647 -- (2^^31 - 1) -- - */ - sizelimit = 2147483647; + sizelimit = LDAP_MAXINT; } else { ival = strtol( optarg, &next, 10 ); if ( next == NULL || next[0] != '\0' ) { - fprintf( stderr, _("Unable to parse size limit \"%s\"\n"), optarg ); + fprintf( stderr, + _("Unable to parse size limit \"%s\"\n"), optarg ); exit( EXIT_FAILURE ); } sizelimit = ival; } - if( sizelimit < 0 ) { + if( sizelimit < 0 || sizelimit > LDAP_MAXINT ) { fprintf( stderr, _("%s: invalid sizelimit (%d) specified\n"), - prog, timelimit ); + prog, sizelimit ); exit( EXIT_FAILURE ); } break; diff --git a/include/ldap.h b/include/ldap.h index 6d10d417a1..08e6abf2de 100644 --- a/include/ldap.h +++ b/include/ldap.h @@ -76,6 +76,9 @@ LDAP_BEGIN_DECL #define LDAP_ALL_USER_ATTRIBUTES "*" #define LDAP_ALL_OPERATIONAL_ATTRIBUTES "+" /* RFC 3673 */ +/* RFC 2251: maxInt INTEGER ::= 2147483647 -- (2^^31 - 1) -- */ +#define LDAP_MAXINT (2147483647) + /* * LDAP_OPTions * 0x0000 - 0x0fff reserved for api options