1
0
mirror of https://github.com/samba-team/samba.git synced 2025-01-05 09:18:06 +03:00
Commit Graph

133 Commits

Author SHA1 Message Date
Jeremy Allison
db458d3e8b r18897: Fix valgrind bug found by Volker.
Jeremy.
2007-10-10 12:14:43 -05:00
Jeremy Allison
53e97bf928 r18793: Fix BE string handling in the auto-generated
code. Should now work again with ASU.
Jeremy.
2007-10-10 12:00:58 -05:00
Jeremy Allison
ece00b70a4 r18787: Fix the strlen_m and strlen_m_term code by merging
in (and using elsewhere) next_codepoint from Samba4.
Jerry please test.
Jeremy.
2007-10-10 12:00:57 -05:00
Jeremy Allison
9dafb7f48c r16945: Sync trunk -> 3.0 for 3.0.24 code. Still need
to do the upper layer directories but this is what
everyone is waiting for....

Jeremy.
2007-10-10 11:19:14 -05:00
Gerald Carter
1e0b79e591 r15003: patch based on code from Arkady Glabek <aglabek@centeris.com> to ensure that global memory is freed when unloading pam_winbind.so (needs more testing on non-linux platforms) 2007-10-10 11:15:55 -05:00
Jeremy Allison
1d710d06a2 r13915: Fixed a very interesting class of realloc() bugs found by Coverity.
realloc can return NULL in one of two cases - (1) the realloc failed,
(2) realloc succeeded but the new size requested was zero, in which
case this is identical to a free() call.

The error paths dealing with these two cases should be different,
but mostly weren't. Secondly the standard idiom for dealing with
realloc when you know the new size is non-zero is the following :

 tmp = realloc(p, size);
 if (!tmp) {
    SAFE_FREE(p);
    return error;
 } else {
    p = tmp;
 }

However, there were *many* *many* places in Samba where we were
using the old (broken) idiom of :

 p = realloc(p, size)
 if (!p) {
    return error;
 }

which will leak the memory pointed to by p on realloc fail.

This commit (hopefully) fixes all these cases by moving to
a standard idiom of :

 p = SMB_REALLOC(p, size)
 if (!p) {
    return error;
 }

Where if the realloc returns null due to the realloc failing
or size == 0 we *guarentee* that the storage pointed to by p
has been freed. This allows me to remove a lot of code that
was dealing with the standard (more verbose) method that required
a tmp pointer. This is almost always what you want. When a
realloc fails you never usually want the old memory, you
want to free it and get into your error processing asap.

For the 11 remaining cases where we really do need to keep the
old pointer I have invented the new macro SMB_REALLOC_KEEP_OLD_ON_ERROR,
which can be used as follows :

 tmp = SMB_REALLOC_KEEP_OLD_ON_ERROR(p, size);
 if (!tmp) {
    SAFE_FREE(p);
    return error;
 } else {
    p = tmp;
 }

SMB_REALLOC_KEEP_OLD_ON_ERROR guarentees never to free the
pointer p, even on size == 0 or realloc fail. All this is
done by a hidden extra argument to Realloc(), BOOL free_old_on_error
which is set appropriately by the SMB_REALLOC and SMB_REALLOC_KEEP_OLD_ON_ERROR
macros (and their array counterparts).

It remains to be seen what this will do to our Coverity bug count :-).

Jeremy.
2007-10-10 11:10:59 -05:00
Jeremy Allison
c2752347eb r12522: Try and fix bug #2926 by removing setlocale(LC_ALL, "C")
and replace calls to isupper/islower/toupper/tolower with
ASCII equivalents (mapping into _w variants).
Jeremy.
2007-10-10 11:05:58 -05:00
Jeremy Allison
c65b752604 r12043: It's amazing the warnings you find when compiling on a 64-bit
box with gcc4 and -O6...
Fix a bunch of C99 dereferencing type-punned pointer will break
strict-aliasing rules errors. Also added prs_int32 (not uint32...)
as it's needed in one place. Find places where prs_uint32 was being
used to marshall/unmarshall a time_t (a big no no on 64-bits).
More warning fixes to come.
Thanks to Volker for nudging me to compile like this.
Jeremy.
2007-10-10 11:05:42 -05:00
Jeremy Allison
22fca74657 r5933: We were handling setting of EA's incorrectly - we should be able to set
a list. Also not converting names from DOS CP to UNIX CP correctly. This
code doesn't quite work yet but it's a work in progress to be fixed
tomorrow (don't want to lose it).
Jeremy.
2007-10-10 10:56:09 -05:00
Jeremy Allison
8e1b1693ab r4126: Fix from Björn Jacke <bjoern@j3e.de> for bugid #2040 - ensure the locale
is reset to C to get ASCII-compatible toupper/lower functions.
Jeremy.
2007-10-10 10:53:35 -05:00
Jeremy Allison
620f2e608f r4088: Get medieval on our ass about malloc.... :-). Take control of all our allocation
functions so we can funnel through some well known functions. Should help greatly with
malloc checking.
HEAD patch to follow.
Jeremy.
2007-10-10 10:53:32 -05:00
Jeremy Allison
ac9b91d805 r3857: Shut up gcc about erroneous "used uninitialised" warning.
Jeremy.
2007-10-10 10:53:21 -05:00
Jeremy Allison
7b0560dccc r2610: Even if we only use the fast-path (ascii only) then
we still need to set errno = E2BIG when we overflow.
Jeremy.
2007-10-10 10:52:48 -05:00
Jeremy Allison
afa88868b7 r2392: Steal the nicer error message from Samba4 :-).
Jeremy.
2007-10-10 10:52:42 -05:00
Jeremy Allison
5d04cd6804 r2114: Shameless theft of iconv commit from Samba4 to keep the two libs more in sync :-).
try to cope with a wider range of UTF-16 characters when we are using
an external libiconv library.
Jeremy.
2007-10-10 10:52:32 -05:00
Jeremy Allison
db3dde026b r1684: Patch for bug #1578 based on fix from Alexander E. Patrakov,
<patrakov@ums.usu.ru>. Main change, hardcode replacement char
to '_' as I really don't want a new parameter.
Jeremy.
2007-10-10 10:52:18 -05:00
Gerald Carter
c9bef86b8b r907: fixing browse.dat bug -- don't include the resouce byte from the netbios name when pulling a string from a packet (jra, please double check this 2007-10-10 10:51:48 -05:00
Jeremy Allison
37dd5e52f6 "Fixing my FORTRAN". Ensure we always have some valid char converter for the
neccessary types before we will run at all. If we can't get one, use ASCII
but complain mightily.
Jeremy.
0001-01-01 00:00:00 +00:00
Jeremy Allison
e8b68ef965 Correctness patch from fumiya@miraclelinux.com to count characters correctly,
doesn't affect what got put on the wire.
Jeremy.
0001-01-01 00:00:00 +00:00
Jeremy Allison
6339c4690a Remove excess logging when probing for the length of the next mb char.
Jeremy.
0001-01-01 00:00:00 +00:00
Jeremy Allison
5a9324525a Change check_path_syntax() to use the new next_mb_char_size() function
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.
0001-01-01 00:00:00 +00:00
Jeremy Allison
d2b2a39fd2 Add function next_mb_char_size() that returns a size_t of the number of
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.
0001-01-01 00:00:00 +00:00
Alexander Bokovoy
2c404f6ba9 Fix check_path_syntax() for multibyte encodings which have no '\' as second 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.'
'
0001-01-01 00:00:00 +00:00
Jeremy Allison
d7cf64b1e4 Ensure we don't truncate strcmps to nstring anymore...
Jeremy.
0001-01-01 00:00:00 +00:00
Jeremy Allison
b4ea493599 Modified fix for bugid #784. Based on a patch from moriyama@miraclelinux.com (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.
0001-01-01 00:00:00 +00:00
Jeremy Allison
966e49a48c First part of patch from moriyama@miraclelinux.com (MORIYAMA Masayuki) to
fix up netbios names with mb strings. Includes reformat of libsmb/nmblib.c
so it's readable.
Jeremy.
0001-01-01 00:00:00 +00:00
Jeremy Allison
7b96765c23 Restore the contract on all convert_stringXX() interfaces. Add a "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.
0001-01-01 00:00:00 +00:00
Jeremy Allison
4c182d3220 Fixup the allocate version of the function to do "crap" conversions too.
Embarrassing number of goto's in this :-(. Fixes #830 I think.
Jeremy.
0001-01-01 00:00:00 +00:00
Jeremy Allison
6a7919f254 Working on #830. Cope with bad conversions better - don't just memcpy but
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.
0001-01-01 00:00:00 +00:00
Andrew Tridgell
8b8f0c5279 the conversion from int to size_t in charcnv did not take into account
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!
0001-01-01 00:00:00 +00:00
Gerald Carter
79fe75dcdf * BUG 446
- 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
0001-01-01 00:00:00 +00:00
Andrew Bartlett
494781f628 auth/auth_util.c:
- 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
0001-01-01 00:00:00 +00:00
Jeremy Allison
cd2075580b Get a little paranoid about memfree use in convert_string_allocate..
Looking at crash bugs #809 and others.
Jeremy.
0001-01-01 00:00:00 +00:00
Richard Sharpe
58d7a51c57 Fix a couple of warnings with casts. 0001-01-01 00:00:00 +00:00
Jeremy Allison
d7e35dfb92 Put strcasecmp/strncasecmp on the banned list (except for needed calls
in iconv.c and nsswitch/). Using them means you're not thinking about multibyte at
all and I really want to discourage that.
Jeremy.
0001-01-01 00:00:00 +00:00
Jeremy Allison
f23acb4ca5 Fix for MacOS/X which uses STUPID BROKEN UNICODE COMPOSE CHARACTERS !
(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.
0001-01-01 00:00:00 +00:00
Jeremy Allison
035f595995 Fix mb bug in fast path code. strlen_w() returns number of *characters*
not number of bytes. Reproduce this by trying to rename the file named :
sibrseau -> sibrseaU
from Windows 2000 explorer.
Jeremy.
0001-01-01 00:00:00 +00:00
Jeremy Allison
6fc0e529f7 Fix valgrind-found read of uninit variable (ensure length is right).
Jeremy.
0001-01-01 00:00:00 +00:00
Jeremy Allison
8cb9ec5d53 More cachegrind tuning, plus fix an error message.
Jeremy.
0001-01-01 00:00:00 +00:00
Jeremy Allison
f35e9a8b90 More tuning from cachegrind. Change most trim_string() calls to trim_char(0,
as that's what they do. Fix string_replace() to fast-path ascii.
Jeremy.
0001-01-01 00:00:00 +00:00
Jeremy Allison
467cafdb1f More hand-tuning of the fastpath. Don't do strlen() when we're doing
to walk to the end anyway.
Jeremy.
0001-01-01 00:00:00 +00:00
Jeremy Allison
e98fbfaf38 Remove convert_string_internal completely from fast path when processing
NBENCH calls. Requires fixed buffer size for strdup_upper().
Jeremy.
0001-01-01 00:00:00 +00:00
Jeremy Allison
ef140d15ea Used cachegrind to track down some bottlenecks.
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.
0001-01-01 00:00:00 +00:00
Jeremy Allison
236d6adadf Half-way though the big conversion of all nmbd access to wire elements being
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.
0001-01-01 00:00:00 +00:00
Jeremy Allison
94d0f888c9 Shut conversion errors up when initialising tables.
Jeremy.
0001-01-01 00:00:00 +00:00
Jeremy Allison
cfde7477fd Attempt to fix the charcnv issues causing nmbd to crash. If we get a failed
conversion simply copy as is. Also fixed the horrid malloc-twice-copy code
in the convert alloc path.
Jeremy.
0001-01-01 00:00:00 +00:00
Andrew Bartlett
6c9056029b Use push_ucs2_allocate(), rather than convert_string_allocate() directly.
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
0001-01-01 00:00:00 +00:00
Andrew Bartlett
912035af11 Some small fixes to our charset conversion code:
- 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
0001-01-01 00:00:00 +00:00
Tim Potter
59dae1da66 More printf portability fixes. Got caught out by some gcc'isms last
time.  )-:
0001-01-01 00:00:00 +00:00
Tim Potter
ba4d334b82 More printf fixes - size_t is long on some architectures. 0001-01-01 00:00:00 +00:00