Issue 399 - ldap_search_ext parameter checking problem
Summary: ldap_search_ext parameter checking problem
Status: VERIFIED FIXED
Alias: None
Product: OpenLDAP
Classification: Unclassified
Component: slapd (show other issues)
Version: unspecified
Hardware: All All
: --- normal
Target Milestone: ---
Assignee: OpenLDAP project
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 1999-12-15 16:22 UTC by Steve Sonntag
Modified: 2014-08-01 21:06 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Steve Sonntag 1999-12-15 16:22:22 UTC
Full_Name: Steven F. Sonntag
Version: development
OS: WinNT
URL: ftp://ftp.openldap.org/incoming/
Submission from: (NULL) (137.65.214.133)


libraries/libldap/search.c v1.31

ldap_search_ext does not check parameters correctly

I changed it to do the following: 
   Return LDAP_PARAM_ERROR when tv_sec and tv_usec are both zero
   Use timeout of 1 second when tv_sec==0 and tv_usec!=0

Diff -u follows:

--- ldap/libraries/libldap/search.c	Wed Sep 08 18:06:30 1999
+++ search.c	Tue Dec 14 23:45:55 1999
@@ -98,12 +98,23 @@
 	Debug( LDAP_DEBUG_TRACE, "ldap_search_ext\n", 0, 0, 0 );
 
 	/*
 	 * if timeout is provided, use only tv_sec as timelimit.
+	 * if both timevals are zero return LDAP_PARAM_ERROR.
+	 * if only tv_usec is provided, use value of 1 second.
-	 * otherwise, use default.
 	 */
-	timelimit = (timeout != NULL)
-			?  timeout->tv_sec
-			: -1;
+
+	if( timeout == NULL ) {
+		timelimit = -1;	/* infinite */
+	} else {
+		if( (timeout->tv_sec == 0) && (timeout->tv_usec == 0)) { 
+			return LDAP_PARAM_ERROR;
+		}
+		if( timeout->tv_sec == 0) {
+			timelimit = 1;
+		} else {
+			timelimit = timeout->tv_sec;
+		}
+	}
 
 	ber = ldap_build_search_req( ld, base, scope, filter, attrs,
 	    attrsonly, sctrls, cctrls, timelimit, sizelimit ); 


Comment 1 Kurt Zeilenga 1999-12-15 23:36:29 UTC
Applied patch based on your suggestion.  Please test.

At 04:22 PM 12/15/99 GMT, vtag@novell.com wrote:
>Full_Name: Steven F. Sonntag
>Version: development
>OS: WinNT
>URL: ftp://ftp.openldap.org/incoming/
>Submission from: (NULL) (137.65.214.133)
>
>
>libraries/libldap/search.c v1.31
>
>ldap_search_ext does not check parameters correctly
>
>I changed it to do the following: 
>   Return LDAP_PARAM_ERROR when tv_sec and tv_usec are both zero
>   Use timeout of 1 second when tv_sec==0 and tv_usec!=0
>
>Diff -u follows:
>
>--- ldap/libraries/libldap/search.c	Wed Sep 08 18:06:30 1999
>+++ search.c	Tue Dec 14 23:45:55 1999
>@@ -98,12 +98,23 @@
> 	Debug( LDAP_DEBUG_TRACE, "ldap_search_ext\n", 0, 0, 0 );
> 
> 	/*
> 	 * if timeout is provided, use only tv_sec as timelimit.
>+	 * if both timevals are zero return LDAP_PARAM_ERROR.
>+	 * if only tv_usec is provided, use value of 1 second.
>-	 * otherwise, use default.
> 	 */
>-	timelimit = (timeout != NULL)
>-			?  timeout->tv_sec
>-			: -1;
>+
>+	if( timeout == NULL ) {
>+		timelimit = -1;	/* infinite */
>+	} else {
>+		if( (timeout->tv_sec == 0) && (timeout->tv_usec == 0)) { 
>+			return LDAP_PARAM_ERROR;
>+		}
>+		if( timeout->tv_sec == 0) {
>+			timelimit = 1;
>+		} else {
>+			timelimit = timeout->tv_sec;
>+		}
>+	}
> 
> 	ber = ldap_build_search_req( ld, base, scope, filter, attrs,
> 	    attrsonly, sctrls, cctrls, timelimit, sizelimit ); 
>
>
>
>
Comment 2 Kurt Zeilenga 1999-12-16 00:12:20 UTC
changed notes
changed state Open to Test
Comment 3 Kurt Zeilenga 1999-12-16 00:12:50 UTC
moved from Incoming to Software Bugs
Comment 4 Kurt Zeilenga 1999-12-24 17:28:57 UTC
changed notes
changed state Test to Closed
Comment 5 OpenLDAP project 2014-08-01 21:06:53 UTC
devel issue
resolved.