summaryrefslogtreecommitdiff
path: root/source3/lib
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2007-09-11 23:57:59 +0000
committerGerald (Jerry) Carter <jerry@samba.org>2007-10-10 12:30:41 -0500
commit3a9d3821649c9ea88a6cd424f0838a453165a00a (patch)
tree4b4f61570a20e0a252436ebd88b1d0dee58c704e /source3/lib
parent1ef2464451ee64023173637fa03e703405dc8c85 (diff)
downloadsamba-3a9d3821649c9ea88a6cd424f0838a453165a00a.tar.gz
samba-3a9d3821649c9ea88a6cd424f0838a453165a00a.tar.bz2
samba-3a9d3821649c9ea88a6cd424f0838a453165a00a.zip
r25111: Move to talloced pathnames on most code paths.
There are now ony 17 pstrings left in reply.c, and these will be easy to remove (and I'll be doing that shortly). Had to fix an interesting bug in pull_ucs2_base_talloc() when a source string is not null terminated :-). Jeremy. (This used to be commit 0c9a8c4dff10974dbffd2a302ae982896122fcc0)
Diffstat (limited to 'source3/lib')
-rw-r--r--source3/lib/charcnv.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/source3/lib/charcnv.c b/source3/lib/charcnv.c
index dd03a56233..4e3b7cba62 100644
--- a/source3/lib/charcnv.c
+++ b/source3/lib/charcnv.c
@@ -1460,7 +1460,21 @@ static size_t pull_ucs2_base_talloc(TALLOC_CTX *ctx,
if (dest_len) {
/* Did we already process the terminating zero ? */
if (dest[dest_len-1] != 0) {
- dest[dest_len-1] = 0;
+ size_t size = talloc_get_size(dest);
+ /* Have we got space to append the '\0' ? */
+ if (size <= dest_len) {
+ /* No, realloc. */
+ dest = TALLOC_REALLOC(ctx, dest,
+ dest_len+1);
+ if (!dest) {
+ /* talloc fail. */
+ dest_len = (size_t)-1;
+ return 0;
+ }
+ }
+ /* Yay - space ! */
+ dest[dest_len] = '\0';
+ dest_len++;
}
} else if (dest) {
dest[0] = 0;