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

4780 Commits

Author SHA1 Message Date
Volker Lendecke
4a9fe4efef libsmb: Protect cli_RNetShareEnum() against rprcnt<6
Bug: https://bugzilla.samba.org/show_bug.cgi?id=14362
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
2020-05-05 15:35:35 +00:00
Volker Lendecke
ae91d67a24 libsmb: Fix indentation in cli_RNetShareEnum()
Also remove a level of indentation with a "goto done;"

Best review with "git show -b", almost no code change

Bug: https://bugzilla.samba.org/show_bug.cgi?id=14362
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
2020-05-05 15:35:35 +00:00
Volker Lendecke
2e3be1394c libsmb: Add a NULL check
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2020-05-05 11:48:39 +00:00
Volker Lendecke
157554f3d8 libsmb: Align integer types in net_share_enum_rpc()
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2020-05-05 11:48:39 +00:00
Volker Lendecke
3d2abb6772 libsmb: Use talloc_strndup() to cut a backslash
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2020-05-05 11:48:39 +00:00
Volker Lendecke
2d6448a3df libsmb: Add a NULL check after talloc_strdup()
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2020-05-05 11:48:39 +00:00
Gary Lockyer
f467727db5 CVE-2020-10704: lib util asn1: Add ASN.1 max tree depth
Add maximum parse tree depth to the call to asn1_init, which will be
used to limit the depth of the ASN.1 parse tree.

Credit to OSS-Fuzz

REF: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=20454
BUG: https://bugzilla.samba.org/show_bug.cgi?id=14334

Signed-off-by: Gary Lockyer <gary@catalyst.net.nz>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2020-05-04 02:59:31 +00:00
Volker Lendecke
b57bb1fe22 libsmb: Add cli_setfileinfo_ext()
Analogue to cli_setpathinfo_ext()

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2020-04-28 09:08:39 +00:00
Volker Lendecke
9b63cbd789 libsmb: Factor out prep_basic_information_buf()
Will be used in cli_setfileinfo_ext next

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2020-04-28 09:08:39 +00:00
Volker Lendecke
092da6ec07 libsmb: Move clirap2.c to utils/
It's only used in net_rap.c, expansion to other users is
unlikely. Don't link it into libsmbclient anymore. It saves roughly
50k from the everywhere-linked libsmb.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>

Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Sat Apr 18 04:12:48 UTC 2020 on sn-devel-184
2020-04-18 04:12:48 +00:00
Volker Lendecke
aa22ae6b40 libsmb: Slightly simplify get_ipc_connect()
No else required with an early return

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2020-04-18 02:29:34 +00:00
Volker Lendecke
67b097b823 libsmb: Move get_ipc_connect_master_ip_bcast() to smbtree.c
... the only user

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2020-04-08 14:46:40 +00:00
Volker Lendecke
c7022803ed libsmb: Remove unused cli_NetWkstaUserLogon()
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2020-04-08 14:46:40 +00:00
Volker Lendecke
cfd0a8a738 libsmb: Respect the full timeval for smbc_utimes()
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2020-04-08 14:46:40 +00:00
Volker Lendecke
810397f89a libsmbclient: Don't throw away nsec fields in stat()
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2020-04-08 14:46:40 +00:00
Volker Lendecke
b22b4daeba libsmb: Remove unused cli_setpathinfo_basic()
We got beyond 1-sec timestamp resolution a while ago...

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2020-04-08 14:46:40 +00:00
Volker Lendecke
7b246696c8 libsmb: Call cli_setpathinfo_ext() instead of .._basic()
Yes, the formatting is not according to README.Coding, but that's a
patch for another day.

Also, this is no functional change: All callers so far either set
.tv_sec only or set .tv_nsec to SAMBA_UTIME_OMIT.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2020-04-08 14:46:40 +00:00
Volker Lendecke
e4aa9a970a libsmb: Pass "struct timespec" to SMBC_setatr()
Prepare to set higher-precision timestamps. No change in behaviour so
far: The {.tv_nsec=SAMBA_UTIME_OMIT} implicitly sets .tv_sec=0, and
SMBC_setatr() only looks at .tv_sec

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2020-04-08 14:46:40 +00:00
Volker Lendecke
aa1f34219d libsmb: Make cli_setpathinfo_ext() take structs instead of pointers
This simplifies the next commit: With direct (small) structs on the
stack we don't need declared variables in the callers

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2020-04-08 14:46:39 +00:00
Volker Lendecke
6cb1f20f73 libsmb: Use cli_setfileinfo_send() in cli_ftruncate_send()
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2020-04-08 14:46:39 +00:00
Volker Lendecke
b46b5a6408 libsmb: Use cli_setfilefinfo_send() in cli_nt_delete_on_close_send()
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2020-04-08 14:46:39 +00:00
Volker Lendecke
bf61a0d7f3 libsmb: Add cli_setfileinfo_send/recv()
Encapsulate TRANSACT2_SETFILEINFO like cli_setpathinfo_send() does for
TRANSACT2_SETPATHINFO.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2020-04-08 14:46:39 +00:00
Volker Lendecke
fbf55d124d libsmb: Remove a typedef
No API change, this is not used publically

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2020-04-08 14:46:39 +00:00
Volker Lendecke
eadbaabca1 libsmb: Use ARRAY_DEL_ELEMENT() in remove_duplicate_addrs2()
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2020-03-26 14:43:31 +00:00
Volker Lendecke
487ca0754d libsmb: Use ARRAY_DEL_ELEMENT() in sort_acl()
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Ralph Boehme <slow@samba.org>
2020-03-26 14:43:31 +00:00
Andrew Bartlett
5c1867ba45 py3: Remove #define PyInt_FromLong PyLong_FromLong
This allows us to end the use of Python 2/3 compatability macros.

Signed-off-by: Andrew Bartlett <abartlet@samba.org>
Reviewed-by: Noel Power
2020-03-23 19:12:43 +00:00
Volker Lendecke
39c910fd9c libsmb: Don't try to find posix stat info in SMBC_getatr()
This wrongly used "frame" instead of "fname", which can never have
worked. A first attempt to fix in 51551e0d53 caused a few followup
patches in an attempt to clean up the test failures 51551e0d53
introduced. They were reverted after a few discussions. So rather than
changing behaviour, just remove the code that introduced the valgrind
error again.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>

Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Fri Mar 20 05:06:07 UTC 2020 on sn-devel-184
2020-03-20 05:06:07 +00:00
Volker Lendecke
9653a10738 libsmbclient: Put it back to a known, well-working state
For adapting unix extensions in our client libraries, we need a fresh start
with additional APIs. We can't change existing application behaviour.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2020-03-10 21:25:33 +00:00
Volker Lendecke
a1856f07b3 libsmb: Use posix open in SMBC_open_ctx
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2020-03-03 17:48:38 +00:00
Volker Lendecke
c2e012fe11 libsmb: Use posix result in SMBC_readdirplus2_ctx
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2020-03-03 17:48:37 +00:00
Volker Lendecke
890c94d585 libsmb: Implement SMB_FIND_FILE_UNIX_INFO2 dir listing
This keeps the original SMB_STRUCT_STAT coming from posix as part of
struct file_info. It is a slight waste of space, as the timestamps are
kept twice, but having a full SMB_STRUCT_STAT with the nlink!=0
validity check makes thinking about which mode/size/etc is the correct
one a no-brainer. We can save space later by referencing only one set
of time stamps for example.

This for the time fixes readdirplus2, but for the wrong reason: We don't yet
create files the "proper" way using posix create.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2020-03-03 17:48:37 +00:00
Volker Lendecke
128545ba4f libsmb: Introduce fetch_file_unix_basic_info2()
Will be used in clilist.c for SMB_FIND_FILE_UNIX_INFO2

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2020-03-03 17:48:37 +00:00
Volker Lendecke
9cc546956d libsmb: Factor out fetch_file_unix_basic_info()
Will be used in clilist.c for SMB_FIND_FILE_UNIX_INFO2

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2020-03-03 17:48:37 +00:00
Volker Lendecke
edfc19f1eb libsmb: Fix a typo
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2020-03-03 17:48:37 +00:00
Stefan Metzmacher
b1ebfec39e s3:libsmb: move cli_set_message() to source3/libsmb/nmblib.c
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2020-02-26 19:45:36 +00:00
Stefan Metzmacher
03562cf128 s3:libsmb: use only a timeout of 250ms in name_resolve_bcast_send()
We use the same value for broadcasts in name_query().

Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2020-02-26 19:45:36 +00:00
Stefan Metzmacher
08a7f5c47d s3:libsmb: pass dest_ss to cli_cm_open()
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2020-02-26 19:45:36 +00:00
Stefan Metzmacher
e0c502728f s3:libsmb: pass dest_ss to cli_cm_connect() down to cli_connect_nb()
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2020-02-26 19:45:36 +00:00
Volker Lendecke
c3242b4dfc libsmb: Fill in device which we don't get from cli_posix_stat
SMB1 unix extensions don't carry st_dev for stat

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14101

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>

Autobuild-User(master): Jeremy Allison <jra@samba.org>
Autobuild-Date(master): Wed Feb 26 00:50:32 UTC 2020 on sn-devel-184
2020-02-26 00:50:32 +00:00
Volker Lendecke
51551e0d53 libsmb: Pass the correct path to cli_posix_stat()
This fixes doing strlen() on talloc_tos(), about which valgrind is pretty
unhappy. Without this patch we survive the tests because we have fallbacks to
the non-posix flavors of stat(). With this patch in place cli_posix_stat()
becomes functional in this code path. This creates conflicts with the readdir
libsmbclient tests, which need fixing separately.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14101

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2020-02-25 23:23:39 +00:00
Volker Lendecke
15769f11a4 libsmb: Don't pass "sbuf" to cli_posix_stat_send()
Don't pass in the result buffer upon _send(), let the _recv() function
fill this in. Internal API only, adapt to current conventions.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2020-02-25 17:44:45 +00:00
Volker Lendecke
6d282d610f libsmb: Avoid casts
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2020-02-25 17:44:45 +00:00
Volker Lendecke
42f744d871 libsmb: Use IS[DOT]DOT
strequal is not necessary here

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2020-02-25 17:44:44 +00:00
Volker Lendecke
78eae77ec1 libsmb: Remove a pointless ZERO_STRUCT()
"c" is a pointer that was initialized to NULL above

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2020-02-25 17:44:44 +00:00
Volker Lendecke
d7281e3210 libsmb: Simplify callers of SMBC_dlist_contains()
This function already does the NULL check on the file pointer

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2020-02-25 17:44:44 +00:00
Volker Lendecke
427e10e8e3 libsmb: Make SMBC_dlist_contains return bool
It returned True/False, and is used as boolean only. Modernize
formatting a bit.

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2020-02-25 17:44:44 +00:00
Volker Lendecke
c3a2cc9ba2 libsmb: Align calls to SMBC_dlist_contains()
Everywhere else it's called as !SMBC_dlist_contains()

Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2020-02-25 17:44:44 +00:00
Volker Lendecke
a4a96a90bf libsmb: Add a NULL check
Signed-off-by: Volker Lendecke <vl@samba.org>
Reviewed-by: Jeremy Allison <jra@samba.org>
2020-02-25 17:44:44 +00:00
Stefan Metzmacher
c403fa1a7f krb5_wrap: move source3/libads/krb5_errs.c to lib/krb5_wrap/krb5_errs.c
Signed-off-by: Stefan Metzmacher <metze@samba.org>
Reviewed-by: Andreas Schneider <asn@samba.org>
2020-02-10 16:32:37 +00:00
Douglas Bagnall
3bc7acc626 nmblib: avoid undefined behaviour in handle_name_ptrs()
If *offset is length - 1, we would read ubuf[(*offset)+1] as the lower
bits of the new *offset. This value is undefined, but because it is
checked against the valid range, there is no way to read further
beyond that one byte.

Credit to oss-fuzz.

BUG: https://bugzilla.samba.org/show_bug.cgi?id=14242
OSS-Fuzz: https://bugs.chromium.org/p/oss-fuzz/issues/detail?id=20193

Signed-off-by: Douglas Bagnall <douglas.bagnall@catalyst.net.nz>
Reviewed-by: Jeremy Allison <jra@samba.org>
Reviewed-by: Andrew Bartlett <abartlet@samba.org>

Autobuild-User(master): Andrew Bartlett <abartlet@samba.org>
Autobuild-Date(master): Fri Feb  7 10:19:39 UTC 2020 on sn-devel-184
2020-02-07 10:19:39 +00:00