mirror of
https://github.com/samba-team/samba.git
synced 2024-12-23 17:34:34 +03:00
r25214: use talloc_strndup_append() instead of talloc_append_string()
and ugly hacks to handle the string termination.
metze
(This used to be commit 32bb276920
)
This commit is contained in:
parent
68256289a4
commit
df7fbf8cfd
@ -132,27 +132,11 @@ static void *append_string(void *ctx,
|
||||
char *append,
|
||||
int size)
|
||||
{
|
||||
char c;
|
||||
char *end_p = append + size;
|
||||
void *ret;
|
||||
if (!orig) {
|
||||
return talloc_strndup(ctx, append, size);
|
||||
}
|
||||
|
||||
/*
|
||||
* We need to null terminate the string to be copied. Save character at
|
||||
* the size limit of the source string.
|
||||
*/
|
||||
c = *end_p;
|
||||
|
||||
/* Temporarily null-terminate it */
|
||||
*end_p = '\0';
|
||||
|
||||
/* Append the requested data */
|
||||
ret = talloc_append_string(ctx, orig, append);
|
||||
|
||||
/* Restore the original character in place of our temporary null byte */
|
||||
*end_p = c;
|
||||
|
||||
/* Give 'em what they came for */
|
||||
return ret;
|
||||
return talloc_strndup_append(orig, append, size);
|
||||
}
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user