summaryrefslogtreecommitdiff
path: root/source3/lib/charcnv.c
AgeCommit message (Collapse)AuthorFilesLines
2004-03-18Correctness patch from fumiya@miraclelinux.com to count characters correctly,Jeremy Allison1-0/+3
doesn't affect what got put on the wire. Jeremy. (This used to be commit e8b68ef965ea2e3bed41cb397ef32df05c631e92)
2004-03-17Remove excess logging when probing for the length of the next mb char.Jeremy Allison1-0/+3
Jeremy. (This used to be commit 6339c4690aef7692571dd4c65dd0a12d56a7ffab)
2004-03-17Change check_path_syntax() to use the new next_mb_char_size() functionJeremy Allison1-20/+4
to make it generic. Remove the mb-codepage "blacklist". Alexander, please check this fix as it reverts your blacklist changes, but I'm hoping it fixes the problem in a more generic way for all charsets. I'm not trying to trample on your (excellent!) work here, just make things more generic without special cases. Jeremy. (This used to be commit 5a9324525acc02e6bf14528679816b35929a564e)
2004-03-16Add function next_mb_char_size() that returns a size_t of the number ofJeremy Allison1-0/+24
bytes in the mb character at a pointer. Will be useful in fixing check_path_syntax() to not use a "blacklist". Also re-added my (C) to reply.c. I mean, really - I've been adding code to the file for over 10 years and I recognise many of the fuctions as mine ! :-). Jeremy. (This used to be commit d2b2a39fd2f2e06cc4aebf081876985f0b28b477)
2004-03-16Fix check_path_syntax() for multibyte encodings which have no '\' as second ↵Alexander Bokovoy1-0/+20
byte. This is intermediate fix as discussed with Jeremy until we move check_path_syntax() to UCS2 internally where all ambiguity is resolved. Please add other encodings into charcnv.c with such property.' ' (This used to be commit 2c404f6ba988d68c6f44df9409c0de319553de10)
2004-03-13Ensure we don't truncate strcmps to nstring anymore...Jeremy Allison1-0/+2
Jeremy. (This used to be commit d7cf64b1e4e501bcd01ddc8279babc65d894a4b3)
2004-03-13Modified fix for bugid #784. Based on a patch from moriyama@miraclelinux.com ↵Jeremy Allison1-3/+6
(MORIYAMA Masayuki). Don't use nstrings to hold workgroup and netbios names. The problem with them is that MB netbios and workgroup names in unix charset (particularly utf8) may be up to 3x bigger than the name when represented in dos charset (ie. cp932). So go back to using fstrings for these but translate into nstrings (ie. 16 byte length values) for transport on the wire. Jeremy. (This used to be commit b4ea493599ab414f7828b83f40a5a8b43479ff64)
2004-03-13First part of patch from moriyama@miraclelinux.com (MORIYAMA Masayuki) toJeremy Allison1-1/+29
fix up netbios names with mb strings. Includes reformat of libsmb/nmblib.c so it's readable. Jeremy. (This used to be commit 966e49a48c352563cdd7f75fe2768f2d6612ec7e)
2004-03-11Restore the contract on all convert_stringXX() interfaces. Add a ↵Jeremy Allison1-39/+63
"allow_bad_conv" boolean parameter that allows broken iconv conversions to work. Gets rid of the nasty errno checks in mangle_hash2 and check_path_syntax and allows correct return code checking. Jeremy. (This used to be commit 7b96765c23637613f079d37566d95d5edd511f05)
2004-02-04Fixup the allocate version of the function to do "crap" conversions too.Jeremy Allison1-20/+83
Embarrassing number of goto's in this :-(. Fixes #830 I think. Jeremy. (This used to be commit 4c182d3220e87ea74d9c977b8ab1d740ef4cc30f)
2004-02-04Working on #830. Cope with bad conversions better - don't just memcpy butJeremy Allison1-10/+82
try a crap conversion instead. Next this needs to be done to the convert_alloc function. Actually fixes some valgrind warnings as well - cool ! Jeremy. (This used to be commit 6a7919f2544a689840fe46f3c58ed66f69aca65a)
2004-02-02the conversion from int to size_t in charcnv did not take into accountAndrew Tridgell1-1/+1
one place where we checked "if (src_len > 0)". I actually would greatly prefer to switch back to int for src_len. The type *can* be negative, which means an unsigned type is inappropriate. There is absolutely no reason why "int" should not be used for a parameter like this. I didn't change back to int as we are close to a release and I wanted a mininal change, but please don't go changing types like this in future without very careful testing and a damn good reason. this bug broke pull_ucs2(), I would not be surprised if it caused all sorts of nastiness. Thanks to vl for noticing the symptoms! (This used to be commit 8b8f0c527959c707f274b435fc59156e37232981)
2004-01-15* BUG 446Gerald Carter1-0/+4
- setup_logging() in smbclient to be interactive (remove the timestamps) - Fix bad return value in pull_ucs2( needs more testing to make sure this didn't break something else) that caused clistr_pull() to always read the same string from the buffer (pull_usc2() could return -1 if the original source length was given as -1) - increment some debugging messages to avoid printing them out so often (This used to be commit 79fe75dcdf6cc38e18ca1231e4357893db4d4a08)
2003-12-31auth/auth_util.c:Andrew Bartlett1-2/+2
- Fill in the 'backup' idea of a domain, if the DC didn't supply one. This doesn't seem to occour in reality, hence why we missed the typo. lib/charcnv.c: lib/smbldap.c: libads/ldap.c: libsmb/libsmbclient.c: printing/nt_printing.c: - all the callers to pull_utf8_allocate() pass a char ** as the first parammeter, so don't make them all cast it to a void ** nsswitch/winbind_util.c: - Allow for a more 'correct' view of when usernames should be qualified in winbindd. If we are a PDC, or have 'winbind trusted domains only', then for the authentication returns stip the domain portion. - Fix valgrind warning about use of free()ed name when looking up our local domain. lp_workgroup() is maniplated inside a procedure that uses it's former value. Instead, use the fact that our local domain is always the first in the list. Andrew Bartlett (This used to be commit 494781f628683d6e68e8ba21ae54f738727e8c21)
2003-12-01Get a little paranoid about memfree use in convert_string_allocate..Jeremy Allison1-7/+6
Looking at crash bugs #809 and others. Jeremy. (This used to be commit cd2075580b0f35c8a414c995f03834c01efaa9be)
2003-11-13Fix a couple of warnings with casts.Richard Sharpe1-2/+2
(This used to be commit 58d7a51c5762a444aae6a795a3703269134423d7)
2003-10-22Put strcasecmp/strncasecmp on the banned list (except for needed callsJeremy Allison1-1/+1
in iconv.c and nsswitch/). Using them means you're not thinking about multibyte at all and I really want to discourage that. Jeremy. (This used to be commit d7e35dfb9283d560d0ed2ab231f36ed92767dace)
2003-09-13Fix for MacOS/X which uses STUPID BROKEN UNICODE COMPOSE CHARACTERS !Jeremy Allison1-24/+51
(rant off :-). Inspired by work from Benjamin Riefenstahl <Benjamin.Riefenstahl@epost.de>. Also add MacOSX/Darwin configure fixes. Jerry - can we put this in 3.0 release ? :-). Jeremy. (This used to be commit f23acb4ca5feac8ad2acfa1baf7df31283aba3ea)
2003-09-10Fix mb bug in fast path code. strlen_w() returns number of *characters*Jeremy Allison1-3/+3
not number of bytes. Reproduce this by trying to rename the file named : sibréseau -> sibréseaU from Windows 2000 explorer. Jeremy. (This used to be commit 035f59599514491609078ac0fe5804278c43a9b3)
2003-09-08Fix valgrind-found read of uninit variable (ensure length is right).Jeremy Allison1-3/+3
Jeremy. (This used to be commit 6fc0e529f70253244628017a372257e8dc053294)
2003-09-05More cachegrind tuning, plus fix an error message.Jeremy Allison1-11/+32
Jeremy. (This used to be commit 8cb9ec5d533085d40fc6bfe4ca9647d80bf41ac7)
2003-09-05More tuning from cachegrind. Change most trim_string() calls to trim_char(0,Jeremy Allison1-4/+2
as that's what they do. Fix string_replace() to fast-path ascii. Jeremy. (This used to be commit f35e9a8b909d3c74be47083ccc4a4e91a14938db)
2003-09-04More hand-tuning of the fastpath. Don't do strlen() when we're doingJeremy Allison1-12/+27
to walk to the end anyway. Jeremy. (This used to be commit 467cafdb1f7ddfb4278824f385b732975246a4f5)
2003-09-04Remove convert_string_internal completely from fast path when processingJeremy Allison1-10/+18
NBENCH calls. Requires fixed buffer size for strdup_upper(). Jeremy. (This used to be commit e98fbfaf384bd2d3ebb002b0b981366377fb5ac0)
2003-09-04Used cachegrind to track down some bottlenecks.Jeremy Allison1-11/+94
Removed calls to clobber_region when not compiling with developer as they were hiding speed problems. Added fast path to convert_string() when dealing with ascii -> ascii, ucs2-le to ascii and ascii to ucs2-le with values <= 0x7F. This gives a speedup of 22% on my nbench tests. Next I will do this on convert_string_allocate. Jeremy. (This used to be commit ef140d15ea0d76a3e7cdcadbfd3e917c210a9411)
2003-08-23Half-way though the big conversion of all nmbd access to wire elements beingJeremy Allison1-0/+10
converted to pull/push_ascii. This will not work right at the moment for non English codepages, but compiles - I will finish the work over the weekend. Then nmbd should be completely codepage correct. Jeremy. (This used to be commit 236d6adadf32397b28028ea82ae2ec027366f7c8)
2003-08-21Shut conversion errors up when initialising tables.Jeremy Allison1-12/+24
Jeremy. (This used to be commit 94d0f888c9abd52e26ef5fc597ade5426a521227)
2003-08-20Attempt to fix the charcnv issues causing nmbd to crash. If we get a failedJeremy Allison1-34/+92
conversion simply copy as is. Also fixed the horrid malloc-twice-copy code in the convert alloc path. Jeremy. (This used to be commit cfde7477fd12caef943a9422b52174438092a135)
2003-07-27Use push_ucs2_allocate(), rather than convert_string_allocate() directly.Andrew Bartlett1-8/+4
Remove strdup_upper/strdup_lower from their old file, now that they have been moved to charcnv.c Note that string_replace assumes that s is a pstring. (doco change only) Andrew Bartlett (This used to be commit 6c9056029bb3dfadb244f301598e12e69493fff9)
2003-07-27Some small fixes to our charset conversion code:Andrew Bartlett1-50/+70
- Treat the NMB names in the 'session request' packet as 'ASCII'. This means that we do not get invalid multibyte from the wire, even if we truncate in the conversion. (Otherwise we panic when we try to strupper_m it). - Remove acnv_uxu2(), as it was duplicated by push_ucs2_allocate() - Remove acnv_dosu2(), as it is not used. - In push_ucs2(), with the STR_UPPER flag, do the case conversion *after* the UCS2 conversion, when it we know that the length can't change. Also faster, as we don't need to do another 2 UCS2 conversions. Andrew Bartlett (This used to be commit 912035af1178424583d0bf887a391a0cac2acd87)
2003-07-25More printf portability fixes. Got caught out by some gcc'isms lastTim Potter1-2/+2
time. )-: (This used to be commit 59dae1da66a5eb7e128263bd578f167d8746e9f0)
2003-07-24More printf fixes - size_t is long on some architectures.Tim Potter1-1/+1
(This used to be commit ba4d334b822248d8ab929c9568533431603d967e)
2003-07-03Removed strupper/strlower macros that automatically map to ↵Jeremy Allison1-3/+3
strupper_m/strlower_m. I really want people to think about when they're using multibyte strings. Jeremy. (This used to be commit ff222716a08af65d26ad842ce4c2841cc6540959)
2003-06-30- added LOCALE patch from vorlon@debian.org (Steve Langasek) (bug #122)Andrew Tridgell1-0/+24
- changed --enable-developer debug to use -gstabs as it makes the samba binaries about 10x smaller and is still quite functional for samba debugging (This used to be commit 53bfcd478a193d4def8da872e92d7ed8f46aa4b9)
2003-06-16reverted locale patch put in by jht (originally from vorlon).Andrew Tridgell1-37/+0
There are lots of things wrong with this patch, including: 1) it overrides a user chosen configuration option 2) it adds lots of complexity inside a loop when a tiny piece of code outside the loop would do the same thing 3) it does no error checking, and is sure to crash on some systems If you want this functionality then try something like this at the end of charset_name(): #ifdef HAVE_NL_LANGINFO if (strcasecmp(ret, "LOCALE") == 0) { const char *ln = nl_langinfo(CODESET); if (ln) { DEBUG(5,("Substituting charset '%s' for LOCALE\n", ln)); return ln; } } #endif then users can set 'display charset = LOCALE' to get the locale based charset. You could even make that the default for systems that have nl_langinfo(). (This used to be commit 382b9b806b1ecd227b1ea247e3825d6848090462)
2003-06-15Patch from vorlon@debian.org, see bugzilal #122John Terpstra1-0/+37
Samba should preferentially use the locale information from the native system, and only fall back on 'display charset' if this is unavailable or unsupported. (This used to be commit 1e445fb4220cdf4700dd9d1850a42746a1065c5a)
2003-06-06Fix for valgrind - when doing a srvstr_push we must zero fillJeremy Allison1-0/+13
any extra bytes, not clobber region them - otherwise valgrind thinks they are invalid on send() or write(). Jeremy. (This used to be commit 8aa5f7a65c71fb89ed05e71a2465e61385e80c2b)
2003-06-06- the 8.3 name in BOTH_DIRECTORY_INFO is supposed to be always unicodeAndrew Tridgell1-1/+1
(to match win2003 behaviour) - added the STR_TERMINATE_ASCII flag from samba4 so we can get the string termination right for the case where it is supposed to be non-terminated for UCS2 and terminated when ASCII (This used to be commit 791a4cc7cf84eca77116bca00aeb5f95560f6705)
2003-05-08fixed bug #75; add check for non-zero destlenGerald Carter1-1/+1
(This used to be commit 83bb84f13121267992e78f2d005257932c711f23)
2003-05-08Another attempt at undoing my bogus patch 1.55.2.19Tim Potter1-0/+2
(This used to be commit 05a684b3be1525aad3589ded9e59c3f012b5ef20)
2003-05-07Whoops - that wasn't a whitespace syncup after all.Tim Potter1-0/+2
(This used to be commit 42d0414ed244b92b665cb231f6756f60391861dd)
2003-04-28Whitespace syncup.Tim Potter1-4/+0
(This used to be commit 7fd7af121ee8ba4f9540394f64fe3c78e2e96cd2)
2003-04-23Patch by Metze to ensure that we always at least initialize our output stringAndrew Bartlett1-0/+4
for rpc_pull_string. If we had a NULL or zero-length string, we would use uninitialised data in the result string. Andrew Bartlett (This used to be commit df10aee451b431a8a056a949a98393da256185da)
2003-04-22Merge (HEAD->3.0) mbp's fixes to our charcnv code - don't use a staic buffer,Andrew Bartlett1-12/+33
which can restrict things like unix_strupper() to 512 byte strings. Andrew Bartlett (This used to be commit 341d6affa474262654f83c075f186d985cbcb9a0)
2003-04-14Merge across tridge's Realloc fix.Jeremy Allison1-3/+3
Jeremy. (This used to be commit df214d18817467fbe3023a412bceec325f73b518)
2003-04-04Export lazy_initialize_conv so that it can be called fromMartin Pool1-1/+5
check_dos_char. init_iconv: Call init_doschar_table when reinitializing conversions. (This used to be commit d0b2c5d7ba5531fc695a23bba87a1551cc39e2ee)
2003-04-04lazy_initialize_conv: Remove redundant call to init_valid_table,Martin Pool1-4/+6
because init_iconv calls it for us. init_iconv: Add documentation about how this is reintialized when configuration is reloaded. (This used to be commit 0ee80a9018601fbba1c9558545de61cb16e94fac)
2003-03-20Patch from Samuel Thibault to convert messages from dos to unix charsetJelmer Vernooij1-1/+1
when sending(and vice versa when receiving). (This used to be commit 5310447ec6e0df1c000e3ee14572f5b7fee31f28)
2003-03-18Merge in the developer string options from HEAD. We need to ensure 3.0Jeremy Allison1-103/+12
is as stable as possible in the string department and some pain now will help later :-). Jeremy. (This used to be commit 86e3eddac698d90f4666b8492b4603a4efbbd67b)
2003-02-24Merge documentation from HEADMartin Pool1-6/+13
(This used to be commit 3761f8ebe339fbbeffee9d7b69f9483ebfd9ae6b)