summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2007-09-18 13:33:44 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 15:06:55 -0500
commitdf7fbf8cfdcf679d2dd48818176068dd9ad97ab6 (patch)
treeb047750641a30fd1f050c0a362bed9f3b5b7d752
parent68256289a4a9326544748fb21ea1a2b018e6711d (diff)
downloadsamba-df7fbf8cfdcf679d2dd48818176068dd9ad97ab6.tar.gz
samba-df7fbf8cfdcf679d2dd48818176068dd9ad97ab6.tar.bz2
samba-df7fbf8cfdcf679d2dd48818176068dd9ad97ab6.zip
r25214: use talloc_strndup_append() instead of talloc_append_string()
and ugly hacks to handle the string termination. metze (This used to be commit 32bb276920d3f6987427613c6f1bc71557d8893e)
-rw-r--r--source4/scripting/ejs/literal.c24
1 files changed, 4 insertions, 20 deletions
diff --git a/source4/scripting/ejs/literal.c b/source4/scripting/ejs/literal.c
index d50e5afdb9..8307c211d3 100644
--- a/source4/scripting/ejs/literal.c
+++ b/source4/scripting/ejs/literal.c
@@ -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);
}