From 468ee6e751345639dbc386a51eb1720c9fdec0ca Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Mon, 11 Mar 2013 12:27:59 -0700 Subject: [PATCH 1/2] Part 1 of fix for 9706 - Parameter is incorrect on Android. Match Windows in ignoring a upper_read size of 0xFFFF explicitly. Signed-off-by: Jeremy Allison --- source3/smbd/reply.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/source3/smbd/reply.c b/source3/smbd/reply.c index 64c4fdb..1566045 100644 --- a/source3/smbd/reply.c +++ b/source3/smbd/reply.c @@ -3855,12 +3855,19 @@ nosendfile_read: we supported this. ****************************************************************************/ -static bool server_will_accept_large_read(void) +static bool server_will_accept_large_read(size_t upper_size) { /* Samba client ? No problem. */ if (get_remote_arch() == RA_SAMBA) { return true; } + /* + * Windows explicitly ignores upper size of 0xFFFF. + * See [MS-SMB].pdf <26> Section 2.2.4.2.1: + */ + if (upper_size == 0xFFFF) { + return false; + } /* Need UNIX extensions. */ if (!lp_unix_extensions()) { return false; @@ -3914,7 +3921,7 @@ void reply_read_and_X(struct smb_request *req) } upper_size = SVAL(req->vwv+7, 0); - if ((upper_size != 0) && server_will_accept_large_read()) { + if ((upper_size != 0) && server_will_accept_large_read(upper_size)) { /* * This is Samba only behavior (up to Samba 3.6)! * -- 1.8.1.3 From 655da481098b4296fcaad4d79e3e59b25493383c Mon Sep 17 00:00:00 2001 From: Jeremy Allison Date: Mon, 11 Mar 2013 12:29:40 -0700 Subject: [PATCH 2/2] Part 2 of fix for 9706 - Parameter is incorrect on Android. Client must have told us it will do CAP_LARGE_READX, and we must have told it we will do UNIX extensions. Signed-off-by: Jeremy Allison --- source3/smbd/reply.c | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/source3/smbd/reply.c b/source3/smbd/reply.c index 1566045..50a743d 100644 --- a/source3/smbd/reply.c +++ b/source3/smbd/reply.c @@ -3868,11 +3868,22 @@ static bool server_will_accept_large_read(size_t upper_size) if (upper_size == 0xFFFF) { return false; } - /* Need UNIX extensions. */ - if (!lp_unix_extensions()) { + /* + * Client needs to have told us it can accept + * a large readX reply in sessionsetup. + */ + if (!(global_client_caps & CAP_LARGE_READX)) { return false; } - return true; + /* + * Yes if the client told us it can do CAP_LARGE_READX + * and we told the client we do UNIX extensions. + */ + if (lp_unix_extensions()) { + return true; + } + /* Otherwise ignore the upper size. */ + return false; } /**************************************************************************** -- 1.8.1.3