summaryrefslogtreecommitdiff
path: root/lib/tdr
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2011-03-30 13:08:31 -0700
committerJeremy Allison <jra@samba.org>2011-03-30 23:59:37 +0200
commitc109a70531de72eef30a695248b91704bd0c7c24 (patch)
tree29182afa1ae334e8aee0e71e59aa1a0e5de65f6a /lib/tdr
parent9ede19fdccaf09303012208129a093197403ef2c (diff)
downloadsamba-c109a70531de72eef30a695248b91704bd0c7c24.tar.gz
samba-c109a70531de72eef30a695248b91704bd0c7c24.tar.bz2
samba-c109a70531de72eef30a695248b91704bd0c7c24.zip
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 <jra@samba.org> Autobuild-Date: Wed Mar 30 23:59:37 CEST 2011 on sn-devel-104
Diffstat (limited to 'lib/tdr')
-rw-r--r--lib/tdr/tdr.c11
1 files changed, 6 insertions, 5 deletions
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;