1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-31 17:18:04 +03:00
Commit Graph

167 Commits

Author SHA1 Message Date
Tim Prouty
59124382d2 Cleanup size_t return values in convert_string_allocate
This patch is the first iteration of an inside-out conversion to cleanup
functions in charcnv.c returning size_t == -1 to indicate failure.
2008-04-11 11:33:33 +02:00
Michael Adam
5f6c730cbe charcnv: add talloc_strdup_lower() - talloc variant of strdup_lower().
Michael
2008-04-10 01:27:56 +02:00
Jeremy Allison
aab736e607 Ensure that convert_string_allocate() allocates 2 extra
bytes and null terminates them to ensure NDR wire-reads
of string types are always null terminated. Bug found by
Volker after great pain :-).
Jeremy.
2008-02-01 14:23:54 -08:00
Jeremy Allison
329b924cba Fixup hot paths - add macro for toupper (c < 0x80).
This now matches 3.0.x on my micro-tests.
Jeremy.
2008-01-09 17:32:26 -08:00
Volker Lendecke
b6d1d24288 Make init_doschar_table() static
It's only called directly before init_valid_table() anyway, so move it there.
2007-12-16 10:56:58 -08:00
Jeremy Allison
c87f3eba9a Remove pstrings from client/client.c by doing a large rewrite.
Mostly compiles....
Jeremy.
2007-12-06 17:16:33 -08:00
Jeremy Allison
288aacce4b pull_ascii_pstring is gone.
Jeremy.
2007-12-04 17:05:33 -08:00
Jeremy Allison
063358d87a Allow STR_TERMINATE and -1 src_len for pull_ucs2_base_talloc().
Jeremy.
2007-12-04 15:21:14 -08:00
Jeremy Allison
bac3bb2f6e More trivial pstring removal.
Jeremy.
2007-11-20 15:31:37 -08:00
Jeremy Allison
c21e9bdc10 Start to remove some of the pstring functions we're
no longer using.
Jeremy.
2007-11-19 17:51:21 -08:00
Jeremy Allison
f35a266b3c RIP BOOL. Convert BOOL -> bool. I found a few interesting
bugs in various places whilst doing this (places that assumed
BOOL == int). I also need to fix the Samba4 pidl generation
(next checkin).
Jeremy.
2007-10-18 17:40:25 -07:00
Jeremy Allison
32626e2b97 r25277: Belt-and-braces approach to Volker's fix for RPC-SAMBA3-GETUSERNAME.
If we promise dest is null terminated, ensure we do it even on
fast path exits.
Jeremy.
2007-10-10 12:30:57 -05:00
Michael Adam
8b5c34b7d1 r25258: Fix a panic message and remove superfluous return after the call to smb_panic().
Michael
2007-10-10 12:30:55 -05:00
Jeremy Allison
abedd96786 r25238: Make the error returns from the string functions
always consistent. Return -1 on error, and ensure
we check for this. In cases where the dest is already
specified and we've been asked to terminate with a
null, ensure we always do so even on error.
Jeremy.
2007-10-10 12:30:53 -05:00
Jeremy Allison
9fc14c83cc r25222: Fix last assumptions that (size_t)-1 can be used
as a special dest_len of sizeof(pstring).
Jeremy.
2007-10-10 12:30:51 -05:00
Jeremy Allison
db1b629377 r25199: Remove pstring from strdup_upper - make it the
same as talloc_strdup_upper.
Jeremy.
2007-10-10 12:30:51 -05:00
Jeremy Allison
8bb85f3f14 r25195: Fix issue with calling pull_uc2_*alloc with
str_len == 0. We should just return 0 in this
case.
Jeremy.
2007-10-10 12:30:50 -05:00
Volker Lendecke
b64df8a3c5 r25184: Fix some C++ warnings and an uninitialized variable 2007-10-10 12:30:49 -05:00
Jeremy Allison
39c211a702 r25138: More pstring elimination. Add a TALLOC_CTX parameter
to unix_convert().
Jeremy.
2007-10-10 12:30:44 -05:00
Jeremy Allison
54c658867d r25136: When tallocing a string to uppercase remember the terminating
'\0' in size calculations.
Jeremy.
2007-10-10 12:30:43 -05:00
Jeremy Allison
9cc70e3ccf r25120: One more warning.
Jeremy.
2007-10-10 12:30:42 -05:00
Jeremy Allison
7f0db75fb0 r25117: The mega-patch Jerry was waiting for. Remove all pstrings from
the main server code paths. We should now be able to cope with
paths up to PATH_MAX length now.
Final job will be to add the TALLOC_CTX * parameter to
unix_convert to make it explicit (for Volker).
Jeremy.
2007-10-10 12:30:41 -05:00
Jeremy Allison
0c9a8c4dff r25111: Move to talloced pathnames on most code paths.
There are now ony 17 pstrings left in reply.c,
and these will be easy to remove (and I'll be
doing that shortly). Had to fix an interesting
bug in pull_ucs2_base_talloc() when a source
string is not null terminated :-).
Jeremy.
2007-10-10 12:30:41 -05:00
Jeremy Allison
dee8beba7a r25009: Large patch discussed with Volker. Move unix_convert to a talloc-based
interface. More development will come on top of this. Remove the
"mangled map" parameter.
Jeremy.
2007-10-10 12:30:32 -05:00
Volker Lendecke
824eb26738 r24133: Explicitly pass flags2 down to push_string_fn
This needs a bit closer review, it also touches the client libs
2007-10-10 12:29:10 -05:00
Volker Lendecke
a40d3a566a r23865: Fix a type-punned error 2007-10-10 12:28:35 -05:00
Jeremy Allison
b4eff3f680 r23858: Added srvstr_pull_buf_talloc() and srvstr_pull_talloc()
calls and converted reply_tcon and reply_tconX to use
them - to show the boilerplate usage (valgrind tested).
In conjunction with Volker's srvstr_get_path_talloc()
work this should allow us to start eliminating all
pstrings/fstrings out of the main path processing
code.
I'll watch the build farm tonight...
Jeremy.
2007-10-10 12:28:35 -05:00
Andrew Tridgell
b0132e94fc r23784: use the GPLv3 boilerplate as recommended by the FSF and the license text 2007-10-10 12:28:22 -05:00
Jeremy Allison
407e6e695b r23779: Change from v2 or later to v3 or later.
Jeremy.
2007-10-10 12:28:20 -05:00
Volker Lendecke
836782b07b r23726: Explicitly pass down the FLAGS2 field to srvstr_pull_buf. The next
checkin will pull this up to srvstr_get_path. At that point we can get more
independent of the inbuf, the base_ptr in pull_string will only be used
to satisfy UCS2 alignment constraints.
2007-10-10 12:23:49 -05:00
Volker Lendecke
c195eccefe r23662: According to simo, check_dos_char is needed 2007-10-10 12:23:43 -05:00
Volker Lendecke
7e9a4c39a5 r23660: Anybody know what check_dos_char() was used for? It wasn't called at
all, so it's gone. With it 8k bss went away.
2007-10-10 12:23:43 -05:00
James Peach
171dc060e2 r23510: Tidy calls to smb_panic by removing trailing newlines. Print the
failed expression in SMB_ASSERT.
2007-10-10 12:23:23 -05:00
Jeremy Allison
14b167ef6e r22754: When processing a string, ensure we don't write one past
the terminating NULL if we've already processed the null
in iconv. Jerry, once I get confirmation from Thomas Bork
this needs to be in 3.0.25 final. Tests fine with valgrind
here.
Jeremy.
2007-10-10 12:21:54 -05:00
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