summaryrefslogtreecommitdiff
path: root/source3
diff options
context:
space:
mode:
authorJeremy Allison <jra@samba.org>2018-07-12 12:18:50 -0700
committerKarolin Seeger <kseeger@samba.org>2018-08-13 12:56:35 +0200
commita970d45d1774b5b55bea23488035ca44de0cb7f2 (patch)
tree2b0a72f54403956ec8663aa1e390ff76438163bd /source3
parent41302b40301b410ca618c92df67394de51d6b1bc (diff)
downloadsamba-a970d45d1774b5b55bea23488035ca44de0cb7f2.tar.gz
s3: libsmbclient: Fix cli_splice() fallback when reading less than a complete file.
We were always asking for SPLICE_BLOCK_SIZE even when the remaining bytes we wanted were smaller than that. This works when using cli_splice() on a complete file, as the cli_read() terminated the read at the right place. We always have the space to read SPLICE_BLOCK_SIZE bytes so this isn't an overflow. Found by Bailey Berro <baileyberro@google.com> BUG: https://bugzilla.samba.org/show_bug.cgi?id=13527 Signed-off-by: Bailey Berro <baileyberro@google.com> Reviewed-by: Jeremy Allison <jra@samba.org> Reviewed-by: David Disseldorp <ddiss@samba.org> Autobuild-User(master): David Disseldorp <ddiss@samba.org> Autobuild-Date(master): Fri Jul 13 14:57:14 CEST 2018 on sn-devel-144 (cherry picked from commit c9656fd2977557ab20ec4e3d87c385a9b2f1bf43)
Diffstat (limited to 'source3')
-rw-r--r--source3/libsmb/clireadwrite.c4
1 files changed, 3 insertions, 1 deletions
diff --git a/source3/libsmb/clireadwrite.c b/source3/libsmb/clireadwrite.c
index 00ee09ece89..67870d8c40b 100644
--- a/source3/libsmb/clireadwrite.c
+++ b/source3/libsmb/clireadwrite.c
@@ -1462,8 +1462,10 @@ static NTSTATUS cli_splice_fallback(TALLOC_CTX *frame,
*written = 0;
while (remaining) {
+ size_t to_read = MIN(remaining, SPLICE_BLOCK_SIZE);
+
status = cli_read(srccli, src_fnum,
- (char *)buf, src_offset, SPLICE_BLOCK_SIZE,
+ (char *)buf, src_offset, to_read,
&nread);
if (!NT_STATUS_IS_OK(status)) {
return status;