From 8b32e62d35efbd634fb80fdada0da7f7fac9a66d Mon Sep 17 00:00:00 2001 From: Ralph Boehme Date: Mon, 6 Nov 2017 11:09:44 +0100 Subject: [PATCH] WIP: s3/smbd: max xattr xize in get_ea_value() The current maximum allowed xattr size is 64 KB which is too small for certain use cases. Raise this limit to 64 MB by adding a parametric option "smbd:max_xattr_size" with a default value of 64 MB. The option value is stored in a static value to avoid expensive calls to loadparm for every call to get_ea_value(). --- source3/smbd/trans2.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/source3/smbd/trans2.c b/source3/smbd/trans2.c index de6073a973f..483739868e6 100644 --- a/source3/smbd/trans2.c +++ b/source3/smbd/trans2.c @@ -214,6 +214,12 @@ NTSTATUS get_ea_value(TALLOC_CTX *mem_ctx, size_t attr_size = 256; char *val = NULL; ssize_t sizeret; + static size_t max_xattr_size = 0; + + if (max_xattr_size == 0) { + max_xattr_size = (size_t)lp_parm_ulonglong( + SNUM(conn), "smbd", "max_xattr_size", 64*1024*1024); + } again: @@ -229,8 +235,8 @@ NTSTATUS get_ea_value(TALLOC_CTX *mem_ctx, ea_name, val, attr_size); } - if (sizeret == -1 && errno == ERANGE && attr_size != 65536) { - attr_size = 65536; + if (sizeret == -1 && errno == ERANGE && attr_size <= max_xattr_size) { + attr_size = sizeret; goto again; } -- 2.13.6