wldap32: Fix parsing page controls.

Signed-off-by: Hans Leidekker <hans@codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard@winehq.org>
This commit is contained in:
Hans Leidekker 2021-04-20 11:42:19 +02:00 committed by Alexandre Julliard
parent 7394483c62
commit fb44267803
1 changed files with 14 additions and 14 deletions

View File

@ -20,6 +20,7 @@
#include <stdarg.h> #include <stdarg.h>
#include <stdlib.h> #include <stdlib.h>
#include <limits.h>
#include "windef.h" #include "windef.h"
#include "winbase.h" #include "winbase.h"
#include "winnls.h" #include "winnls.h"
@ -31,8 +32,6 @@
WINE_DEFAULT_DEBUG_CHANNEL(wldap32); WINE_DEFAULT_DEBUG_CHANNEL(wldap32);
#define LDAP_MAXINT (2^31)
static struct berval null_cookieW = { 0, NULL }; static struct berval null_cookieW = { 0, NULL };
/*********************************************************************** /***********************************************************************
@ -48,7 +47,7 @@ ULONG CDECL ldap_create_page_controlA( LDAP *ld, ULONG pagesize, struct berval *
TRACE( "(%p, 0x%08x, %p, 0x%02x, %p)\n", ld, pagesize, cookie, critical, control ); TRACE( "(%p, 0x%08x, %p, 0x%02x, %p)\n", ld, pagesize, cookie, critical, control );
if (!ld || !control || pagesize > LDAP_MAXINT) return LDAP_PARAM_ERROR; if (!ld || !control || pagesize > INT_MAX) return LDAP_PARAM_ERROR;
ret = ldap_create_page_controlW( ld, pagesize, cookie, critical, &controlW ); ret = ldap_create_page_controlW( ld, pagesize, cookie, critical, &controlW );
if (ret == LDAP_SUCCESS) if (ret == LDAP_SUCCESS)
@ -131,7 +130,7 @@ ULONG CDECL ldap_create_page_controlW( LDAP *ld, ULONG pagesize, struct berval *
{ {
TRACE( "(%p, 0x%08x, %p, 0x%02x, %p)\n", ld, pagesize, cookie, critical, control ); TRACE( "(%p, 0x%08x, %p, 0x%02x, %p)\n", ld, pagesize, cookie, critical, control );
if (!ld || !control || pagesize > LDAP_MAXINT) return LDAP_PARAM_ERROR; if (!ld || !control || pagesize > INT_MAX) return LDAP_PARAM_ERROR;
return create_page_control( pagesize, cookie, critical, control ); return create_page_control( pagesize, cookie, critical, control );
} }
@ -230,18 +229,18 @@ ULONG CDECL ldap_parse_page_controlA( LDAP *ld, LDAPControlA **ctrls, ULONG *cou
/*********************************************************************** /***********************************************************************
* ldap_parse_page_controlW (WLDAP32.@) * ldap_parse_page_controlW (WLDAP32.@)
*/ */
ULONG CDECL ldap_parse_page_controlW( LDAP *ld, LDAPControlW **ctrls, ULONG *count, struct berval **cookie ) ULONG CDECL ldap_parse_page_controlW( LDAP *ld, LDAPControlW **ctrls, ULONG *ret_count, struct berval **ret_cookie )
{ {
ULONG ret; ULONG ret, count;
LDAPControlW *control = NULL; LDAPControlW *control = NULL;
BerElement *ber; BerElement *ber;
struct berval *vec[2]; struct berval *cookie = NULL;
int tag; int tag;
ULONG i; ULONG i;
TRACE( "(%p, %p, %p, %p)\n", ld, ctrls, count, cookie ); TRACE( "(%p, %p, %p, %p)\n", ld, ctrls, ret_count, ret_cookie );
if (!ld || !ctrls || !count || !cookie) return LDAP_PARAM_ERROR; if (!ld || !ctrls || !ret_count || !ret_cookie) return LDAP_PARAM_ERROR;
for (i = 0; ctrls[i]; i++) for (i = 0; ctrls[i]; i++)
{ {
@ -252,13 +251,14 @@ ULONG CDECL ldap_parse_page_controlW( LDAP *ld, LDAPControlW **ctrls, ULONG *cou
if (!(ber = ber_init( &control->ldctl_value ))) return LDAP_NO_MEMORY; if (!(ber = ber_init( &control->ldctl_value ))) return LDAP_NO_MEMORY;
vec[0] = *cookie; tag = ber_scanf( ber, (char *)"{iO}", &count, &cookie );
vec[1] = 0; if (tag == LBER_ERROR) ret = LDAP_DECODING_ERROR;
tag = ber_scanf( ber, (char *)"{iV}", count, vec );
if (tag == LBER_ERROR)
ret = LDAP_DECODING_ERROR;
else else
{
*ret_count = count;
*ret_cookie = cookie;
ret = LDAP_SUCCESS; ret = LDAP_SUCCESS;
}
ber_free( ber, 1 ); ber_free( ber, 1 );
return ret; return ret;