Fix bug 8040 - smbclient segfaults when a Cyrillic netbios name or workgroup is confi...
authorJeremy Allison <jra@samba.org>
Fri, 25 Mar 2011 22:12:12 +0000 (15:12 -0700)
committerKarolin Seeger <kseeger@samba.org>
Tue, 14 Jun 2011 10:56:28 +0000 (12:56 +0200)
commitd65d2279399316b80b1a992e5821919c6800cad4
treedade41c01f7c645f8aeef61ef2f6efc6f4fedf13
parent56adade6c2c16d938d507c4d6373bb4b61aef60a
Fix bug 8040 - smbclient segfaults when a Cyrillic netbios name or workgroup is configured.

As discovered by David Disseldorp <ddiss@suse.de>, convert_string_talloc()
doesn't always return consistent results for a zero length string. The
API states an incoming string must *always* contain the terminating null,
but unfotunately too much code expects passing in a zero source length
to return a null terminated string, so at least ensure we return a
correct null string in the required character set and return the
correct length.

Also ensure we cannot return a zero length for a converted string
(we ensure that the returned buffer is always allocated and zero
terminated anyway) as calling code depends on the fact that returning
true from this function will *always* return a non-zero length (as
it must include the terminating null).

Note this is a different fix from what went into master (this is
identical to the fix I'm planning for 3.5.x) as convert_string_talloc()
has diverged between the two.

Jeremy.
(cherry picked from commit bb3ed43584e6d2c4d64b5f7b9e70a7db7f3e859d)
source3/lib/charcnv.c