Skip to content

Commit

Permalink
ldb: Explain why this use of talloc_memdup() is safe
Browse files Browse the repository at this point in the history
Signed-off-by: Andrew Bartlett <[email protected]>
Reviewed-by: Jelmer Vernooij <[email protected]>
  • Loading branch information
abartlet committed Jan 5, 2016
1 parent 084bab5 commit 30e92d0
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions lib/ldb/common/ldb_dn.c
Original file line number Diff line number Diff line change
Expand Up @@ -586,6 +586,12 @@ static bool ldb_dn_explode(struct ldb_dn *dn)

p++;
*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.data = \
(uint8_t *)talloc_memdup(dn->components, dt, l + 1);
dn->components[dn->comp_num].value.length = l;
Expand Down Expand Up @@ -708,6 +714,11 @@ static bool ldb_dn_explode(struct ldb_dn *dn)
}

*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);
Expand Down

0 comments on commit 30e92d0

Please sign in to comment.