From a862ca969cfd4dc9309e8123e6e90c4e47f9b89b Mon Sep 17 00:00:00 2001 From: N Balachandran Date: Wed, 30 Aug 2017 10:01:54 +0530 Subject: perf/qr: Use a ref-ed data to extract content qr_content_extract used dict_get to get the value of the GF_CONTENT_KEY key. dict_get does not ref the data before returning it so QR could be acting on freed memory if another thread deletes the key before then. This patch also fixes a race in dict_get_with_ref. Fix: Use dict_get_with_ref to retrieve the file contents. > BUG: 1484709 > Signed-off-by: N Balachandran > Reviewed-on: https://review.gluster.org/18115 > Smoke: Gluster Build System > Reviewed-by: Amar Tumballi > Tested-by: Raghavendra G > CentOS-regression: Gluster Build System > Reviewed-by: Raghavendra G Change-Id: Ib1a7a70bb92eed7e70747ec530e0b3edc53127ec BUG: 1486538 (cherry picked from commit 414d3e92fc56f08e320a3aa65b6b18e65b384551) Signed-off-by: N Balachandran Reviewed-on: https://review.gluster.org/18145 Reviewed-by: Raghavendra G Smoke: Gluster Build System CentOS-regression: Gluster Build System Reviewed-by: MOHIT AGRAWAL --- libglusterfs/src/dict.h | 1 + 1 file changed, 1 insertion(+) (limited to 'libglusterfs/src/dict.h') diff --git a/libglusterfs/src/dict.h b/libglusterfs/src/dict.h index 93ffa3e8cc7..b1313636092 100644 --- a/libglusterfs/src/dict.h +++ b/libglusterfs/src/dict.h @@ -105,6 +105,7 @@ int32_t dict_set (dict_t *this, char *key, data_t *value); /* function to set a new key/value pair (without checking for duplicate) */ int32_t dict_add (dict_t *this, char *key, data_t *value); +int dict_get_with_ref (dict_t *this, char *key, data_t **data); data_t *dict_get (dict_t *this, char *key); void dict_del (dict_t *this, char *key); int dict_reset (dict_t *dict); -- cgit