Commit 124e90d9 authored by Alex Henrie's avatar Alex Henrie Committed by Alexandre Julliard

wldap32: Handle null DN or null message in ldap_delete* and add tests.

parent 4eff0667
......@@ -72,7 +72,7 @@ ULONG CDECL ldap_delete_extA( LDAP *ld, char *dn, LDAPControlA **serverctrls, LD
TRACE( "(%p, %s, %p, %p, %p)\n", ld, debugstr_a(dn), serverctrls, clientctrls, message );
if (!ld) return WLDAP32_LDAP_PARAM_ERROR;
if (!ld || !message) return WLDAP32_LDAP_PARAM_ERROR;
if (dn && !(dnW = strAtoW( dn ))) goto exit;
if (serverctrls && !(serverctrlsW = controlarrayAtoW( serverctrls ))) goto exit;
......@@ -99,9 +99,9 @@ ULONG CDECL ldap_delete_extW( LDAP *ld, WCHAR *dn, LDAPControlW **serverctrls, L
TRACE( "(%p, %s, %p, %p, %p)\n", ld, debugstr_w(dn), serverctrls, clientctrls, message );
if (!ld) return WLDAP32_LDAP_PARAM_ERROR;
if (!ld || !message) return WLDAP32_LDAP_PARAM_ERROR;
if (dn && !(dnU = strWtoU( dn ))) goto exit;
if (!(dnU = dn ? strWtoU( dn ) : strdup( "" ))) goto exit;
if (serverctrls && !(serverctrlsU = controlarrayWtoU( serverctrls ))) goto exit;
if (clientctrls && !(clientctrlsU = controlarrayWtoU( clientctrls ))) goto exit;
else
......@@ -155,7 +155,7 @@ ULONG CDECL ldap_delete_ext_sW( LDAP *ld, WCHAR *dn, LDAPControlW **serverctrls,
if (!ld) return WLDAP32_LDAP_PARAM_ERROR;
if (dn && !(dnU = strWtoU( dn ))) goto exit;
if (!(dnU = dn ? strWtoU( dn ) : strdup( "" ))) goto exit;
if (serverctrls && !(serverctrlsU = controlarrayWtoU( serverctrls ))) goto exit;
if (clientctrls && !(clientctrlsU = controlarrayWtoU( clientctrls ))) goto exit;
else
......
......@@ -349,6 +349,33 @@ static void test_ldap_compare( LDAP *ld )
ok( ret == LDAP_UNDEFINED_TYPE, "ldap_compare_ext_sA should fail, got %#lx\n", ret );
}
static void test_ldap_delete( LDAP *ld )
{
ULONG ret, num;
ret = ldap_deleteA( NULL, NULL );
ok( ret == (ULONG)-1, "ldap_deleteA should fail, got %#lx\n", ret );
ret = ldap_deleteA( NULL, (char *)"" );
ok( ret == (ULONG)-1, "ldap_deleteA should fail, got %#lx\n", ret );
ret = ldap_delete_sA( NULL, NULL );
ok( ret == LDAP_PARAM_ERROR, "ldap_delete_sA should fail, got %#lx\n", ret );
ret = ldap_delete_sA( NULL, (char *)"" );
ok( ret == LDAP_PARAM_ERROR, "ldap_delete_sA should fail, got %#lx\n", ret );
ret = ldap_delete_extA( NULL, NULL, NULL, NULL, NULL );
ok( ret == LDAP_PARAM_ERROR, "ldap_delete_extA should fail, got %#lx\n", ret );
ret = ldap_delete_extA( NULL, (char *)"", NULL, NULL, &num );
ok( ret == LDAP_PARAM_ERROR, "ldap_delete_extA should fail, got %#lx\n", ret );
ret = ldap_delete_extA( ld, (char *)"", NULL, NULL, NULL );
ok( ret == LDAP_PARAM_ERROR, "ldap_delete_extA should fail, got %#lx\n", ret );
ret = ldap_delete_ext_sA( NULL, NULL, NULL, NULL );
ok( ret == LDAP_PARAM_ERROR, "ldap_delete_ext_sA should fail, got %#lx\n", ret );
ret = ldap_delete_ext_sA( NULL, (char *)"", NULL, NULL );
ok( ret == LDAP_PARAM_ERROR, "ldap_delete_ext_sA should fail, got %#lx\n", ret );
}
static void test_ldap_server_control( void )
{
/* SEQUENCE { INTEGER :: 0x07 } */
......@@ -478,6 +505,7 @@ START_TEST (parse)
test_ldap_add( ld );
test_ldap_modify( ld );
test_ldap_compare( ld );
test_ldap_delete( ld );
test_ldap_parse_sort_control( ld );
test_ldap_search_extW( ld );
test_ldap_get_optionW( ld );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment