From df7fbf8cfdcf679d2dd48818176068dd9ad97ab6 Mon Sep 17 00:00:00 2001 From: Stefan Metzmacher Date: Tue, 18 Sep 2007 13:33:44 +0000 Subject: 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) --- source4/scripting/ejs/literal.c | 24 ++++-------------------- 1 file changed, 4 insertions(+), 20 deletions(-) (limited to 'source4/scripting') 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); } -- cgit