1
0
mirror of https://github.com/samba-team/samba.git synced 2025-11-30 20:23:49 +03:00
Commit Graph

24 Commits

Author SHA1 Message Date
Andrew Tridgell
6e7754abd0 r4591: - converted the other _p talloc functions to not need _p
- added #if TALLOC_DEPRECATED around the _p functions

- fixes the code that broke from the above

while doing this I fixed quite a number of places that were
incorrectly using the non type-safe talloc functions to use the type
safe ones. Some were even doing multiplies for array allocation, which
is potentially unsafe.
2007-10-10 13:08:30 -05:00
Andrew Tridgell
573230ea99 r4124: include locale.h to get LC_ALL in include/system/iconv.h 2007-10-10 13:06:28 -05:00
Andrew Tridgell
53c4d0a7d8 r4123: set locale to C to ensure ascii string functions work
thanks to Bjoern JACKE <samba@j3e.de> for pointing this out
2007-10-10 13:06:28 -05:00
Andrew Tridgell
e6e8a9c7f0 r3598: hopefully fix the build on stratos 2007-10-10 13:05:37 -05:00
Andrew Tridgell
55aeb33343 r3063: our default dos charset is CP850, but some systems don't have that, so
as a special case, automatically fall back to ASCII if its not found.
2007-10-10 13:01:55 -05:00
Andrew Tridgell
4d2497b7f4 r3061: change a debug to help track down a charset problem 2007-10-10 13:01:55 -05:00
Andrew Tridgell
e3009492b8 r2907: auto destroy iconv memory handles on exit, to make valgrind leak
reports easier to read (less noisy)
2007-10-10 12:59:46 -05:00
Andrew Tridgell
abcd841a85 r2903: a considerably more efficient (both in terms of CPU and memory)
convert_string_talloc() implementation.

the previous version used a minimum of 512 bytes, which is way above the average
of what is needed.
2007-10-10 12:59:46 -05:00
Andrew Tridgell
814881f0e5 r2857: this commit gets rid of smb_ucs2_t, wpstring and fpstring, plus lots of associated functions.
The motivation for this change was to avoid having to convert to/from
ucs2 strings for so many operations. Doing that was slow, used many
static buffers, and was also incorrect as it didn't cope properly with
unicode codepoints above 65536 (which could not be represented
correctly as smb_ucs2_t chars)

The two core functions that allowed this change are next_codepoint()
and push_codepoint(). These functions allow you to correctly walk a
arbitrary multi-byte string a character at a time without converting
the whole string to ucs2.

While doing this cleanup I also fixed several ucs2 string handling
bugs. See the commit for details.

The following code (which counts the number of occuraces of 'c' in a
string) shows how to use the new interface:

size_t count_chars(const char *s, char c)
{
	size_t count = 0;

	while (*s) {
		size_t size;
		codepoint_t c2 = next_codepoint(s, &size);
		if (c2 == c) count++;
		s += size;
	}

	return count;
}
2007-10-10 12:59:39 -05:00
Jelmer Vernooij
b90da2337b r2684: Free the right talloc context (don't panic when encountering illegal multibyte
sequences)
2007-10-10 12:59:22 -05:00
Andrew Tridgell
8dc23821c9 r2671: we're getting too many errors caused by the talloc_realloc() API not
taking a context (so when you pass a NULL pointer you end up with
memory in a top level context). Fixed it by changing the API to take a
context. The context is only used if the pointer you are reallocing is
NULL.
2007-10-10 12:59:20 -05:00
Andrew Tridgell
28dcd22029 r2642: smb_iconv_t is a pointer, so checks against -1 errors should use a cast 2007-10-10 12:59:15 -05:00
Andrew Tridgell
60e8d154fd r2638: do lazy initialisation of iconv handles, so we don't initialise a
handle unless we use it. This saves quite a bit of memory (libc chews
a lot loading a handle). Typically smbd now loads 3 handles, instead
of 36.
2007-10-10 12:59:15 -05:00
Andrew Bartlett
dfecb01506 r2552: Character set conversion and string handling updates.
The intial motivation for this commit was to merge in some of the
bugfixes present in Samba3's chrcnv and string handling code into
Samba4.  However, along the way I found a lot of unused functions, and
decided to do a bit more...

The strlen_m code now does not use a fixed buffer, but more work is
needed to finish off other functions in str_util.c.  These fixed
length buffers hav caused very nasty, hard to chase down bugs at some
sites.

The strupper_m() function has a strupper_talloc() to replace it (we
need to go around and fix more uses, but it's a start).  Use of these
new functions will avoid bugs where the upper or lowercase version of
a string is a different length.

I have removed the push_*_allocate functions, which are replaced by
calls to push_*_talloc.  Likewise, pstring and other 'fixed length'
wrappers are removed, where possible.

I have removed the first ('base pointer') argument, used by push_ucs2,
as the Samba4 way of doing things ensures that this is always on an
even boundary anyway.  (It was used in only one place, in any case).
2007-10-10 12:59:05 -05:00
Andrew Tridgell
6807d336c2 r2380: nicer error reporting in convert_string() 2007-10-10 12:58:46 -05:00
Andrew Tridgell
756f28ac95 r2159: converted samba4 over to UTF-16.
I had previously thought this was unnecessary, as windows doesn't use
standards compliant UTF-16, and for filesystem operations treats bytes
as UCS-2, but Bjoern Jacke has pointed out to me that this means we
don't correctly store extended UTF-16 characters as UTF-8 on
disk. This can be seen with (for example) the gothic characters with
codepoints above 64k.

This commit also adds a LOCAL-ICONV torture test that tests the first
1 million codepoints against the system iconv library, and tests 5
million random UTF-16LE buffers for identical error handling to the
system iconv library.

the lib/iconv.c changes need backporting to samba3
2007-10-10 12:58:27 -05:00
Andrew Tridgell
168be7fbd7 r2106: try to cope with a wider range of UTF-16 characters when we are using
an external libiconv library.
2007-10-10 12:58:25 -05:00
Andrew Bartlett
4f06bf4ab8 r1196: Remove unused pstring/fstring functions.
Andrew Bartlett
2007-10-10 12:56:44 -05:00
Andrew Tridgell
b7935c9674 r934: on ascii strings STR_TERMINATE_ASCII should trigger STR_TERMINATE behaviour 2007-10-10 12:56:20 -05:00
Andrew Bartlett
5f5786ad5f r831: These functions duplicate the push/pull charcnv interfaces that we use
everywhere else in the Samba code, so remove them for clarity.

(ok, so  also just never liked the names  ;-)

Andrew Bartlett
2007-10-10 12:53:53 -05:00
Andrew Tridgell
a0a51af6b7 added support for big-endian ucs2 strings (as used by big-endian
msrpc).

this was easier than I expected!
-
Andrew Tridgell
02d068ba7d more fixes from the IRIX compiler (thanks herb!) -
Andrew Tridgell
c770603ac6 fixed some places where we don't brace (flags & STR_UNICODE)
this fixes the samba4 server with ascii clients
-
Andrew Tridgell
b0510b5428 first public release of samba4 code -