summaryrefslogtreecommitdiff
path: root/source3/modules
diff options
context:
space:
mode:
authorRalph Boehme <slow@samba.org>2019-10-25 15:21:32 +0200
committerKarolin Seeger <kseeger@samba.org>2019-11-08 09:57:34 +0000
commit2a61a6b7c375e0cc664c7c874f4a76de025f19ff (patch)
tree871c0c59d5222a45c3aeae0388b1b8c8a11c1e09 /source3/modules
parentf3482d9efc8d768b53cfb9d673bdcf4f2dc190d9 (diff)
downloadsamba-2a61a6b7c375e0cc664c7c874f4a76de025f19ff.tar.gz
lib/adouble: drop ad_data reallocate logic
Simply set the buffer size to AD_XATTR_MAX_HDR_SIZE. When reading the AppleDouble file, read up to AD_XATTR_MAX_HDR_SIZE from the file. BUG: https://bugzilla.samba.org/show_bug.cgi?id=14171 Signed-off-by: Ralph Boehme <slow@samba.org> Reviewed-by: Stefan Metzmacher <metze@samba.org> (backported from commit 9a3da6bebcdb924ca2027337544d79ac2088677e)
Diffstat (limited to 'source3/modules')
-rw-r--r--source3/modules/vfs_fruit.c46
1 files changed, 23 insertions, 23 deletions
diff --git a/source3/modules/vfs_fruit.c b/source3/modules/vfs_fruit.c
index 14110ea2792..ea80b12cf8c 100644
--- a/source3/modules/vfs_fruit.c
+++ b/source3/modules/vfs_fruit.c
@@ -1664,8 +1664,7 @@ static ssize_t ad_read_rsrc_adouble(vfs_handle_struct *handle,
struct adouble *ad,
const struct smb_filename *smb_fname)
{
- char *p_ad = NULL;
- size_t size;
+ size_t to_read;
ssize_t len;
int ret;
bool ok;
@@ -1677,32 +1676,17 @@ static ssize_t ad_read_rsrc_adouble(vfs_handle_struct *handle,
return -1;
}
- /*
- * AppleDouble file header content and size, two cases:
- *
- * - without xattrs it is exactly AD_DATASZ_DOT_UND (82) bytes large
- * - with embedded xattrs it can be larger, up to AD_XATTR_MAX_HDR_SIZE
- *
- * Read as much as we can up to AD_XATTR_MAX_HDR_SIZE.
- */
- size = ad->ad_fsp->fsp_name->st.st_ex_size;
- if (size > talloc_array_length(ad->ad_data)) {
- if (size > AD_XATTR_MAX_HDR_SIZE) {
- size = AD_XATTR_MAX_HDR_SIZE;
- }
- p_ad = talloc_realloc(ad, ad->ad_data, char, size);
- if (p_ad == NULL) {
- return -1;
- }
- ad->ad_data = p_ad;
+ to_read = ad->ad_fsp->fsp_name->st.st_ex_size;
+ if (to_read > AD_XATTR_MAX_HDR_SIZE) {
+ to_read = AD_XATTR_MAX_HDR_SIZE;
}
len = SMB_VFS_NEXT_PREAD(handle,
ad->ad_fsp,
ad->ad_data,
- talloc_array_length(ad->ad_data),
+ to_read,
0);
- if (len != talloc_array_length(ad->ad_data)) {
+ if (len != to_read) {
DBG_NOTICE("%s %s: bad size: %zd\n",
smb_fname->base_name, strerror(errno), len);
return -1;
@@ -1800,7 +1784,23 @@ static struct adouble *ad_alloc(TALLOC_CTX *ctx,
adsize = AD_DATASZ_XATTR;
break;
case ADOUBLE_RSRC:
- adsize = AD_DATASZ_DOT_UND;
+ /*
+ * AppleDouble ._ file case, optimize for fewer (but larger)
+ * IOs. Two cases:
+ *
+ * - without xattrs size of the header is exactly
+ * AD_DATASZ_DOT_UND (82) bytes
+ *
+ * - with embedded xattrs it can be larger, up to
+ * AD_XATTR_MAX_HDR_SIZE
+ *
+ * Larger headers are not supported, but this is a reasonable
+ * limit that is also employed by the macOS client.
+ *
+ * We used the largest possible size to be able to read the full
+ * header with one IO.
+ */
+ adsize = AD_XATTR_MAX_HDR_SIZE;
break;
default:
return NULL;