diff options
author | Andrew Tridgell <tridge@samba.org> | 2008-05-27 18:20:23 +1000 |
---|---|---|
committer | Andrew Tridgell <tridge@samba.org> | 2008-05-27 18:20:23 +1000 |
commit | 8daeee5c5d7d5851677089cceaf26a0e32675a96 (patch) | |
tree | 6c7892ea7b20fd5c68ae826a49ea670d23cdd464 | |
parent | 4f0d968d1dd185a4f5b38c2669f520536b1f8445 (diff) | |
download | samba-8daeee5c5d7d5851677089cceaf26a0e32675a96.tar.gz samba-8daeee5c5d7d5851677089cceaf26a0e32675a96.tar.bz2 samba-8daeee5c5d7d5851677089cceaf26a0e32675a96.zip |
ensure that we honor SMB2 read min_count properly
(This used to be commit 318038d6f670efffa96d8b0db63f46b3752e1cd3)
-rw-r--r-- | source4/libcli/raw/interfaces.h | 2 | ||||
-rw-r--r-- | source4/ntvfs/ntvfs_generic.c | 12 | ||||
-rw-r--r-- | source4/ntvfs/posix/pvfs_read.c | 8 |
3 files changed, 10 insertions, 12 deletions
diff --git a/source4/libcli/raw/interfaces.h b/source4/libcli/raw/interfaces.h index 68ebc19bdb..17c85138ac 100644 --- a/source4/libcli/raw/interfaces.h +++ b/source4/libcli/raw/interfaces.h @@ -1647,7 +1647,7 @@ union smb_read { struct { union smb_handle file; uint64_t offset; - uint16_t mincnt; + uint32_t mincnt; /* enforced on SMB2, 16 bit on SMB */ uint32_t maxcnt; uint16_t remaining; bool read_for_execute; diff --git a/source4/ntvfs/ntvfs_generic.c b/source4/ntvfs/ntvfs_generic.c index 3d92c0be33..06d89a717b 100644 --- a/source4/ntvfs/ntvfs_generic.c +++ b/source4/ntvfs/ntvfs_generic.c @@ -1295,16 +1295,6 @@ static NTSTATUS ntvfs_map_read_finish(struct ntvfs_module_context *ntvfs, rd->smb2.out.data.length= rd2->generic.out.nread; rd->smb2.out.remaining = 0; rd->smb2.out.reserved = 0; - if (NT_STATUS_IS_OK(status) && - rd->smb2.out.data.length == 0) { - status = NT_STATUS_END_OF_FILE; - } - /* SMB2 does honor the min_count field, SMB does not */ - if (NT_STATUS_IS_OK(status) && - rd->smb2.in.min_count > rd->smb2.out.data.length) { - rd->smb2.out.data.length = 0; - status = NT_STATUS_END_OF_FILE; - } break; default: return NT_STATUS_INVALID_LEVEL; @@ -1396,7 +1386,7 @@ NTSTATUS ntvfs_map_read(struct ntvfs_module_context *ntvfs, case RAW_READ_SMB2: rd2->readx.in.file.ntvfs= rd->smb2.in.file.ntvfs; rd2->readx.in.offset = rd->smb2.in.offset; - rd2->readx.in.mincnt = rd->smb2.in.length; + rd2->readx.in.mincnt = rd->smb2.in.min_count; rd2->readx.in.maxcnt = rd->smb2.in.length; rd2->readx.in.remaining = 0; rd2->readx.out.data = rd->smb2.out.data.data; diff --git a/source4/ntvfs/posix/pvfs_read.c b/source4/ntvfs/posix/pvfs_read.c index 418b7e09fb..a01a8a57e3 100644 --- a/source4/ntvfs/posix/pvfs_read.c +++ b/source4/ntvfs/posix/pvfs_read.c @@ -93,6 +93,14 @@ NTSTATUS pvfs_read(struct ntvfs_module_context *ntvfs, return pvfs_map_errno(pvfs, errno); } + /* only SMB2 honors mincnt */ + if (req->ctx->protocol == PROTOCOL_SMB2) { + if (rd->readx.in.mincnt > ret || + (ret == 0 && maxcnt > 0)) { + return NT_STATUS_END_OF_FILE; + } + } + f->handle->position = f->handle->seek_offset = rd->readx.in.offset + ret; rd->readx.out.nread = ret; |