1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-25 23:21:54 +03:00
Commit Graph

133 Commits

Author SHA1 Message Date
Jeremy Allison
f1964048a5 r18897: Fix valgrind bug found by Volker.
Jeremy.
(This used to be commit db458d3e8b)
2007-10-10 12:14:43 -05:00
Jeremy Allison
3a60a67432 r18793: Fix BE string handling in the auto-generated
code. Should now work again with ASU.
Jeremy.
(This used to be commit 53e97bf928)
2007-10-10 12:00:58 -05:00
Jeremy Allison
f18c9365ca r18787: Fix the strlen_m and strlen_m_term code by merging
in (and using elsewhere) next_codepoint from Samba4.
Jerry please test.
Jeremy.
(This used to be commit ece00b70a4)
2007-10-10 12:00:57 -05:00
Jeremy Allison
fbdcf2663b 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.
(This used to be commit 9dafb7f48c)
2007-10-10 11:19:14 -05:00
Gerald Carter
bbf666e447 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)
(This used to be commit 1e0b79e591)
2007-10-10 11:15:55 -05:00
Jeremy Allison
894358a8f3 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.
(This used to be commit 1d710d06a2)
2007-10-10 11:10:59 -05:00
Jeremy Allison
5a4881bf39 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.
(This used to be commit c2752347eb)
2007-10-10 11:05:58 -05:00
Jeremy Allison
d1f91f7c72 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.
(This used to be commit c65b752604)
2007-10-10 11:05:42 -05:00
Jeremy Allison
442b9f3e87 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.
(This used to be commit 22fca74657)
2007-10-10 10:56:09 -05:00
Jeremy Allison
92a7eb69d3 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.
(This used to be commit 8e1b1693ab)
2007-10-10 10:53:35 -05:00
Jeremy Allison
acf9d61421 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.
(This used to be commit 620f2e608f)
2007-10-10 10:53:32 -05:00
Jeremy Allison
b74b9c5037 r3857: Shut up gcc about erroneous "used uninitialised" warning.
Jeremy.
(This used to be commit ac9b91d805)
2007-10-10 10:53:21 -05:00
Jeremy Allison
17ab9e8db1 r2610: Even if we only use the fast-path (ascii only) then
we still need to set errno = E2BIG when we overflow.
Jeremy.
(This used to be commit 7b0560dccc)
2007-10-10 10:52:48 -05:00
Jeremy Allison
fb4c421f1b r2392: Steal the nicer error message from Samba4 :-).
Jeremy.
(This used to be commit afa88868b7)
2007-10-10 10:52:42 -05:00
Jeremy Allison
651daa4b42 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.
(This used to be commit 5d04cd6804)
2007-10-10 10:52:32 -05:00
Jeremy Allison
16de9d9711 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.
(This used to be commit db3dde026b)
2007-10-10 10:52:18 -05:00
Gerald Carter
5a3bc12683 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
(This used to be commit c9bef86b8b)
2007-10-10 10:51:48 -05:00
Jeremy Allison
fe160f5b72 "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.
(This used to be commit 37dd5e52f6)
2004-04-01 19:42:36 +00:00
Jeremy Allison
c66f52a5ac Correctness patch from fumiya@miraclelinux.com to count characters correctly,
doesn't affect what got put on the wire.
Jeremy.
(This used to be commit e8b68ef965)
2004-03-18 17:58:50 +00:00
Jeremy Allison
41ea0d35ae Remove excess logging when probing for the length of the next mb char.
Jeremy.
(This used to be commit 6339c4690a)
2004-03-17 19:23:48 +00:00
Jeremy Allison
aa2e306a01 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.
(This used to be commit 5a9324525a)
2004-03-17 02:08:31 +00:00
Jeremy Allison
acad182a3f 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.
(This used to be commit d2b2a39fd2)
2004-03-16 21:59:11 +00:00
Alexander Bokovoy
e2fd98af57 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.'
'
(This used to be commit 2c404f6ba9)
2004-03-16 17:18:57 +00:00
Jeremy Allison
a0034d3586 Ensure we don't truncate strcmps to nstring anymore...
Jeremy.
(This used to be commit d7cf64b1e4)
2004-03-13 02:47:21 +00:00
Jeremy Allison
6b9dbbcd24 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.
(This used to be commit b4ea493599)
2004-03-13 02:16:21 +00:00
Jeremy Allison
fd2d4f87d4 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.
(This used to be commit 966e49a48c)
2004-03-13 00:28:53 +00:00
Jeremy Allison
e3f5b54270 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.
(This used to be commit 7b96765c23)
2004-03-11 22:48:24 +00:00
Jeremy Allison
ef743c0641 Fixup the allocate version of the function to do "crap" conversions too.
Embarrassing number of goto's in this :-(. Fixes #830 I think.
Jeremy.
(This used to be commit 4c182d3220)
2004-02-04 19:13:45 +00:00
Jeremy Allison
39f8afa866 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.
(This used to be commit 6a7919f254)
2004-02-04 02:09:41 +00:00
Andrew Tridgell
423ad90974 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!
(This used to be commit 8b8f0c5279)
2004-02-02 12:02:43 +00:00
Gerald Carter
b20f1a95a9 * 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
(This used to be commit 79fe75dcdf)
2004-01-15 19:03:18 +00:00
Andrew Bartlett
5eee23cc64 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
(This used to be commit 494781f628)
2003-12-31 00:31:43 +00:00
Jeremy Allison
c4167baca1 Get a little paranoid about memfree use in convert_string_allocate..
Looking at crash bugs #809 and others.
Jeremy.
(This used to be commit cd2075580b)
2003-12-01 22:46:46 +00:00
Richard Sharpe
e6994778ec Fix a couple of warnings with casts.
(This used to be commit 58d7a51c57)
2003-11-13 17:27:21 +00:00
Jeremy Allison
bb0598faf5 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.
(This used to be commit d7e35dfb92)
2003-10-22 23:38:20 +00:00
Jeremy Allison
cba653c30a 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.
(This used to be commit f23acb4ca5)
2003-09-13 22:41:21 +00:00
Jeremy Allison
ee51d6aabe 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.
(This used to be commit 035f595995)
2003-09-10 02:21:24 +00:00
Jeremy Allison
16e6d22408 Fix valgrind-found read of uninit variable (ensure length is right).
Jeremy.
(This used to be commit 6fc0e529f7)
2003-09-08 21:26:30 +00:00
Jeremy Allison
966b0fc7c9 More cachegrind tuning, plus fix an error message.
Jeremy.
(This used to be commit 8cb9ec5d53)
2003-09-05 21:30:50 +00:00
Jeremy Allison
94f59f5492 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.
(This used to be commit f35e9a8b90)
2003-09-05 19:59:55 +00:00
Jeremy Allison
0e8c2a4133 More hand-tuning of the fastpath. Don't do strlen() when we're doing
to walk to the end anyway.
Jeremy.
(This used to be commit 467cafdb1f)
2003-09-04 23:03:58 +00:00
Jeremy Allison
22831019dc Remove convert_string_internal completely from fast path when processing
NBENCH calls. Requires fixed buffer size for strdup_upper().
Jeremy.
(This used to be commit e98fbfaf38)
2003-09-04 18:40:55 +00:00
Jeremy Allison
245fbf7efb 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.
(This used to be commit ef140d15ea)
2003-09-04 01:12:39 +00:00
Jeremy Allison
dac11b890b 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.
(This used to be commit 236d6adadf)
2003-08-23 01:59:14 +00:00
Jeremy Allison
a8eda05d75 Shut conversion errors up when initialising tables.
Jeremy.
(This used to be commit 94d0f888c9)
2003-08-21 23:55:29 +00:00
Jeremy Allison
ecddae8bf0 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.
(This used to be commit cfde7477fd)
2003-08-20 22:06:19 +00:00
Andrew Bartlett
4b3e0268b5 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
(This used to be commit 6c9056029b)
2003-07-27 02:40:06 +00:00
Andrew Bartlett
455bb6de90 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
(This used to be commit 912035af11)
2003-07-27 02:28:25 +00:00
Tim Potter
7d833de662 More printf portability fixes. Got caught out by some gcc'isms last
time.  )-:
(This used to be commit 59dae1da66)
2003-07-25 04:24:40 +00:00
Tim Potter
77373f1f8e More printf fixes - size_t is long on some architectures.
(This used to be commit ba4d334b82)
2003-07-24 23:46:27 +00:00