summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStefan Metzmacher <metze@samba.org>2011-11-08 08:25:16 +0100
committerKarolin Seeger <kseeger@samba.org>2011-11-16 20:34:40 +0100
commit9b3a0594424a66bb410bdc48aebfdee8485b1df4 (patch)
tree1f0a7f444731ef17bb106112ce077d0190a54776
parent467a586b3b25f632a5b9ca58abf428a546d97740 (diff)
downloadsamba-9b3a0594424a66bb410bdc48aebfdee8485b1df4.tar.gz
samba-9b3a0594424a66bb410bdc48aebfdee8485b1df4.tar.xz
samba-9b3a0594424a66bb410bdc48aebfdee8485b1df4.zip
s3:libsmb: fix cli_write_and_x() against OS/2 print shares (bug #5326)
Print shares doesn't support CAP_LARGE_WRITEX, while it's negotiated by the file server part. metze Autobuild-User: Stefan Metzmacher <metze@samba.org> Autobuild-Date: Tue Nov 8 17:01:36 CET 2011 on sn-devel-104 (cherry picked from commit 95595dd93fd04999fcf56ecaab7c29b064d021f8)
-rw-r--r--source3/libsmb/clireadwrite.c19
1 files changed, 15 insertions, 4 deletions
diff --git a/source3/libsmb/clireadwrite.c b/source3/libsmb/clireadwrite.c
index 1f5f9252d49..0481c181b8d 100644
--- a/source3/libsmb/clireadwrite.c
+++ b/source3/libsmb/clireadwrite.c
@@ -944,7 +944,7 @@ struct tevent_req *cli_write_andx_create(TALLOC_CTX *mem_ctx,
return NULL;
}
- size = MIN(size, max_write);
+ state->size = MIN(size, max_write);
vwv = state->vwv;
@@ -956,8 +956,8 @@ struct tevent_req *cli_write_andx_create(TALLOC_CTX *mem_ctx,
SIVAL(vwv+5, 0, 0);
SSVAL(vwv+7, 0, mode);
SSVAL(vwv+8, 0, 0);
- SSVAL(vwv+9, 0, (size>>16));
- SSVAL(vwv+10, 0, size);
+ SSVAL(vwv+9, 0, (state->size>>16));
+ SSVAL(vwv+10, 0, state->size);
SSVAL(vwv+11, 0,
cli_smb_wct_ofs(reqs_before, num_reqs_before)
@@ -1026,7 +1026,18 @@ static void cli_write_andx_done(struct tevent_req *subreq)
return;
}
state->written = SVAL(vwv+2, 0);
- state->written |= SVAL(vwv+4, 0)<<16;
+ if (state->size > UINT16_MAX) {
+ /*
+ * It is important that we only set the
+ * high bits only if we asked for a large write.
+ *
+ * OS/2 print shares get this wrong and may send
+ * invalid values.
+ *
+ * See bug #5326.
+ */
+ state->written |= SVAL(vwv+4, 0)<<16;
+ }
tevent_req_done(req);
}