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: 1212660
Signed-off-by: Jeff Darcy <jdarcy@redhat.com>
Reviewed-on: http://review.gluster.org/10319
Reviewed-by: Krishnan Parthasarathi <kparthas@redhat.com>
Tested-by: NetBSD Build System
Tested-by: Gluster Build System <jenkins@build.gluster.com>
Reviewed-by: Krutika Dhananjay <kdhananj@redhat.com>
Reviewed-by: Atin Mukherjee <amukherj@redhat.com>
Reviewed-by: Vijay Bellur <vbellur@redhat.com>
This commit is contained in:
Jeff Darcy 2015-04-21 11:48:15 -04:00 committed by Vijay Bellur
parent f1bdc3f186
commit 765849ee00

View File

@ -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;
}