diff options
author | Jeremy Allison <jra@samba.org> | 2011-03-30 13:08:31 -0700 |
---|---|---|
committer | Jeremy Allison <jra@samba.org> | 2011-03-30 23:59:37 +0200 |
commit | c109a70531de72eef30a695248b91704bd0c7c24 (patch) | |
tree | 29182afa1ae334e8aee0e71e59aa1a0e5de65f6a /librpc | |
parent | 9ede19fdccaf09303012208129a093197403ef2c (diff) | |
download | samba-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 'librpc')
-rw-r--r-- | librpc/ndr/ndr_string.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/librpc/ndr/ndr_string.c b/librpc/ndr/ndr_string.c index 9cc26dacc5..6e20333f04 100644 --- a/librpc/ndr/ndr_string.c +++ b/librpc/ndr/ndr_string.c @@ -696,7 +696,7 @@ _PUBLIC_ enum ndr_err_code ndr_pull_charset(struct ndr_pull *ndr, int ndr_flags, _PUBLIC_ enum ndr_err_code ndr_push_charset(struct ndr_push *ndr, int ndr_flags, const char *var, uint32_t length, uint8_t byte_mul, charset_t chset) { - ssize_t ret, required; + ssize_t required; if (NDR_BE(ndr) && chset == CH_UTF16) { chset = CH_UTF16BE; @@ -707,17 +707,17 @@ _PUBLIC_ enum ndr_err_code ndr_push_charset(struct ndr_push *ndr, int ndr_flags, NDR_PUSH_NEED_BYTES(ndr, required); if (required) { - ret = convert_string(CH_UNIX, chset, + size_t size = 0; + if (!convert_string(CH_UNIX, chset, var, strlen(var), - ndr->data+ndr->offset, required); - if (ret == -1) { + ndr->data+ndr->offset, required, &size)) { return ndr_push_error(ndr, NDR_ERR_CHARCNV, "Bad character conversion"); } /* Make sure the remaining part of the string is filled with zeroes */ - if (ret < required) { - memset(ndr->data+ndr->offset+ret, 0, required-ret); + if (size < required) { + memset(ndr->data+ndr->offset+size, 0, required-size); } } |