1
0
mirror of https://github.com/samba-team/samba.git synced 2025-03-12 20:58:37 +03:00

68 Commits

Author SHA1 Message Date
Derrell Lipman
fa664b24b8 r18011: Should fix bug 3835.
Jeremy: requires your eyes...

If the remote connection timed out while cli_list() was retrieving its list of
files, the error was not returned to the user, e.g. via smbc_opendir(), so the
user didn't have a way to know to set the timeout longer and try again.  This
problem would occur when a very large directory is being read with a too-small
timeout on the cli.

Jeremy, although there were a couple of areas that needed to be handled, I
needed to make one change that you should bless, in libsmb/clientgen.c.  It
was setting

  cli->smb_rw_error = smb_read_error;

but smb_read_error is zero, so this had no effect.  I'm now doing

  cli->smb_rw_error = READ_TIMEOUT;

instead, and according to the OP, these (cumulative) changes (in a slightly
different form) solve the problem.

Please confirm this smb_rw_error change will have no other adverse effects
that you can see.

Derrell
2007-10-10 11:39:48 -05:00
Jeremy Allison
425280a1d2 r17800: Start using struct timespec internally for file times
on the wire. This allows us to go to nsec resolution
for systems that support it. It should also now be
easy to add a correct "create time" (birth time)
for systems that support it (*BSD). I'll be watching
the build farm closely after this one for breakage :-).
Jeremy.
2007-10-10 11:38:48 -05:00
Jeremy Allison
42a417fb75 r17761: Handle times consistently across all client utils.
Fixes bugs reported in libsmbclient.
Jeremy.
2007-10-10 11:38:47 -05:00
Volker Lendecke
be9aaffdac r17333: Some C++ warnings 2007-10-10 11:38:26 -05:00
Jeremy Allison
09e11dcb23 r16541: Fix #3862 reported by jason@ncac.gwu.edu.
Jeremy.
2007-10-10 11:18:58 -05:00
Jeremy Allison
65d4dfbd60 r15997: Fix bug in OS/2 Warp - it doesn't set the ff_last
offset correctly when doing info level 1 directory
scans. Thanks to Guenter Kukkukk <Guenter.Kukkukk@kukkukk.com>
for reporting this problem and testing the fix.
Jeremy.
2007-10-10 11:17:17 -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
Gerald Carter
17e63ac4ed r13316: Let the carnage begin....
Sync with trunk as off r13315
2007-10-10 11:06:23 -05:00
Derrell Lipman
ee7fcb43ad r12758: r12127@cabra: derrell | 2006-01-03 15:22:18 -0500
remove old superfluous comment and ifdef
2007-10-10 11:06:02 -05:00
Jeremy Allison
5cab88f144 r12275: Fix memory leak found by Mikhail Kshevetskiy <kl@laska.dorms.spbu.ru>
and followed up by derrell@samba.org.
Jeremy.
2007-10-10 11:05:51 -05:00
Jeremy Allison
414303bc02 r11511: A classic "friday night check-in" :-). This moves much
of the Samba4 timezone handling code back into Samba3.
Gets rid of "kludge-gmt" and removes the effectiveness
of the parameter "time offset" (I can add this back
in very easily if needed) - it's no longer being
looked at. I'm hoping this will fix the problems people
have been having with DST transitions. I'll start comprehensive
testing tomorrow, but for now all modifications are done.
Splits time get/set functions into srv_XXX and cli_XXX
as they need to look at different timezone offsets.
Get rid of much of the "efficiency" cruft that was
added to Samba back in the day when the C library
timezone handling functions were slow.
Jeremy.
2007-10-10 11:05:19 -05:00
Tim Potter
985dbb47d9 r8572: Remove crufty #define NO_SYSLOG as it's not used at all anymore. 2007-10-10 11:00:11 -05:00
Jeremy Allison
f9063b383e r7157: Ensure we abort a directory listing if we see the same
name twice between packets.
Jeremy.
2007-10-10 10:57:04 -05:00
Jeremy Allison
848940d5a9 r7151: Fix for bug #2698. If a unicode to unix charset conversion fails (due to buggy iconv?) we can
be left with a filename that doesn't exist on the remote machine. If we then do a findnext
with this file the server gets confused and restarts from the beginning of the directory,
causing directory listing loops. Fix this by keeping a copy of the "raw" filename data and
length and using this as the argument to findnext. This won't fix the incorrect iconv
conversion into the finfo struct but at least it ensures that directory listings always
terminate. Tested against NTFS and FAT directories.
Jeremy.
2007-10-10 10:57:03 -05:00
Jeremy Allison
8227675d3d r6994: Fix for bugid #2729 - it turns out resume keys are *mandatory* for
a search when listing a W2K and above server from a FATxx filesystem
only. Thanks to Steve Langasek <vorlon@debian.org> for giving me the
essential info that allowed me to reproduce and thus fix this.
Jeremy.
2007-10-10 10:56:59 -05:00
Herb Lewis
efea76ac71 r6225: get rid of warnings from my compiler about nested externs 2007-10-10 10:56:30 -05:00
Jeremy Allison
5ded615679 r5991: Fixup last entry offset correctly for level 260.
Should fix bug found by Derrell.Lipman@UnwiredUniverse.com.
Jeremy.
2007-10-10 10:56:14 -05:00
Jeremy Allison
08616ad80d r5975: Re-arrange code and comments to make more sense.
Jeremy.
2007-10-10 10:56:14 -05:00
Jeremy Allison
b0de2d761f r5973: Fix up overwrite of last 2 bytes on clilist (could cause coredump).
Jeremy.
2007-10-10 10:56:14 -05:00
Jeremy Allison
2ed7e30cbb r5970: Fix old bug where ff_searchcount was being compared -1 ! This caused a
filename to be processed twice.
Jeremy.
2007-10-10 10:56:13 -05:00
Jeremy Allison
214a2cbe5a r5967: Fix typo bug where flags overwrote info level.
Jeremy.
2007-10-10 10:56:13 -05:00
Jeremy Allison
710bceee32 r5723: Add missing part of fix for #2271. After analysing the actions of a XP
client against a Samba server. It never uses the "continue" flag, but always
does "new search, continue from this file" instead. Change our client code
to do the same (it appears that's all they test in W2K etc.).
Jeremy.
2007-10-10 10:55:57 -05:00
Jeremy Allison
4f2da9ecf1 r5702: Fix bug #2271. Correctly pull out and use resume names in a
directory listing (we were incorrectly understanding what was
returned in the "last name" entry).
Jeremy.
2007-10-10 10:55:55 -05:00
Gerald Carter
d4443807bc r5577: get recurse; dir working across single level dfs referrals 2007-10-10 10:55:48 -05:00
Gerald Carter
53d6a5f9d1 r5520: fix last remaining dfs issues with smbclient.
* all the unix extension commands should work
* send the correct TRANS2_FINDFIRST format to 2k to
  get a listing from a msdfs root share (tested against
  smbd as well).
* mkdir, rmdir, etc... all seem ok.

I'm sure bugs will pop up so keep testing.

Last thing I plan on doing is to clean up the horrible
mess with connection management in smbclient and global
variables (so i can move the cli_cm_xx() routines to a
separate file).
2007-10-10 10:55:44 -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
Jim McDonough
4319df7fdc Janitor for tpot...bugzilla #1098, msleep already exists on aix -
Jeremy Allison
ad06edd1bb Fixes to check for wraps which could cause coredumps.
Jeremy.
-
Jeremy Allison
2093a3130d Correct fix (removed the earlier band-aid) for what I thought was a signing
bug with w2k. Turns out that when we're doing a trans/trans2/nttrans call
the MID and send_sequence_number and reply_sequence_number must remain constant.
This was something we got very wrong in earlier versions of Samba. I can now
get a directory listing from WINNT\SYSTEM32 with the older earlier parameters
for clilist.c
This still needs to be fixed for the server side of Samba, client appears to
be working happily now (I'm doing a signed smbtar download of an entire W2K3
image to test this :-).
Jeremy.
-
Jeremy Allison
677d3a3c4c Fix bug we discovered in W2K client signing on secondary trans2 packets.
Use W2K parameters. tpot please re-test smbclient with your problem
directory.
Jeremy.
-
Jeremy Allison
b8f6b83646 Eliminate valgrind error when client gets bad sig on list. Some reformatting.
Jeremy.
-
Andrew Bartlett
c5b604e2ee Jeremy merged across my string parinoia fixes, but forgot to enable them! :-)
This patch catches up on the rest of the work - as much string checking
as is possible is done at compile time, and the rest at runtime.

Lots of code converted to pstrcpy() etc, and other code reworked to correctly
call sizeof().

Andrew Bartlett
-
Jeremy Allison
33b11d5eb5 Change size parameters from signed to unsigned to fix up warnings.
Jeremy.
-
Gerald Carter
0fb724b321 *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
-
Gerald Carter
7a4c874842 merging some rpcclient and net functionality from HEAD -
Jeremy Allison
8dcbfa4e77 Fix client reporting of 64 bit files.
Jeremy.
-
Herb Lewis
172dccf55e use the new IVAL_TO_SMB_OFF_T for file_info size member
dir now shows correct size on large files
-
Gerald Carter
65e7b5273b sync'ing up for 3.0alpha20 release -
Andrew Tridgell
03ac082dcb updated the 3.0 branch from the head branch - ready for alpha18 -
Tim Potter
6a58c9bd06 Removed version number from file header.
Changed "SMB/Netbios" to "SMB/CIFS" in file header.
-
Jeremy Allison
01ff6ce496 Same fix as went into 2.2 (I'm waiting for jerry to finish some code).
Jeremy.
-
Simo Sorce
48fc6a6cd5 move to SAFE_FREE() -
Andrew Tridgell
55d5828e60 use cli_is_error() instead of looking in smb_rcls, otherwise NT status
codes don't work correctly
-
Andrew Tridgell
ae669720d8 fixed shortname length in trans2 list -
Andrew Tridgell
5a3fd3317e a fix for directory listing with the dave/thursby client -
Andrew Tridgell
3eba9606f7 a bunch of fixes from the sflight to seattle
in particular:
 - fixed NT status code for a bunch of ops
 - fixed handling of protocol levels in ms_fnmatch
-
Tim Potter
a7863f0f03 Fixed crash bug when attempting to list contents of non-existent
directory.
-
Simo Sorce
fa8e55b8b4 this is a big global fix for the ptr = Realloc(ptr, size) bug.
many possible mem leaks, and segfaults fixed.

someone should port this fix to 2.2 also.
-
Tim Potter
6dbdb0d813 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.
-
Andrew Tridgell
dc99b9ddf8 fixed some unicode and LANMAN2 bugs in trans2 find first -