From 1ef9a920c1735865bce77ba8c93756e85c47f272 Mon Sep 17 00:00:00 2001 From: Raghavendra Bhat Date: Mon, 9 Jul 2012 01:58:30 +0530 Subject: storage/posix: handle getxattr failures gracefully Use proper variable types for getting return value of getxattr calls, which otherwise can lead to segfaulting of processes or page allocation failures in the kernel. Change-Id: I62ab5d6c378447090c19846f03298c3afc8863ba BUG: 838195 Signed-off-by: Raghavendra Bhat Reviewed-on: http://review.gluster.com/3640 Tested-by: Gluster Build System Reviewed-by: Niels de Vos Reviewed-by: Anand Avati --- xlators/storage/posix/src/posix-helpers.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'xlators/storage/posix/src/posix-helpers.c') diff --git a/xlators/storage/posix/src/posix-helpers.c b/xlators/storage/posix/src/posix-helpers.c index 6a9333a01..46bb6ea59 100644 --- a/xlators/storage/posix/src/posix-helpers.c +++ b/xlators/storage/posix/src/posix-helpers.c @@ -214,16 +214,25 @@ _posix_xattr_get_set (dict_t *xattr_req, if (!value) return; - sys_lgetxattr (filler->real_path, key, value, + ret = sys_lgetxattr (filler->real_path, key, value, xattr_size); + if (ret <= 0) { + gf_log (filler->this->name, GF_LOG_WARNING, + "getxattr failed. path: %s, key: %s", + filler->real_path, key); + GF_FREE (value); + return; + } value[xattr_size] = '\0'; ret = dict_set_bin (filler->xattr, key, value, xattr_size); - if (ret < 0) + if (ret < 0) { gf_log (filler->this->name, GF_LOG_DEBUG, "dict set failed. path: %s, key: %s", filler->real_path, key); + GF_FREE (value); + } } } out: -- cgit