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

171 Commits

Author SHA1 Message Date
Volker Lendecke
fd2bac9667 For read&x replies, check the offset 2008-12-13 10:30:02 +01:00
Volker Lendecke
7fbb64d726 Simplify async programming a bit with helper routines
Introduce async_req_is_error() and async_req_simple_recv()
2008-12-08 22:09:33 +01:00
Jelmer Vernooij
4746f79d50 Use {u,}int64_t instead of SMB_BIG_{U,}INT. 2008-10-14 01:59:36 +02:00
Volker Lendecke
f294f51bf0 Remove cli_request_get()
req->private_data==NULL at this point is definitely a bug.
(This used to be commit ce3dc9f616)
2008-08-28 18:22:49 +02:00
Volker Lendecke
128524930d Add cli_pull_reply
Along the lines of cli_request_send this abstracts away the smb-level buffer
handling when parsing replies we got from the server.
(This used to be commit 253134d3aa)
2008-08-28 17:53:37 +02:00
Volker Lendecke
2650207d4a Remove cli->event_ctx, pass it explicitly
Storing the event_context as permanent state in struct cli_state creates more
complex code than necessary IMO.
(This used to be commit debb37f703)
2008-08-28 17:53:37 +02:00
Volker Lendecke
58aa97c0d9 Refactoring: Add the routine cli_request_send()
cli_request_send() is supposed to bundle all generic SMB-header handling. This
makes cli_request_new static to async_smb.c.
(This used to be commit 7e73dd4e76)
2008-08-28 17:53:36 +02:00
Volker Lendecke
1924e7931c Revert "Protect against short read&x replies"
This reverts commit 4ed73cbbbe.

... how did this end up here??

Volker
(This used to be commit 7dd9fd0956)
2008-08-23 15:41:00 +02:00
Volker Lendecke
56cd17dfe1 Protect against short read&x replies
(This used to be commit 4ed73cbbbe)
2008-08-23 15:12:39 +02:00
Volker Lendecke
711efc06c8 cli_request_new() already gave use the req, remove a pointless function call
(This used to be commit 08e97bd369)
2008-08-01 20:46:10 +02:00
Jeremy Allison
d36434f312 Security fix for CVE-2008-1105: Boundary failure when parsing SMB responses
can result in a buffer overrun.
Jeremy.
(This used to be commit 23b825e9d2)
2008-05-28 09:31:42 -07:00
Jeremy Allison
b04bcefc58 Fix bug #5479, print spool shares require max_xmit to
be adhered to.
Jeremy.
(This used to be commit 478a359ede)
2008-05-21 12:39:08 -07:00
Volker Lendecke
b7d2e94296 Fix bug 5399
Thanks to Jason Mader!

Volker
(This used to be commit 36740f4959)
2008-04-19 17:04:09 +02:00
Jeremy Allison
d1e99642f7 Fix bug #5326 - OS/2 servers give strange "high word" replies for print jobs.
Jeremy.
(This used to be commit d090d25cb7)
2008-03-28 10:12:07 -07:00
Volker Lendecke
8f6b03b673 More ssize_t->SMB_OFF_T
(This used to be commit 8dd6458049)
2008-03-28 15:32:02 +01:00
Volker Lendecke
4b3351e5dc On Solaris, size_t seems to be only 32 bit.
Fix bug 5341, thanks a lot to Karoly Vegh for testing it!

Volker
(This used to be commit 19eb8c9316)
2008-03-21 13:41:42 +01:00
Volker Lendecke
b2ec8372ba !NT_STATUS_IS_OK != NT_STATUS_IS_ERR
When reading from a pipe, Windows return STATUS_BUFFER_OVERFLOW which is *not*
an error.
(This used to be commit 24018d882d)
2008-03-19 22:38:13 +01:00
Volker Lendecke
16cbc22a99 Fix bug 5334
I did not test with a zero length file :-)
(This used to be commit 7d7a73944c)
2008-03-18 13:49:46 +01:00
Volker Lendecke
973734cde6 Correctly calculate the max read size
(This used to be commit f556c9e162)
2008-03-08 22:28:01 +01:00
Volker Lendecke
a015227490 Convert cli_read to use cli_pull
(This used to be commit d69b20111a)
2008-03-06 13:28:23 +01:00
Volker Lendecke
6244578835 Add async cli_pull support
This is the big (and potentially controversial) one. It took a phone call to
explain to metze what is going on inside cli_pull_read_done, but I would really
like everybody to understand this function. It is a very good and reasonably
complex example of async programming. If we want more asynchronism in s3, this
is what we will have to deal with :-)

Make use of it in the smbclient "get" command.

Volker
(This used to be commit 76f9b360ee)
2008-03-06 13:28:23 +01:00
Jeremy Allison
f44713df4d Fix bug found by Derrell - windows returns an read return
offset of zero if return size is zero. Should fix testread
libsmbclient code.
Jeremy.
(This used to be commit df3c464839)
2008-01-16 17:33:19 -08:00
Jeremy Allison
d7582b5186 Windows insists on write sizes < max_xmit on signed connections.
Jeremy.
(This used to be commit ef9b278b62)
2008-01-14 13:46:06 -08:00
Jeremy Allison
afc93255d1 Add SMB encryption. Still fixing client decrypt but
negotiation works.
Jeremy.
(This used to be commit d78045601a)
2007-12-26 17:12:36 -08:00
Jeremy Allison
7498e1b8c0 Ensure we don't use massive writes in pipe mode.
Jeremy.
(This used to be commit 47640fb20e)
2007-11-06 14:12:38 -08:00
Jeremy Allison
329365684b Change the client library to write directly out of
the incoming buffer in the non-signed case. Speeds
up writes by over 10% or so. Complete the server
recvfile implementation.
Jeremy.
(This used to be commit 81ca5853b2)
2007-11-02 12:21:34 -07:00
Jeremy Allison
f5dcac6e8e Our userlevel SMBwriteX call is non-standard in that it
sometimes uses a 12-word write and doesn't include a pad
byte (as Windows does). Fix this so that we are identical
to Windows clients. This will make recvfile processing
much easier to detect (as we can just read a standard
writeX header length to decide).
Jeremy.
(This used to be commit 3d3d1b806a)
2007-10-30 12:54:39 -07:00
Jeremy Allison
30191d1a57 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.
(This used to be commit f35a266b3c)
2007-10-18 17:40:25 -07:00
Gerald (Jerry) Carter
e5a951325a [GLUE] Rsync SAMBA_3_2_0 SVN r25598 in order to create the v3-2-test branch.
(This used to be commit 5c6c8e1fe9)
2007-10-10 15:34:30 -05:00
Andrew Tridgell
5e54558c6d r23784: use the GPLv3 boilerplate as recommended by the FSF and the license text
(This used to be commit b0132e94fc)
2007-10-10 12:28:22 -05:00
Jeremy Allison
d824b98f80 r23779: Change from v2 or later to v3 or later.
Jeremy.
(This used to be commit 407e6e695b)
2007-10-10 12:28:20 -05:00
Jeremy Allison
4d6caa09e2 r23148: Fix old old bug in cli_smbwrite() (not incrementing
data being sent). Patch from mnix@wanm.com.au.
Jeremy.
(This used to be commit 2524d85465)
2007-10-10 12:22:48 -05:00
Jeremy Allison
32106b2395 r22920: Add in the UNIX capability for 24-bit readX, as discussed
with the Apple guys and Linux kernel guys. Still looking
at how to do writeX as there's no recvfile().
Jeremy.
(This used to be commit a53268fb20)
2007-10-10 12:22:08 -05:00
Jeremy Allison
0829e1ad1c r22391: Looks bigger than it is. Make "inbuf" available
to all callers of smb_setlen (via set_message()
calls). This will allow the server to reflect back
the correct encryption context.
Jeremy.
(This used to be commit 2d80a96120)
2007-10-10 12:19:30 -05:00
Volker Lendecke
02eea79624 r17333: Some C++ warnings
(This used to be commit be9aaffdac)
2007-10-10 11:38:26 -05:00
Jeremy Allison
7b75d2c650 r15162: Patch for bug #3668. Windows has a bug with LARGE_READX
where if you ask for exactly 64k bytes it returns 0.
Jeremy.
(This used to be commit dcef65acb5)
2007-10-10 11:16:27 -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
7756059d38 r13119: Fix for #1779 from William Jojo <jojowil@hvcc.edu>
Jeremy.
(This used to be commit 103cac7dd3)
2007-10-10 11:06:14 -05:00
Gerald Carter
54abd2aa66 r10656: BIG merge from trunk. Features not copied over
* \PIPE\unixinfo
* winbindd's {group,alias}membership new functions
* winbindd's lookupsids() functionality
* swat (trunk changes to be reverted as per discussion with Deryck)
(This used to be commit 939c3cb5d7)
2007-10-10 11:04:48 -05:00
Tim Potter
ab398643a4 r8572: Remove crufty #define NO_SYSLOG as it's not used at all anymore.
(This used to be commit 985dbb47d9)
2007-10-10 11:00:11 -05:00
Jeremy Allison
9e3453459c r4212: Ensure we only look at the bottom bit of large_readx.
Set the 14 word version of write if size > 0xffff as
well as 64-bit offset.
Jeremy.
(This used to be commit 94779ccb39)
2007-10-10 10:53:37 -05:00
Jeremy Allison
4730a56263 r4188: Ensure we add in the upper length in the right place !
Jeremy.
(This used to be commit 9d4e57f06c)
2007-10-10 10:53:36 -05:00
Jeremy Allison
5b713a206b r4186: Fix client & server to allow 127k READX calls.
Jeremy.
(This used to be commit 831cb21a87)
2007-10-10 10:53:36 -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
Richard Sharpe
26c106e083 r2959: If we want to support writes >= 65536 with cli_write, then it had better
return a size_t, not an ssize_t, and we had better left shift the upper
part of the write count, not right shift it.
(This used to be commit 3eb33fbc64)
2007-10-10 10:52:57 -05:00
Jeremy Allison
40a89ce884 r2373: Fix typo.
Jeremy.
(This used to be commit b1033fc77c)
2007-10-10 10:52:41 -05:00
Jeremy Allison
41b3720713 r2371: Fix for talking to OS/2 clients (max_mux ignored) by Guenter Kukkukk <guenter.kukkukk@kukkukk.com>.
Bugid #1590.
Jeremy.
(This used to be commit 330025d1a6)
2007-10-10 10:52:41 -05:00
Jeremy Allison
38b3ee6467 RPC fix from Ronan Waide <waider@waider.ie>. Tested with rpcecho.
Jeremy.
(This used to be commit 68590b9e22)
2003-08-08 17:08:35 +00:00
Gerald Carter
99cdb46208 *lots of small merges form HEAD
*sync up configure.in
*don't build torture tools in make all
*make sure to remove torture tools as part of make clean
(This used to be commit 0fb724b321)
2003-01-15 18:57:41 +00:00
Andrew Bartlett
634c54310c Merge from HEAD - make Samba compile with -Wwrite-strings without additional
warnings.  (Adds a lot of const).

Andrew Bartlett
(This used to be commit 3a7458f947)
2003-01-03 08:28:12 +00:00
Jeremy Allison
266c1ece12 Merge Richard's write > 4Gb fix.
Jeremy.
(This used to be commit 5431bae894)
2002-12-30 06:12:13 +00:00
Herb Lewis
41969738a4 merge from 2.2 fix for smbclient large files
(This used to be commit 17f685fdbf)
2002-12-19 20:26:44 +00:00
Jeremy Allison
296c93923c Test was reversed for ERRmoredata in cli_read.
Jeremy.
(This used to be commit fff7f3cbe2)
2002-11-27 19:11:46 +00:00
Gerald Carter
a834a73e34 sync'ing up for 3.0alpha20 release
(This used to be commit 65e7b5273b)
2002-09-25 15:19:00 +00:00
Andrew Tridgell
e90b652848 updated the 3.0 branch from the head branch - ready for alpha18
(This used to be commit 03ac082dcb)
2002-07-15 10:35:28 +00:00
Jeremy Allison
a1249aca90 Correctly increment offset in cli_smbwrite.
Jeremy.
(This used to be commit 5b04b5f1df)
2002-03-20 01:47:31 +00:00
Jeremy Allison
5e09ffdc7c Test against W2K that we're doing large read/writes correctly (we are).
At least with 14 word writes.
Jeremy.
(This used to be commit 24ef6258a1)
2002-03-20 01:43:06 +00:00
Tim Potter
cd68afe312 Removed version number from file header.
Changed "SMB/Netbios" to "SMB/CIFS" in file header.
(This used to be commit 6a58c9bd06)
2002-01-30 06:08:46 +00:00
Jeremy Allison
d6823366b8 Same fix as went into 2.2 (I'm waiting for jerry to finish some code).
Jeremy.
(This used to be commit 01ff6ce496)
2002-01-11 19:10:25 +00:00
Andrew Tridgell
d53d5beeb2 use cli_is_error() instead of looking in smb_rcls, otherwise NT status
codes don't work correctly
(This used to be commit 55d5828e60)
2001-09-05 11:32:59 +00:00
Andrew Tridgell
ee5f7237de started converting NTSTATUS to be a structure on systems with gcc in order to make it type incompatible with BOOL so we catch errors sooner. This has already found a number of bugs
(This used to be commit 1b778bc7d2)
2001-08-27 17:52:23 +00:00
Jeremy Allison
364d0e56e9 Re-added readbraw call to test with smbtorture. This code not yet
tested...
Jeremy.
(This used to be commit fe85a19b4b)
2001-08-24 20:20:08 +00:00
Tim Potter
2ccfea3de7 A rewrite of the error handling in the libsmb client code. I've separated
out the error handling into a bunch of separate functions rather than all
being handled in one big function.

Fetch error codes from the last received packet:

    void cli_dos_error(struct cli_state *cli, uint8 *eclass, uint32 *num);
    uint32 cli_nt_error(struct cli_state *);

Convert errors to UNIX errno values:

    int cli_errno_from_dos(uint8 eclass, uint32 num);
    int cli_errno_from_nt(uint32 status);
    int cli_errno(struct cli_state *cli);

Detect different kinds of errors:

    BOOL cli_is_dos_error(struct cli_state *cli);
    BOOL cli_is_nt_error(struct cli_state *cli);
    BOOL cli_is_error(struct cli_state *cli);

This also means we now support CAP_STATUS32 as we can decode and understand
NT errors instead of just DOS errors.  Yay!

Ported a whole bunch of files in libsmb to use this new API instead of the
just the DOS error.
(This used to be commit 6dbdb0d813)
2001-08-10 06:00:33 +00:00
Andrew Tridgell
4592d107fc cli_read() was reading too many bytes.
(This used to be commit ba79d2a030)
2001-07-01 13:18:35 +00:00
Jeremy Allison
5fb9a869b7 Use a logical cli_read(), removed the cli_read_one() hack.
Jeremy.
(This used to be commit 2999eab5ab)
2001-06-29 00:22:22 +00:00
Tim Potter
ff5a18ad3e Merged cli_read_one() function for reading DCE/RPC reply fragments.
(This used to be commit 9e074bc2bf)
2001-06-22 01:09:40 +00:00
Andrew Tridgell
6fdffd9b6c added some comments to make the cli read code clearer
(This used to be commit bbfbe03cc6)
2001-06-22 00:42:53 +00:00
Andrew Tridgell
91b8a8d1d2 next_token() was supposed to be a reentrant replacement for strtok(),
but the code suffered from bitrot and is not now reentrant. That means
we can get bizarre behaviour
i've fixed this by making next_token() reentrant and creating a
next_token_nr() that is a small non-reentrant wrapper for those lumps
of code (mostly smbclient) that have come to rely on the non-reentrant
behaviour
(This used to be commit 674ee2f1d1)
2001-06-21 09:10:42 +00:00
Jeremy Allison
5264e9a2a7 Set correct reply word in large writeX (greater than 64k) replies.
Also added smbtorture test for this.
Jeremy.
(This used to be commit 6d65556ae8)
2001-06-05 08:17:16 +00:00
Jeremy Allison
7f36df301e Tidyup removing many of the 0xC0000000 | NT_STATUS_XXX stuff (only need NT_STATUS_XXX).
Removed IS_BITS_xxx macros as they were just reproducing "C" syntax in a more
obscure way.
Jeremy.
(This used to be commit c55bcec817)
2000-08-01 18:32:34 +00:00
Andrew Tridgell
858e63cab3 split clientgen.c into several parts
the next step is splitting out the auth code, to make adding lukes
NTLMSSP support easier
(This used to be commit 10c5470835)
2000-04-25 14:04:06 +00:00