1
0
mirror of https://github.com/samba-team/samba.git synced 2025-02-26 21:57:41 +03:00

ldb: don't try to save a value that isn't there

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14049

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Gary Lockyer <gary@catalyst.net.nz>
This commit is contained in:
Douglas Bagnall 2019-07-26 09:49:13 +12:00 committed by Andrew Bartlett
parent 1521a22f43
commit 54f30f2fe3

View File

@ -697,31 +697,32 @@ static bool ldb_dn_explode(struct ldb_dn *dn)
goto failed;
}
/* save last element */
if ( t ) {
/* trim back */
d -= (p - t);
l -= (p - t);
if (in_value) {
/* save last element */
if ( t ) {
/* trim back */
d -= (p - t);
l -= (p - t);
}
*d++ = '\0';
/*
* This talloc_memdup() is OK with the
* +1 because *d has been set to '\0'
* just above.
*/
dn->components[dn->comp_num].value.length = l;
dn->components[dn->comp_num].value.data =
(uint8_t *)talloc_memdup(dn->components, dt, l + 1);
if ( ! dn->components[dn->comp_num].value.data) {
/* ouch */
goto failed;
}
talloc_set_name_const(dn->components[dn->comp_num].value.data,
(const char *)dn->components[dn->comp_num].value.data);
dn->comp_num++;
}
*d++ = '\0';
/*
* This talloc_memdup() is OK with the
* +1 because *d has been set to '\0'
* just above.
*/
dn->components[dn->comp_num].value.length = l;
dn->components[dn->comp_num].value.data =
(uint8_t *)talloc_memdup(dn->components, dt, l + 1);
if ( ! dn->components[dn->comp_num].value.data) {
/* ouch */
goto failed;
}
talloc_set_name_const(dn->components[dn->comp_num].value.data,
(const char *)dn->components[dn->comp_num].value.data);
dn->comp_num++;
talloc_free(data);
return true;