diff options
author | Douglas Bagnall <douglas.bagnall@catalyst.net.nz> | 2019-07-26 09:49:13 +1200 |
---|---|---|
committer | Karolin Seeger <kseeger@samba.org> | 2019-09-04 08:31:24 +0000 |
commit | c71c51dda004a617eaeccb0819b70310de1ebd14 (patch) | |
tree | 121421713da4eb5707b8f36a03325c7dc3c776f3 /lib | |
parent | 61a039cc21d845bb4b984929d878dd8cf68839fe (diff) | |
download | samba-c71c51dda004a617eaeccb0819b70310de1ebd14.tar.gz |
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>
(cherry picked from commit 54f30f2fe3f03c9640664f9a11260b093fc57a5b)
Diffstat (limited to 'lib')
-rw-r--r-- | lib/ldb/common/ldb_dn.c | 47 |
1 files changed, 24 insertions, 23 deletions
diff --git a/lib/ldb/common/ldb_dn.c b/lib/ldb/common/ldb_dn.c index 9b2fa966e11..a7fb0d9c443 100644 --- a/lib/ldb/common/ldb_dn.c +++ b/lib/ldb/common/ldb_dn.c @@ -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); - *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; + dn->comp_num++; } - 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; |