From 7656aec3b9ef60592c8cf251dfb5cdb6088cd328 Mon Sep 17 00:00:00 2001 From: Dmitry Antipov Date: Thu, 26 Dec 2019 15:25:35 +0300 Subject: Avoid buffer overwrite due to uuid_utoa() misuse Code like: f(..., uuid_utoa(x), uuid_utoa(y)); is not valid (causes undefined behaviour) because uuid_utoa() uses the only static thread-local buffer which will be overwritten by the subsequent call. All such cases should be converted to use uuid_utoa_r() with explicitly specified buffer. Change-Id: I5e72bab806d96a9dd1707c28ed69ca033b9c8d6c Updates: bz#1193929 Signed-off-by: Dmitry Antipov --- xlators/cluster/afr/src/afr-self-heal-entry.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'xlators/cluster/afr') diff --git a/xlators/cluster/afr/src/afr-self-heal-entry.c b/xlators/cluster/afr/src/afr-self-heal-entry.c index 3ce882e8c4a..e7062289c79 100644 --- a/xlators/cluster/afr/src/afr-self-heal-entry.c +++ b/xlators/cluster/afr/src/afr-self-heal-entry.c @@ -86,6 +86,7 @@ afr_selfheal_recreate_entry(call_frame_t *frame, int dst, int source, 0, }; unsigned char *newentry = NULL; + char dir_uuid_str[64] = {0}, iatt_uuid_str[64] = {0}; priv = this->private; iatt = &replies[source].poststat; @@ -93,8 +94,8 @@ afr_selfheal_recreate_entry(call_frame_t *frame, int dst, int source, gf_msg(this->name, GF_LOG_ERROR, 0, AFR_MSG_SELF_HEAL_FAILED, "Invalid ia_type (%d) or gfid(%s). source brick=%d, " "pargfid=%s, name=%s", - iatt->ia_type, uuid_utoa(iatt->ia_gfid), source, - uuid_utoa(dir->gfid), name); + iatt->ia_type, uuid_utoa_r(iatt->ia_gfid, iatt_uuid_str), source, + uuid_utoa_r(dir->gfid, dir_uuid_str), name); ret = -EINVAL; goto out; } -- cgit