From 24422a6f1599597b3a378fa2ff392aa40f5a33f5 Mon Sep 17 00:00:00 2001 From: Jeff Darcy Date: Tue, 21 Apr 2015 11:48:15 -0400 Subject: core: avoid crashes in gf_msg dup-detection code Use global_xlator for allocations so that we don't try to free objects belonging to an already-deleted translator (which will crash). Change-Id: Ie72a546e7770cf5cb8a8370e22448c8d09e3ab37 BUG: 1214220 Signed-off-by: Jeff Darcy Reviewed-on: http://review.gluster.org/10319 Reviewed-by: Krishnan Parthasarathi Tested-by: Gluster Build System Reviewed-by: Krutika Dhananjay Reviewed-by: Atin Mukherjee Reviewed-by: Vijay Bellur Reviewed-on: http://review.gluster.org/10330 Tested-by: NetBSD Build System --- libglusterfs/src/logging.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'libglusterfs') diff --git a/libglusterfs/src/logging.c b/libglusterfs/src/logging.c index 3b0c1e8244c..774dd092660 100644 --- a/libglusterfs/src/logging.c +++ b/libglusterfs/src/logging.c @@ -296,6 +296,18 @@ log_buf_init (log_buf_t *buf, const char *domain, const char *file, int errnum, uint64_t msgid, char **appmsgstr, int graph_id) { int ret = -1; + xlator_t *old_THIS; + extern xlator_t global_xlator; + + /* + * The current translator will be put in the block header for any + * memory block we allocate here. Unfortunately, these objects might + * outlive the current translator, and if we then try to dereference + * that pointer we go BOOM. Since this is really a global structure, + * use the global translator. + */ + old_THIS = THIS; + THIS = &global_xlator; if (!buf || !domain || !file || !function || !appmsgstr || !*appmsgstr) goto out; @@ -326,6 +338,7 @@ log_buf_init (log_buf_t *buf, const char *domain, const char *file, ret = 0; out: + THIS = old_THIS; return ret; } -- cgit