1
0
mirror of https://github.com/samba-team/samba.git synced 2024-12-23 17:34:34 +03:00

ensure that we honor SMB2 read min_count properly

(This used to be commit 318038d6f6)
This commit is contained in:
Andrew Tridgell 2008-05-27 18:20:23 +10:00
parent 4f0d968d1d
commit 8daeee5c5d
3 changed files with 10 additions and 12 deletions

View File

@ -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;

View File

@ -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;

View File

@ -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;