[PATCH] FSCTL_GET_SHADOW_COPY_DATA

Christof Schmitt christof.schmitt at us.ibm.com
Mon Aug 5 15:43:55 MDT 2013


Here are two patches for the FSCTL_GET_SHADOW_COPY_DATA code. The
first one fixes an issue that uninitialized data can be returned to a
client. The second one removes four superfluous bytes at the end of
the returned data. With these changes, the returned data looks similar
to the data returned from w2008r2. So far there is no problem that
would be caused by the current code, but i think it would be
worthwhile to make the returned data consistent with Windows and the
spec.

-- 
Christof Schmitt || IBM || SONAS System Development || Tucson, AZ
christof.schmitt at us.ibm.com  ||  +1-520-799-2469  (T/L: 321-2469)
-------------- next part --------------
>From b8c78baa5f3be1c8869a006367c727cb834b046f Mon Sep 17 00:00:00 2001
From: Christof Schmitt <christof.schmitt at us.ibm.com>
Date: Mon, 5 Aug 2013 11:16:22 -0700
Subject: [PATCH 1/2] FSCTL_GET_SHADOW_COPY_DATA: Initialize output array to zero

Otherwise num_volumes and the end marker can return uninitialized data
to the client.

Signed-off-by: Christof Schmitt <christof.schmitt at us.ibm.com>
---
 source3/modules/vfs_default.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/source3/modules/vfs_default.c b/source3/modules/vfs_default.c
index 82d059c..efb0204 100644
--- a/source3/modules/vfs_default.c
+++ b/source3/modules/vfs_default.c
@@ -1151,7 +1151,7 @@ static NTSTATUS vfswrap_fsctl(struct vfs_handle_struct *handle,
 			return NT_STATUS_BUFFER_TOO_SMALL;
 		}
 
-		cur_pdata = talloc_array(ctx, char, *out_len);
+		cur_pdata = talloc_zero_array(ctx, char, *out_len);
 		if (cur_pdata == NULL) {
 			TALLOC_FREE(shadow_data);
 			return NT_STATUS_NO_MEMORY;
-- 
1.7.1

-------------- next part --------------
>From b6755c37fe358ff8216e6c31fe1554344a4ee8ce Mon Sep 17 00:00:00 2001
From: Christof Schmitt <christof.schmitt at us.ibm.com>
Date: Mon, 5 Aug 2013 11:21:59 -0700
Subject: [PATCH 2/2] FSCTL_GET_SHADOW_COPY_DATA: Don't return 4 extra bytes at end

labels_data_count already accounts for the unicode null character at the
end of the array. There is no need in adding space for it again.

Signed-off-by: Christof Schmitt <christof.schmitt at us.ibm.com>
---
 source3/modules/vfs_default.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/source3/modules/vfs_default.c b/source3/modules/vfs_default.c
index efb0204..304ef37 100644
--- a/source3/modules/vfs_default.c
+++ b/source3/modules/vfs_default.c
@@ -1141,7 +1141,7 @@ static NTSTATUS vfswrap_fsctl(struct vfs_handle_struct *handle,
 		if (!labels) {
 			*out_len = 16;
 		} else {
-			*out_len = 12 + labels_data_count + 4;
+			*out_len = 12 + labels_data_count;
 		}
 
 		if (max_out_len < *out_len) {
@@ -1168,7 +1168,7 @@ static NTSTATUS vfswrap_fsctl(struct vfs_handle_struct *handle,
 		}
 
 		/* needed_data_count 4 bytes */
-		SIVAL(cur_pdata, 8, labels_data_count + 4);
+		SIVAL(cur_pdata, 8, labels_data_count);
 
 		cur_pdata += 12;
 
-- 
1.7.1



More information about the samba-technical mailing list