summaryrefslogtreecommitdiffstats
path: root/source3/smbd/reply.c
diff options
context:
space:
mode:
authorDavid Disseldorp <ddiss@samba.org>2015-02-16 19:26:23 +0100
committerJeremy Allison <jra@samba.org>2015-02-17 03:08:07 +0100
commit4ab0e57f1073e776b8832f5edc3dca04ef903fef (patch)
tree5911354bd5d149534284f692a5e10cb3cc359a52 /source3/smbd/reply.c
parent2501afe08b94a514d8e2f3eeb4a2c4edc9764979 (diff)
downloadsamba-4ab0e57f1073e776b8832f5edc3dca04ef903fef.tar.gz
samba-4ab0e57f1073e776b8832f5edc3dca04ef903fef.tar.xz
samba-4ab0e57f1073e776b8832f5edc3dca04ef903fef.zip
smbd/reply: convert free space to 16bit in dskattr handler
The deprecated Core Protocol dskattr SMB_COM_QUERY_INFORMATION_DISK command provides free space information in the form of 16-bit words. Until now, this has been handled by passing the dskattr specific small_query boolean through to disk_norm() via the SMB_VFS_DISK_FREE VFS hook. disk_norm(small_query=true) then modifies the block size and free space values such that they fit in the 16-bit field. This change adds the command specific logic to the dskattr handler, so that it can be removed from the SMB_VFS_DISK_FREE()->disk_norm() code path. In doing so, it fixes dskattr request handling against opaque VFS backends that don't call disk_norm(), such as vfs_glusterfs. Signed-off-by: David Disseldorp <ddiss@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org>
Diffstat (limited to 'source3/smbd/reply.c')
-rw-r--r--source3/smbd/reply.c21
1 files changed, 20 insertions, 1 deletions
diff --git a/source3/smbd/reply.c b/source3/smbd/reply.c
index 0b6c102448..b6199bbef2 100644
--- a/source3/smbd/reply.c
+++ b/source3/smbd/reply.c
@@ -1456,15 +1456,34 @@ void reply_setatr(struct smb_request *req)
void reply_dskattr(struct smb_request *req)
{
connection_struct *conn = req->conn;
+ uint64_t ret;
uint64_t dfree,dsize,bsize;
START_PROFILE(SMBdskattr);
- if (get_dfree_info(conn,".",True,&bsize,&dfree,&dsize) == (uint64_t)-1) {
+ ret = get_dfree_info(conn, ".", false, &bsize, &dfree, &dsize);
+ if (ret == (uint64_t)-1) {
reply_nterror(req, map_nt_error_from_unix(errno));
END_PROFILE(SMBdskattr);
return;
}
+ /*
+ * Force max to fit in 16 bit fields.
+ */
+ while (dfree > WORDMAX || dsize > WORDMAX || bsize < 512) {
+ dfree /= 2;
+ dsize /= 2;
+ bsize *= 2;
+ if (bsize > (WORDMAX*512)) {
+ bsize = (WORDMAX*512);
+ if (dsize > WORDMAX)
+ dsize = WORDMAX;
+ if (dfree > WORDMAX)
+ dfree = WORDMAX;
+ break;
+ }
+ }
+
reply_outbuf(req, 5, 0);
if (get_Protocol() <= PROTOCOL_LANMAN2) {