mirror of
https://github.com/samba-team/samba.git
synced 2025-01-25 06:04:04 +03:00
dsdb/common: dsdb_dn_construct_internal() more strict checking
Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
This commit is contained in:
parent
8115fb03b6
commit
15f332a1c0
@ -47,18 +47,32 @@ static struct dsdb_dn *dsdb_dn_construct_internal(TALLOC_CTX *mem_ctx,
|
|||||||
enum dsdb_dn_format dn_format,
|
enum dsdb_dn_format dn_format,
|
||||||
const char *oid)
|
const char *oid)
|
||||||
{
|
{
|
||||||
struct dsdb_dn *dsdb_dn = talloc(mem_ctx, struct dsdb_dn);
|
struct dsdb_dn *dsdb_dn = NULL;
|
||||||
|
|
||||||
|
switch (dn_format) {
|
||||||
|
case DSDB_BINARY_DN:
|
||||||
|
case DSDB_STRING_DN:
|
||||||
|
break;
|
||||||
|
case DSDB_NORMAL_DN:
|
||||||
|
if (extra_part.length != 0) {
|
||||||
|
errno = EINVAL;
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case DSDB_INVALID_DN:
|
||||||
|
default:
|
||||||
|
errno = EINVAL;
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
dsdb_dn = talloc(mem_ctx, struct dsdb_dn);
|
||||||
if (!dsdb_dn) {
|
if (!dsdb_dn) {
|
||||||
|
errno = ENOMEM;
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
dsdb_dn->dn = talloc_steal(dsdb_dn, dn);
|
dsdb_dn->dn = talloc_steal(dsdb_dn, dn);
|
||||||
dsdb_dn->extra_part = extra_part;
|
dsdb_dn->extra_part = extra_part;
|
||||||
dsdb_dn->dn_format = dn_format;
|
dsdb_dn->dn_format = dn_format;
|
||||||
/* Look to see if this attributeSyntax is a DN */
|
|
||||||
if (dsdb_dn->dn_format == DSDB_INVALID_DN) {
|
|
||||||
talloc_free(dsdb_dn);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
dsdb_dn->oid = oid;
|
dsdb_dn->oid = oid;
|
||||||
talloc_steal(dsdb_dn, extra_part.data);
|
talloc_steal(dsdb_dn, extra_part.data);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user