summaryrefslogtreecommitdiff
path: root/source3/libsmb/clilist.c
AgeCommit message (Collapse)AuthorFilesLines
2025-07-07libsmb: use parse_finfo_posix_info in is_bad_finfo_name()Ralph Boehme1-1/+3
BUG: https://bugzilla.samba.org/show_bug.cgi?id=15862 Signed-off-by: Ralph Boehme <slow@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
2025-06-16libsmb: Remove "source3/libsmb/libsmb.h"Volker Lendecke1-1/+3
libsmb.h added ads_status.h and cli_smb2_fnum.h. Only few users need either. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
2024-05-22libsmb: Remove a talloc_strdup()Volker Lendecke1-5/+1
We're directly overwriting state->mask without actually using it for anything real. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2024-05-22libsmb: Remove an unneeded NULL checkVolker Lendecke1-5/+4
We have dereferenced p_last_name_raw before in the call to data_blob_free, our only caller does give us a pointer Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2024-05-22libsmb: Remove unused cli_list_trans()Volker Lendecke1-49/+0
Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2024-05-22libsmb: Execute a "TODO", remove IVAL2_TO_SMB_BIG_UINTVolker Lendecke1-1/+1
Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Andrew Bartlett <abartlet@samba.org>
2023-10-31libsmb: infer posix context from info_levelRalph Boehme1-4/+3
No need for an explcit additional argument, we can just infer this from the info_level. Signed-off-by: Ralph Boehme <slow@samba.org> Reviewed-by: David Mulder <dmulder@samba.org>
2023-10-04libsmb: Pass NTTIME to interpret_long_date()Volker Lendecke1-3/+3
Separate concerns of conversion and pulling off the wire. Needed soon for smb311 pidl generated parsing. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
2023-07-13s3:libsmb: Fix code spellingAndreas Schneider1-1/+1
Signed-off-by: Andreas Schneider <asn@samba.org> Reviewed-by: Martin Schwenke <mschwenke@ddn.com> Autobuild-User(master): Andreas Schneider <asn@cryptomilk.org> Autobuild-Date(master): Thu Jul 13 06:34:01 UTC 2023 on atb-devel-224
2023-06-01libsmb: Fix directory listing against old serversVolker Lendecke1-0/+6
cli_list_trans_recv() can be called multiple times. When it's done, it return NT_STATUS_OK and set *finfo to NULL. cli_list_old_recv() did not do the NULL part, so smbclient would endlessly loop. Bug: https://bugzilla.samba.org/show_bug.cgi?id=15382 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): Thu Jun 1 21:54:42 UTC 2023 on atb-devel-224
2022-12-16libsmb: Simplify clistr_is_previous_version_path()Volker Lendecke1-2/+2
Nobody looks at the out params anymore Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org> Autobuild-User(master): Volker Lendecke <vl@samba.org> Autobuild-Date(master): Fri Dec 16 08:42:18 UTC 2022 on sn-devel-184
2022-11-29libsmb: Allow listing with posix contextDavid Mulder1-3/+4
Signed-off-by: David Mulder <dmulder@samba.org> Reviewed-by: Volker Lendecke <vl@samba.org>
2022-11-29libsmb: Make info_level configurable in dir listingDavid Mulder1-3/+9
This was hard coded to SMB2_FIND_ID_BOTH_DIRECTORY_INFO Signed-off-by: David Mulder <dmulder@suse.com> Reviewed-by: Volker Lendecke <vl@samba.org>
2022-09-15s3: libsmb: Fix SMB1 cli_list_old_send() to cope with DFS paths.Jeremy Allison1-0/+4
Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Noel Power <npower@samba.org>
2022-09-15s3: libsmb: Fix SMB1 cli_list_trans_send() (SMBtrans2:TRANSACT2_FINDFIRST) ↵Jeremy Allison1-0/+4
to cope with DFS paths. See smbtorture3: SMB1-DFS-SEARCH-PATHS: test_smb1_findfirst_path Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Noel Power <npower@samba.org>
2022-09-15s3: libsmb: In cli_list_old_send(), push state->mask into the packet, not ↵Jeremy Allison1-2/+5
just mask. This doesn't matter right now, but it will when I add DFS path awareness to cli_list(). Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Noel Power <npower@samba.org>
2020-11-19libsmb: Use async cli_smb2_list_send() in cli_list_send()Volker Lendecke1-9/+9
Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
2020-11-19libsmb: Prepare cli_list_send()/recv() for single-issue subreqsVolker Lendecke1-23/+58
This prepares cli_list_recv() for the lowerlevel NT_STATUS_RETRY that will come in once cli_list_send() uses cli_smb2_list_send() as well. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
2020-11-19libsmb: Convert cli_list_recv() to single-recvVolker Lendecke1-17/+113
This converts the higher-level cli_list_recv() to the new cli_smb2_list_recv() calling convention to just issue one entry per recv() call in preparation of using the async cli_smb2_list_send() in cli_list_send(). For SMB1 this will be a performance degradation, as we have to make copies out of the arrays that cli_trans_recv() returns, but soon this will become a performance improvement for the SMB2 directory listing. And as hopefully most deployments these days are SMB2, I think we can live with the SMB1 client directory listing degradation. Also, we can also convert the lowerlevel SMB1 directory listing routines in case someone actually sees problems from this here. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
2020-11-04libsmb: Remove "mntpoint" argument from cli_list_trans() callbackVolker Lendecke1-3/+5
This was unused in the callers, also do this for symmetry. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
2020-11-04libsmb: Remove "mntpoint" argument from cli_list() callbackVolker Lendecke1-6/+4
do_list()/do_list_helper() in source3/client/client.c was the only user of this argument. And that use was wrong. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
2020-11-04libsmb: Fix a signed/unsigned warningVolker Lendecke1-1/+1
"num_bytes" is uint32_t, "received" is uint16_t. The multiplication seems to implicitly widen "received" to int, leading to a signed/unsigned warning. This cast makes that warning go away. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
2020-09-30libsmb: Make cli_list() prototype more descriptiveVolker Lendecke1-5/+11
Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
2020-06-04s3: libsmb: Make cli_list_trans() and cli_list take a 32-bit attribute.Jeremy Allison1-5/+5
All sub-functions take 32-bits, and all callers now are compatible with 32-bit attributes. Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Volker Lendecke <vl@samba.org>
2020-06-04s3: libsmb: Make cli_list_old() take 32-bit attribute.Jeremy Allison1-3/+3
Only uses 16 on the wire. No change needed in callers. Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Volker Lendecke <vl@samba.org>
2020-06-04s3: libsmb: Change size of finfo->attr to uint32_t.Jeremy Allison1-2/+1
That's what modern servers return. Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Volker Lendecke <vl@samba.org>
2020-06-04s3: libsmb: In struct file_info rename mode -> attr.Jeremy Allison1-5/+5
Cleanup. It's never been a UNIX mode, always a DOS attribute field. Make that explicit. Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Volker Lendecke <vl@samba.org>
2020-06-03s3: libsmb: Info level SMB_FIND_EA_SIZE encodes attibutes as a uint16, not a ↵Jeremy Allison1-1/+1
uint8. We will need this to detect FILE_ATTRIBUTE_REPARSE_POINT in a later commit. BUG: https://bugzilla.samba.org/show_bug.cgi?id=14391 Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
2020-06-03s3: libsmb: Info level SMB_FIND_INFO_STANDARD encodes attibutes as a uint16, ↵Jeremy Allison1-1/+1
not a uint8. We will need this to detect FILE_ATTRIBUTE_REPARSE_POINT in a later commit. BUG: https://bugzilla.samba.org/show_bug.cgi?id=14391 Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
2020-06-03s3: libsmb: Info level SMB_FIND_FILE_BOTH_DIRECTORY_INFO encodes attibutes ↵Jeremy Allison1-1/+2
as a uint32, not a uint8. Cast to a uint16_t for now after pulling the information as finfo->mode is currently only 16 bits. We will need this to detect FILE_ATTRIBUTE_REPARSE_POINT in a later commit. BUG: https://bugzilla.samba.org/show_bug.cgi?id=14391 Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org>
2020-05-28libsmb: Remove clistr_pull_talloc()Volker Lendecke1-35/+35
This was just a 1:1 wrapper around pull_string_talloc() Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
2020-05-12s3: libsmbclient: Finish unifing bad iconv behavior across CORE NT1 SMB2 ↵Jeremy Allison1-2/+3
protocols. On bad name conversion, exit the directory listing with an error, but leave the connection intact. We were already checking for finfo->name == NULL here, but were ignoring it and not reporting an error. Remove the knownfail.d/bad_iconv file as we now behave the same across CORE/NT1/SMB2. BUG: https://bugzilla.samba.org/show_bug.cgi?id=14374 Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org> Autobuild-User(master): Jeremy Allison <jra@samba.org> Autobuild-Date(master): Tue May 12 21:32:44 UTC 2020 on sn-devel-184
2020-05-12s3: libsmb: In SMB1 old protocol - return NT_STATUS_INVALID_NETWORK_RESPONSE ↵Jeremy Allison1-1/+4
if name conversion ended up with a NULL filename. Can happen if namelen == 0. BUG: https://bugzilla.samba.org/show_bug.cgi?id=14374 Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org>
2020-03-10libsmbclient: Put it back to a known, well-working stateVolker Lendecke1-67/+2
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-03libsmb: Implement SMB_FIND_FILE_UNIX_INFO2 dir listingVolker Lendecke1-2/+67
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>
2019-10-29CVE-2019-10218 - s3: libsmb: Protect SMB1 client code from evil server ↵Jeremy Allison1-0/+75
returned names. Disconnect with NT_STATUS_INVALID_NETWORK_RESPONSE if so. BUG: https://bugzilla.samba.org/show_bug.cgi?id=14071 Signed-off-by: Jeremy Allison <jra@samba.org>
2019-10-22s3/libsmd: clang: Fix some uninitialized value errorsNoel Power1-2/+2
Fixes: source3/libsmb/clilist.c:534:14: warning: 1st function call argument is an uninitialized value <--[clang] num_finfo = talloc_array_length(finfo); ^ source3/libsmb/clilist.c:1007:13: warning: The right operand of '<' is a garbage value <--[clang] for (i=0; i<num_finfo; i++) { ^~~~~~~~~~ 2 warnings generated. Signed-off-by: Noel Power <noel.power@suse.com> Reviewed-by: Ralph Boehme <slow@samba.org>
2018-05-05s3: client: Add btime_ts to struct finfo.Jeremy Allison1-0/+19
Fill it in when available, else return it as zero. Based on a patch from Puran Chand <pchand@vmware.com>. Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org> Reviewed-by: Alexander Bokovoy <ab@samba.org>
2016-08-22s3: libsmb: Add return args to clistr_is_previous_version_path().Jeremy Allison1-2/+2
Not yet used - we will use these to construct the SMB2 TWrp blob. BUG: https://bugzilla.samba.org/show_bug.cgi?id=12166 Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Uri Simchoni <uri@samba.org>
2016-08-19s3: libsmb: Plumb in additional_flags2 = FLAGS2_REPARSE_PATH to ↵Jeremy Allison1-2/+13
cli_list_trans_send(). BUG: https://bugzilla.samba.org/show_bug.cgi?id=12165 Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Uri Simchoni <uri@samba.org>
2016-08-19s3: libsmb: Add uint16_t addtional_flags2 to cli_trans_send().Jeremy Allison1-2/+2
Not yet used. BUG: https://bugzilla.samba.org/show_bug.cgi?id=12165 Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Uri Simchoni <uri@samba.org>
2016-08-19s3: libsmb: Add uint16_t additional_flags2 arg to cli_smb_send().Jeremy Allison1-3/+3
Not yet used. BUG: https://bugzilla.samba.org/show_bug.cgi?id=12165 Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Uri Simchoni <uri@samba.org>
2016-04-06s3: libsmb: Fix error where short name length was read as 2 bytes, should be 1.Jeremy Allison1-1/+1
Reported by Thomas Dvorachek <tdvorachek@yahoo.com> from a Windows 10 server. Confirmed in MS-CIFS 2.2.8.1.7. BUG: https://bugzilla.samba.org/show_bug.cgi?id=11822 Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Ralph Boehme <slow@samba.org> Autobuild-User(master): Jeremy Allison <jra@samba.org> Autobuild-Date(master): Wed Apr 6 03:46:55 CEST 2016 on sn-devel-144
2015-05-18Use tevent_req_poll_ntstatusVolker Lendecke1-4/+2
Kill 41 lines .. Signed-off-by: Volker Lendecke <vl@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
2015-05-13Convert all uint32/16/8 to _t in source3/libsmb.Richard Sharpe1-3/+3
Signed-off-by: Richard Sharpe <rsharpe@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
2013-11-14s3-client: smbclient shows no error if deleting a directory with del failedJeremy Allison1-1/+1
BUG: https://bugzilla.samba.org/show_bug.cgi?id=10260 In SMB1 the server filters by attribute requested, in SMB2 there is no attribute sent. Emulate this on the client to provide the same ABI to callers. In SMB1 the server returns NT_STATUS_NO_SUCH_FILE if FindFirst finds no files. Emulate this on the client. Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Andreas Schneider <asn@samba.org> Autobuild-User(master): Andreas Schneider <asn@cryptomilk.org> Autobuild-Date(master): Thu Nov 14 21:23:07 CET 2013 on sn-devel-104
2013-08-15s3:libsmb: Plumb cli_smb2_list() inside cli_list().Jeremy Allison1-1/+7
Signed-off-by: Jeremy Allison <jra@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org>
2013-02-19s3:libsmb: s/struct event_context/struct tevent_contextStefan Metzmacher1-3/+3
Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Michael Adam <obnox@samba.org>
2013-02-19s3:libsmb: make use of samba_tevent_context_init()Stefan Metzmacher1-3/+3
Signed-off-by: Stefan Metzmacher <metze@samba.org> Reviewed-by: Michael Adam <obnox@samba.org>
2012-08-22Fix bug in SMB_FIND_INFO_STANDARD parsing found by Volker.Jeremy Allison1-1/+3
The function align_string() is now broken as base_ptr no longer points at the start of the SMB data packet, but at the start of the returned TRANS2 data area. Replace it with a check for FLAGS2_UNICODE_STRINGS and a call to ucs2_align().