From: Jeremy Allison Date: Fri, 10 Jun 2016 16:32:32 +0000 (-0700) Subject: s4: torture: Added raw readX test to ensure 'reserved' fields are zero. X-Git-Tag: samba-4.3.12~130 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=38c27bf8559005c23c3819a4d1e040b8c5bcb73b;p=thirdparty%2Fsamba.git s4: torture: Added raw readX test to ensure 'reserved' fields are zero. Passes against Win2k12+, and smbd with the previous patch. https://bugzilla.samba.org/show_bug.cgi?id=11845 Signed-off-by: Jeremy Allison Reviewed-by: Alexander Bokovoy Autobuild-User(master): Alexander Bokovoy Autobuild-Date(master): Sat Jun 18 19:32:22 CEST 2016 on sn-devel-144 (cherry picked from commit 747de99fcd70f400ec0ca6b2ca020664f7464454) --- diff --git a/source4/torture/raw/read.c b/source4/torture/raw/read.c index 6abf08b9678..6160e3e4837 100644 --- a/source4/torture/raw/read.c +++ b/source4/torture/raw/read.c @@ -19,6 +19,7 @@ #include "includes.h" #include "libcli/raw/libcliraw.h" +#include "libcli/raw/raw_proto.h" #include "system/time.h" #include "system/filesys.h" #include "libcli/libcli.h" @@ -373,6 +374,8 @@ static bool test_readx(struct torture_context *tctx, struct smbcli_state *cli) const char *fname = BASEDIR "\\test.txt"; const char *test_data = "TEST DATA"; unsigned int seed = time(NULL); + struct smbcli_request *smbreq = NULL; + unsigned int i; buf = talloc_zero_array(tctx, uint8_t, maxsize); @@ -422,6 +425,47 @@ static bool test_readx(struct torture_context *tctx, struct smbcli_state *cli) smbcli_write(cli->tree, fnum, 0, test_data, 0, strlen(test_data)); + printf("Checking reserved fields are [0]\n"); + io.readx.in.file.fnum = fnum; + io.readx.in.offset = 0; + io.readx.in.remaining = 0; + io.readx.in.read_for_execute = false; + io.readx.in.mincnt = strlen(test_data); + io.readx.in.maxcnt = strlen(test_data); + smbreq = smb_raw_read_send(cli->tree, &io); + if (smbreq == NULL) { + ret = false; + torture_fail_goto(tctx, done, "smb_raw_read_send failed\n"); + } + if (!smbcli_request_receive(smbreq) || + smbcli_request_is_error(smbreq)) { + status = smbcli_request_destroy(smbreq); + torture_fail_goto(tctx, done, "receive failed\n"); + } + + if (smbreq->in.wct != 12) { + ret = false; + printf("Incorrect wct %u (should be 12)\n", + (unsigned int)smbreq->in.wct); + status = smbcli_request_destroy(smbreq); + torture_fail_goto(tctx, done, "bad wct\n"); + } + + /* Ensure VWV8 - WVW11 are zero. */ + for (i = 8; i < 12; i++) { + uint16_t br = SVAL(smbreq->in.vwv, VWV(i)); + if (br != 0) { + status = smbcli_request_destroy(smbreq); + ret = false; + printf("reserved field %u is %u not zero\n", + i, + (unsigned int)br); + torture_fail_goto(tctx, done, "bad reserved field\n"); + } + } + + smbcli_request_destroy(smbreq); + printf("Trying small read\n"); io.readx.in.file.fnum = fnum; io.readx.in.offset = 0;