summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRalph Boehme <slow@samba.org>2015-12-19 11:06:19 +0100
committerKarolin Seeger <kseeger@samba.org>2016-01-06 10:07:18 +0100
commitc99c91003355498c9623bfbe6782526ec25c84f3 (patch)
tree0a62467de294e6b51211c98aa55108abc3c4e1b0
parentd8511c06dae8509426583f48e9f1fcb676bd58d8 (diff)
downloadsamba-c99c91003355498c9623bfbe6782526ec25c84f3.tar.gz
vfs_fruit: fix offset and len handling for AFP_AfpInfo stream
When reading from the AFP_AfpInfo stream, OS X ignores the offset from the request and always reads from offset=0. The offset bounds check has a off-by-1 bug in OS X, so a request offset=60 (AFP_AfpInfo stream has a ficed size of 60 bytes), len=1 returns 1 byte from offset 0 insteaf of returning 0. Bug: https://bugzilla.samba.org/show_bug.cgi?id=11347 Signed-off-by: Ralph Boehme <slow@samba.org> Reviewed-by: Jeremy Allison <jra@samba.org> (cherry picked from commit f569fd5e44300ab41aa7298b3efdcac99cd330f2)
-rw-r--r--source3/modules/vfs_fruit.c15
1 files changed, 12 insertions, 3 deletions
diff --git a/source3/modules/vfs_fruit.c b/source3/modules/vfs_fruit.c
index c1c71a5d21f..7201d5f6535 100644
--- a/source3/modules/vfs_fruit.c
+++ b/source3/modules/vfs_fruit.c
@@ -2675,13 +2675,19 @@ static ssize_t fruit_pread(vfs_handle_struct *handle,
char afpinfo_buf[AFP_INFO_SIZE];
size_t to_return;
- if ((offset < 0) || (offset > AFP_INFO_SIZE)) {
+ /*
+ * OS X has a off-by-1 error in the offset calculation, so we're
+ * bug compatible here. It won't hurt, as any relevant real
+ * world read requests from the AFP_AfpInfo stream will be
+ * offset=0 n=60. offset is ignored anyway, see below.
+ */
+ if ((offset < 0) || (offset >= AFP_INFO_SIZE + 1)) {
len = 0;
rc = 0;
goto exit;
}
- to_return = AFP_INFO_SIZE - offset;
+ to_return = MIN(n, AFP_INFO_SIZE);
ai = afpinfo_new(talloc_tos());
if (ai == NULL) {
@@ -2704,7 +2710,10 @@ static ssize_t fruit_pread(vfs_handle_struct *handle,
goto exit;
}
- memcpy(data, afpinfo_buf + offset, to_return);
+ /*
+ * OS X ignores offset when reading from AFP_AfpInfo stream!
+ */
+ memcpy(data, afpinfo_buf, to_return);
len = to_return;
} else {
len = SMB_VFS_NEXT_PREAD(