diff options
| author | Günther Deschner <gd@samba.org> | 2017-10-09 18:05:03 +0200 | 
|---|---|---|
| committer | Shyamsundar Ranganathan <srangana@redhat.com> | 2017-10-25 14:00:03 +0000 | 
| commit | 83615a663c1ac17812c8417dc56b85be600d17e3 (patch) | |
| tree | f3a142631c8a161e5f562a93a66f6b0d92b00255 /xlators/performance | |
| parent | fea9e398da9865ce193d347d14fe2d56fe9946a2 (diff) | |
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 <gd@samba.org>
> Pair-Programmed-With: Michael Adam <obnox@samba.org>
> Change-Id: If723c465a630b8a37b6be58782a2724df7ac6b11
> BUG: 1476324
> Reviewed-on: https://review.gluster.org/17910
> Reviewed-by: Michael Adam <obnox@samba.org>
> Smoke: Gluster Build System <jenkins@build.gluster.org>
> Reviewed-by: Poornima G <pgurusid@redhat.com>
> Tested-by: Poornima G <pgurusid@redhat.com>
> CentOS-regression: Gluster Build System <jenkins@build.gluster.org>
> (cherry picked from commit ab4ffdac9dec1867f2d9b33242179cf2b347319d)
Change-Id: If723c465a630b8a37b6be58782a2724df7ac6b11
BUG: 1499893
Signed-off-by: Günther Deschner <gd@samba.org>
Diffstat (limited to 'xlators/performance')
| -rw-r--r-- | xlators/performance/md-cache/src/md-cache.c | 2 | 
1 files changed, 1 insertions, 1 deletions
diff --git a/xlators/performance/md-cache/src/md-cache.c b/xlators/performance/md-cache/src/md-cache.c index b6969cda56e..001012a2e46 100644 --- a/xlators/performance/md-cache/src/md-cache.c +++ b/xlators/performance/md-cache/src/md-cache.c @@ -626,7 +626,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) {  | 
