From c109a70531de72eef30a695248b91704bd0c7c24 Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Wed, 30 Mar 2011 13:08:31 -0700 Subject: Fix convert_string() to take a *converted_size arg. and return a bool. Makes these interfaces much harder to misuse and easier to ensure error checking. Autobuild-User: Jeremy Allison Autobuild-Date: Wed Mar 30 23:59:37 CEST 2011 on sn-devel-104 --- lib/tdr/tdr.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'lib/tdr') diff --git a/lib/tdr/tdr.c b/lib/tdr/tdr.c index 8ce238bf8b..616cc987a9 100644 --- a/lib/tdr/tdr.c +++ b/lib/tdr/tdr.c @@ -174,7 +174,8 @@ NTSTATUS tdr_pull_charset(struct tdr_pull *tdr, TALLOC_CTX *ctx, const char **v, NTSTATUS tdr_push_charset(struct tdr_push *tdr, const char **v, uint32_t length, uint32_t el_size, charset_t chset) { - size_t ret, required; + size_t required, size = 0; + bool ret; if (length == -1) { length = strlen(*v) + 1; /* Extra element for null character */ @@ -183,14 +184,14 @@ NTSTATUS tdr_push_charset(struct tdr_push *tdr, const char **v, uint32_t length, required = el_size * length; TDR_PUSH_NEED_BYTES(tdr, required); - ret = convert_string(CH_UNIX, chset, *v, strlen(*v), tdr->data.data+tdr->data.length, required); - if (ret == -1) { + ret = convert_string(CH_UNIX, chset, *v, strlen(*v), tdr->data.data+tdr->data.length, required, &size); + if (ret == false) { return NT_STATUS_INVALID_PARAMETER; } /* Make sure the remaining part of the string is filled with zeroes */ - if (ret < required) { - memset(tdr->data.data+tdr->data.length+ret, 0, required-ret); + if (size < required) { + memset(tdr->data.data+tdr->data.length+size, 0, required-size); } tdr->data.length += required; -- cgit