]> git.sur5r.net Git - openldap/commitdiff
Add LDAP_MAXINT macro
authorKurt Zeilenga <kurt@openldap.org>
Fri, 18 Jun 2004 20:14:28 +0000 (20:14 +0000)
committerKurt Zeilenga <kurt@openldap.org>
Fri, 18 Jun 2004 20:14:28 +0000 (20:14 +0000)
Add additional error checks
Fix a few typos and cleanup

clients/tools/ldapsearch.c
include/ldap.h

index 071da080476c184de87048da1246d55dddc6abaf..d1ec9dc0c0a60ae86c19db54818c3b29ef848c75 100644 (file)
@@ -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;
index 6d10d417a122909c4562d0698937a19ca874549a..08e6abf2de4d4841f722fd7749a46ef061c24a60 100644 (file)
@@ -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