1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-23 17:34:34 +03:00
samba-mirror/lib/util/charset
Douglas Bagnall 103d248bee util/charset/convert: do not pretend to realloc
It seems very likely that our clever attempts to dynamically realloc
the output buffer were never triggered. Two lines of reasoning lead to
this conclusion:

1. We allocate 3 * srclen to start with, but no conversion we use will
   more than that. To be precise, from 8-bit charsets we will only deal
   with codepoints in the Unicode basic multilingual plane (up to 0xFFFF).

   These can all be expressed as 3 or fewer utf-8 bytes. In UTF16 they
   are naturally 2 bytes, while in the DOS codes they are 1 byte.

   We have checked the code tables, and can not find a plausible
   (e.g. not EBCDIC) DOS code page or unix charset that is outside
   this range.  Clients cannot chose the code page, the only code
   pages we will use come from 'unix charset' and 'dos charset'
   smb.conf parameters.

   Therefore the worst that can possibly happen is we expand 1 byte into 3
   (specifically, when converting some e.g. CP850 codepoints to UTF-8).

2. If the reallocation was ever used, the results would have been
   catastrophically wrong, as the input pointer was not reset.

Therefore we skip the complication of the goto loop and let E2BIG be
just another impossible error to report.

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2019-05-15 04:03:37 +00:00
..
tests lib:util: Use #ifdef instead of #if for config.h definitions 2018-11-28 23:19:22 +01:00
charset_macosxfs.c lib:util: Use #ifdef instead of #if for config.h definitions 2018-11-28 23:19:22 +01:00
charset_proto.h s3: Fix fn signatures in charset_macosx.c 2011-12-25 13:31:58 +01:00
charset.h lib:charset: Make global_iconv_handle private 2017-04-18 11:47:17 +02:00
codepoints.c lib:charset: Remove use of talloc_autofree_context() for global_iconv_handle 2017-04-18 11:47:17 +02:00
convert_string.c util/charset/convert: do not pretend to realloc 2019-05-15 04:03:37 +00:00
iconv.c lib:util: Use C99 initializer for builtin_functions in iconv 2019-01-28 10:29:22 +01:00
pull_push.c util: Fix the documentation of push_utf8_talloc() 2016-09-09 00:32:12 +02:00
util_str.c lib:charset: Fix error messages from charset conversion 2018-07-07 13:41:09 +02:00
util_unistr_w.c charset: Avoid compiler warnings with --enable-developer 2014-09-19 18:11:11 +02:00
util_unistr.c CVE-2015-5330: strupper_talloc_n_handle(): properly count characters 2015-12-09 17:19:52 +01:00
weird.c lib:util: Use C99 initializer for weird_table in charset 2019-01-28 10:29:22 +01:00
wscript_build charset: Remove unused iconv_talloc() 2012-02-10 16:45:11 +11:00
wscript_configure util:charset: Return EILSEQ in smb_iconv() if newer libc is detected 2017-02-01 05:16:46 +01:00