diff options
author | Andrew Tridgell <tridge@samba.org> | 2011-03-24 10:59:41 +1100 |
---|---|---|
committer | Andrew Tridgell <tridge@samba.org> | 2011-03-24 01:47:26 +0100 |
commit | 15e84a9a09c5a86416e964a3258ee35718fbf45a (patch) | |
tree | a3c1d6698668e55b257c96fe2cace1ac7c8edb3a /lib | |
parent | 451856698fc04a9426ec9cb1ec039574f82f56bb (diff) | |
download | samba-15e84a9a09c5a86416e964a3258ee35718fbf45a.tar.gz samba-15e84a9a09c5a86416e964a3258ee35718fbf45a.tar.bz2 samba-15e84a9a09c5a86416e964a3258ee35718fbf45a.zip |
charcnv: removed the allow_badcharcnv and allow_bad_conv options to convert_string*()
we shouldn't accept bad multi-byte strings, it just hides problems
Autobuild-User: Andrew Tridgell <tridge@samba.org>
Autobuild-Date: Thu Mar 24 01:47:26 CET 2011 on sn-devel-104
Diffstat (limited to 'lib')
-rw-r--r-- | lib/tdr/tdr.c | 4 | ||||
-rw-r--r-- | lib/util/charset/charcnv.c | 16 | ||||
-rw-r--r-- | lib/util/charset/charset.h | 16 | ||||
-rw-r--r-- | lib/util/charset/tests/iconv.c | 6 | ||||
-rw-r--r-- | lib/util/charset/util_unistr.c | 42 |
5 files changed, 38 insertions, 46 deletions
diff --git a/lib/tdr/tdr.c b/lib/tdr/tdr.c index ab016d0bc4..8ce238bf8b 100644 --- a/lib/tdr/tdr.c +++ b/lib/tdr/tdr.c @@ -163,7 +163,7 @@ NTSTATUS tdr_pull_charset(struct tdr_pull *tdr, TALLOC_CTX *ctx, const char **v, TDR_PULL_NEED_BYTES(tdr, el_size*length); - if (!convert_string_talloc(ctx, chset, CH_UNIX, tdr->data.data+tdr->offset, el_size*length, discard_const_p(void *, v), &ret, false)) { + if (!convert_string_talloc(ctx, chset, CH_UNIX, tdr->data.data+tdr->offset, el_size*length, discard_const_p(void *, v), &ret)) { return NT_STATUS_INVALID_PARAMETER; } @@ -183,7 +183,7 @@ 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, false); + ret = convert_string(CH_UNIX, chset, *v, strlen(*v), tdr->data.data+tdr->data.length, required); if (ret == -1) { return NT_STATUS_INVALID_PARAMETER; } diff --git a/lib/util/charset/charcnv.c b/lib/util/charset/charcnv.c index 7fed7555c5..1e1f2a350e 100644 --- a/lib/util/charset/charcnv.c +++ b/lib/util/charset/charcnv.c @@ -123,10 +123,9 @@ convert: * @returns the number of bytes occupied in the destination **/ _PUBLIC_ bool convert_string_convenience(struct smb_iconv_convenience *ic, - charset_t from, charset_t to, - void const *src, size_t srclen, - void *dest, size_t destlen, size_t *converted_size, - bool allow_badcharcnv) + charset_t from, charset_t to, + void const *src, size_t srclen, + void *dest, size_t destlen, size_t *converted_size) { size_t i_len, o_len; size_t retval; @@ -191,11 +190,10 @@ _PUBLIC_ bool convert_string_convenience(struct smb_iconv_convenience *ic, **/ _PUBLIC_ bool convert_string_talloc_convenience(TALLOC_CTX *ctx, - struct smb_iconv_convenience *ic, - charset_t from, charset_t to, - void const *src, size_t srclen, - void *dst, size_t *converted_size, - bool allow_badcharcnv) + struct smb_iconv_convenience *ic, + charset_t from, charset_t to, + void const *src, size_t srclen, + void *dst, size_t *converted_size) { void **dest = (void **)dst; smb_iconv_t descriptor; diff --git a/lib/util/charset/charset.h b/lib/util/charset/charset.h index 943bfa4695..494a4ebc1a 100644 --- a/lib/util/charset/charset.h +++ b/lib/util/charset/charset.h @@ -155,14 +155,13 @@ ssize_t push_string(void *dest, const char *src, size_t dest_len, int flags); ssize_t pull_string(char *dest, const void *src, size_t dest_len, size_t src_len, int flags); bool convert_string_talloc(TALLOC_CTX *ctx, - charset_t from, charset_t to, - void const *src, size_t srclen, - void *dest, size_t *converted_size, - bool allow_badcharcnv); + charset_t from, charset_t to, + void const *src, size_t srclen, + void *dest, size_t *converted_size); size_t convert_string(charset_t from, charset_t to, - void const *src, size_t srclen, - void *dest, size_t destlen, bool allow_badcharcnv); + void const *src, size_t srclen, + void *dest, size_t destlen); ssize_t iconv_talloc(TALLOC_CTX *mem_ctx, smb_iconv_t cd, @@ -206,13 +205,12 @@ struct smb_iconv_convenience *smb_iconv_convenience_reinit(TALLOC_CTX *mem_ctx, bool convert_string_convenience(struct smb_iconv_convenience *ic, charset_t from, charset_t to, void const *src, size_t srclen, - void *dest, size_t destlen, size_t *converted_size, - bool allow_badcharcnv); + void *dest, size_t destlen, size_t *converted_size); bool convert_string_talloc_convenience(TALLOC_CTX *ctx, struct smb_iconv_convenience *ic, charset_t from, charset_t to, void const *src, size_t srclen, - void *dest, size_t *converted_size, bool allow_badcharcnv); + void *dest, size_t *converted_size); /* iconv */ smb_iconv_t smb_iconv_open(const char *tocode, const char *fromcode); int smb_iconv_close(smb_iconv_t cd); diff --git a/lib/util/charset/tests/iconv.c b/lib/util/charset/tests/iconv.c index a1a0d97a7e..9b48771b16 100644 --- a/lib/util/charset/tests/iconv.c +++ b/lib/util/charset/tests/iconv.c @@ -419,7 +419,7 @@ static bool test_string2key(struct torture_context *tctx) torture_comment(tctx, "converting random buffer\n"); - if (!convert_string_talloc(mem_ctx, CH_UTF16MUNGED, CH_UTF8, (void *)buf, len*2, (void**)&dest, &ret, false)) { + if (!convert_string_talloc(mem_ctx, CH_UTF16MUNGED, CH_UTF8, (void *)buf, len*2, (void**)&dest, &ret)) { torture_fail(tctx, "Failed to convert random buffer\n"); } @@ -429,7 +429,7 @@ static bool test_string2key(struct torture_context *tctx) torture_comment(tctx, "converting fixed buffer to UTF16\n"); - if (!convert_string_talloc(mem_ctx, CH_UTF16MUNGED, CH_UTF16, (void *)le1, 20, (void**)&munged1, &ret, false)) { + if (!convert_string_talloc(mem_ctx, CH_UTF16MUNGED, CH_UTF16, (void *)le1, 20, (void**)&munged1, &ret)) { torture_fail(tctx, "Failed to convert fixed buffer to UTF16_MUNGED\n"); } @@ -437,7 +437,7 @@ static bool test_string2key(struct torture_context *tctx) torture_comment(tctx, "converting fixed buffer to UTF8\n"); - if (!convert_string_talloc(mem_ctx, CH_UTF16MUNGED, CH_UTF8, (void *)le1, 20, (void**)&out1, &ret, false)) { + if (!convert_string_talloc(mem_ctx, CH_UTF16MUNGED, CH_UTF8, (void *)le1, 20, (void**)&out1, &ret)) { torture_fail(tctx, "Failed to convert fixed buffer to UTF8\n"); } diff --git a/lib/util/charset/util_unistr.c b/lib/util/charset/util_unistr.c index ad2ba687f4..c59620ed32 100644 --- a/lib/util/charset/util_unistr.c +++ b/lib/util/charset/util_unistr.c @@ -370,7 +370,7 @@ static ssize_t push_ascii(void *dest, const char *src, size_t dest_len, int flag if (flags & (STR_TERMINATE | STR_TERMINATE_ASCII)) src_len++; - return convert_string(CH_UNIX, CH_DOS, src, src_len, dest, dest_len, false); + return convert_string(CH_UNIX, CH_DOS, src, src_len, dest, dest_len); } /** @@ -386,7 +386,7 @@ _PUBLIC_ bool push_ascii_talloc(TALLOC_CTX *ctx, char **dest, const char *src, s { size_t src_len = strlen(src)+1; *dest = NULL; - return convert_string_talloc(ctx, CH_UNIX, CH_DOS, src, src_len, (void **)dest, converted_size, false); + return convert_string_talloc(ctx, CH_UNIX, CH_DOS, src, src_len, (void **)dest, converted_size); } @@ -420,7 +420,7 @@ static ssize_t pull_ascii(char *dest, const void *src, size_t dest_len, size_t s } } - ret = convert_string(CH_DOS, CH_UNIX, src, src_len, dest, dest_len, false); + ret = convert_string(CH_DOS, CH_UNIX, src, src_len, dest, dest_len); if (dest_len) dest[MIN(ret, dest_len-1)] = 0; @@ -473,7 +473,7 @@ static ssize_t push_ucs2(void *dest, const char *src, size_t dest_len, int flags /* ucs2 is always a multiple of 2 bytes */ dest_len &= ~1; - ret = convert_string(CH_UNIX, CH_UTF16, src, src_len, dest, dest_len, false); + ret = convert_string(CH_UNIX, CH_UTF16, src, src_len, dest, dest_len); if (ret == (size_t)-1) { return 0; } @@ -497,7 +497,7 @@ _PUBLIC_ bool push_ucs2_talloc(TALLOC_CTX *ctx, smb_ucs2_t **dest, const char *s { size_t src_len = strlen(src)+1; *dest = NULL; - return convert_string_talloc(ctx, CH_UNIX, CH_UTF16, src, src_len, (void **)dest, converted_size, false); + return convert_string_talloc(ctx, CH_UNIX, CH_UTF16, src, src_len, (void **)dest, converted_size); } @@ -513,7 +513,7 @@ _PUBLIC_ bool push_utf8_talloc(TALLOC_CTX *ctx, char **dest, const char *src, si { size_t src_len = strlen(src)+1; *dest = NULL; - return convert_string_talloc(ctx, CH_UNIX, CH_UTF8, src, src_len, (void **)dest, converted_size, false); + return convert_string_talloc(ctx, CH_UNIX, CH_UTF8, src, src_len, (void **)dest, converted_size); } /** @@ -549,7 +549,7 @@ static size_t pull_ucs2(char *dest, const void *src, size_t dest_len, size_t src if (src_len != (size_t)-1) src_len &= ~1; - ret = convert_string(CH_UTF16, CH_UNIX, src, src_len, dest, dest_len, false); + ret = convert_string(CH_UTF16, CH_UNIX, src, src_len, dest, dest_len); if (dest_len) dest[MIN(ret, dest_len-1)] = 0; @@ -568,7 +568,7 @@ _PUBLIC_ bool pull_ascii_talloc(TALLOC_CTX *ctx, char **dest, const char *src, s { size_t src_len = strlen(src)+1; *dest = NULL; - return convert_string_talloc(ctx, CH_DOS, CH_UNIX, src, src_len, (void **)dest, converted_size, false); + return convert_string_talloc(ctx, CH_DOS, CH_UNIX, src, src_len, (void **)dest, converted_size); } /** @@ -583,7 +583,7 @@ _PUBLIC_ bool pull_ucs2_talloc(TALLOC_CTX *ctx, char **dest, const smb_ucs2_t *s { size_t src_len = utf16_len(src); *dest = NULL; - return convert_string_talloc(ctx, CH_UTF16, CH_UNIX, src, src_len, (void **)dest, converted_size, false); + return convert_string_talloc(ctx, CH_UTF16, CH_UNIX, src, src_len, (void **)dest, converted_size); } /** @@ -598,7 +598,7 @@ _PUBLIC_ bool pull_utf8_talloc(TALLOC_CTX *ctx, char **dest, const char *src, si { size_t src_len = strlen(src)+1; *dest = NULL; - return convert_string_talloc(ctx, CH_UTF8, CH_UNIX, src, src_len, (void **)dest, converted_size, false); + return convert_string_talloc(ctx, CH_UTF8, CH_UNIX, src, src_len, (void **)dest, converted_size); } /** @@ -665,15 +665,13 @@ _PUBLIC_ ssize_t pull_string(char *dest, const void *src, size_t dest_len, size_ * @returns the number of bytes occupied in the destination **/ _PUBLIC_ size_t convert_string(charset_t from, charset_t to, - void const *src, size_t srclen, - void *dest, size_t destlen, - bool allow_badcharcnv) + void const *src, size_t srclen, + void *dest, size_t destlen) { size_t ret; if (!convert_string_convenience(get_iconv_convenience(), from, to, - src, srclen, - dest, destlen, &ret, - allow_badcharcnv)) + src, srclen, + dest, destlen, &ret)) return -1; return ret; } @@ -690,14 +688,12 @@ _PUBLIC_ size_t convert_string(charset_t from, charset_t to, **/ _PUBLIC_ bool convert_string_talloc(TALLOC_CTX *ctx, - charset_t from, charset_t to, - void const *src, size_t srclen, - void *dest, size_t *converted_size, - bool allow_badcharcnv) + charset_t from, charset_t to, + void const *src, size_t srclen, + void *dest, size_t *converted_size) { return convert_string_talloc_convenience(ctx, get_iconv_convenience(), - from, to, src, srclen, dest, - converted_size, - allow_badcharcnv); + from, to, src, srclen, dest, + converted_size); } |