From ab4ffdac9dec1867f2d9b33242179cf2b347319d Mon Sep 17 00:00:00 2001 From: Günther Deschner Date: Fri, 28 Jul 2017 13:38:16 +0200 Subject: md-cache: avoid checking the xattr value buffer with string functions. xattrs may very well contain binary, non-text data with leading 0 values. Using strcmp for checking empty values is not the appropriate thing to do: In the best case, it might treat a binary xattr value starting with 0 from being cached (and hence also from being reported back with xattr). In the worst case, we might read beyond the end of a data blob that does contain any zero byte. We fix this by checking the length of the data blob and checking the first byte against 0 if the length is one. Signed-off-by: Guenther Deschner Pair-Programmed-With: Michael Adam Change-Id: If723c465a630b8a37b6be58782a2724df7ac6b11 BUG: 1476324 Reviewed-on: https://review.gluster.org/17910 Reviewed-by: Michael Adam Smoke: Gluster Build System Reviewed-by: Poornima G Tested-by: Poornima G CentOS-regression: Gluster Build System --- xlators/performance/md-cache/src/md-cache.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'xlators/performance/md-cache/src') diff --git a/xlators/performance/md-cache/src/md-cache.c b/xlators/performance/md-cache/src/md-cache.c index 71fcabab271..364210232cb 100644 --- a/xlators/performance/md-cache/src/md-cache.c +++ b/xlators/performance/md-cache/src/md-cache.c @@ -633,7 +633,7 @@ updatefn(dict_t *dict, char *key, data_t *value, void *data) * not update their cache if the value of a xattr is a 0 byte * data (i.e. ""). */ - if (!strcmp (value->data, "")) + if (value->len == 1 && value->data[0] == '\0') continue; if (dict_set(u->dict, key, value) < 0) { -- cgit