[Date Prev][Date Next] [Chronological] [Thread] [Top]

Re: ldap_search_ext parameter checking problem (ITS#399)



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 ); 
>
>
>
>