From 9eeca96885560ee555826ca0eb4294d226928728 Mon Sep 17 00:00:00 2001 From: ShyamsundarR Date: Fri, 28 Sep 2018 13:47:33 -0400 Subject: mdcache: Fix asan reported potential heap buffer overflow The char pointer mdc_xattr_str in function mdc_xattr_list_populate is malloc'd and doing a strcat into a malloc'd region can overflow content allocated based on prior contents of the memory region. Added a NULL terimation to the malloc'd region to prevent the overflow, and treat it as an empty string. Change-Id: If0decab669551581230a8ede4c44c319ff04bac9 Updates: bz#1635373 Signed-off-by: ShyamsundarR (cherry picked from commit d00a2a1b398346bbdc5ac9b3ba4b09fb1ce1e699) --- xlators/performance/md-cache/src/md-cache.c | 1 + 1 file changed, 1 insertion(+) (limited to 'xlators') diff --git a/xlators/performance/md-cache/src/md-cache.c b/xlators/performance/md-cache/src/md-cache.c index 21cc9de081e..b151110a081 100644 --- a/xlators/performance/md-cache/src/md-cache.c +++ b/xlators/performance/md-cache/src/md-cache.c @@ -3122,6 +3122,7 @@ mdc_xattr_list_populate(struct mdc_conf *conf, char *tmp_str) mdc_xattr_str = GF_MALLOC(max_size, gf_common_mt_char); GF_CHECK_ALLOC(mdc_xattr_str, ret, out); + mdc_xattr_str[0] = '\0'; if (conf->cache_capability) strcat(mdc_xattr_str, "security.capability,"); -- cgit