]> git.sur5r.net Git - openldap/commitdiff
Fix crasher if paged results size is not specified
authorLuke Howard <lukeh@openldap.org>
Fri, 27 Feb 2004 09:32:16 +0000 (09:32 +0000)
committerLuke Howard <lukeh@openldap.org>
Fri, 27 Feb 2004 09:32:16 +0000 (09:32 +0000)
clients/tools/ldapsearch.c

index 7d9a453bafd6c02531ab57fb339fca5c4f9eae8c..c5357c95a0aa291ba8f65ee54f0710916301faa7 100644 (file)
@@ -302,12 +302,16 @@ handle_private_option( int i )
                                fprintf( stderr, _("PagedResultsControl previously specified\n") );
                                exit( EXIT_FAILURE );
                        }
-                       
-                       num = sscanf( cvalue, "%d", &tmp );
-                       if ( num != 1 ) {
-                               fprintf( stderr, _("Invalid value for PagedResultsControl, %s.\n"), cvalue);
-                               exit( EXIT_FAILURE );
 
+                       if( cvalue != NULL ) {
+                               num = sscanf( cvalue, "%d", &tmp );
+                               if ( num != 1 ) {
+                                       fprintf( stderr, _("Invalid value for PagedResultsControl, %s.\n"), cvalue);
+                                       exit( EXIT_FAILURE );
+                               }
+                       } else {
+                               fprintf( stderr, _("Invalid value for PagedResultsControl.\n"), cvalue);
+                               exit( EXIT_FAILURE );
                        }
                        pageSize = (ber_int_t) tmp;
                        pagedResults = 1 + crit;