diff options
author | Dmitry Antipov <dmantipov@yandex.ru> | 2019-12-26 15:25:35 +0300 |
---|---|---|
committer | Amar Tumballi <amarts@gmail.com> | 2019-12-27 16:59:42 +0000 |
commit | 7656aec3b9ef60592c8cf251dfb5cdb6088cd328 (patch) | |
tree | f746427618b260c3ad759437cc1bb62395019463 /libglusterfs | |
parent | f5aafeffed3a5363ff200e9300dec5855f680d9c (diff) |
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 <dmantipov@yandex.ru>
Diffstat (limited to 'libglusterfs')
-rw-r--r-- | libglusterfs/src/inode.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/libglusterfs/src/inode.c b/libglusterfs/src/inode.c index 89e2092927a..6086219ebb1 100644 --- a/libglusterfs/src/inode.c +++ b/libglusterfs/src/inode.c @@ -957,6 +957,7 @@ __inode_link(inode_t *inode, inode_t *parent, const char *name, inode_t *old_inode = NULL; inode_table_t *table = NULL; inode_t *link_inode = NULL; + char link_uuid_str[64] = {0}, parent_uuid_str[64] = {0}; table = inode->table; @@ -1031,11 +1032,12 @@ __inode_link(inode_t *inode, inode_t *parent, const char *name, if (!old_dentry || old_dentry->inode != link_inode) { dentry = dentry_create(link_inode, parent, name); if (!dentry) { - gf_msg_callingfn( - THIS->name, GF_LOG_ERROR, 0, LG_MSG_DENTRY_CREATE_FAILED, - "dentry create failed on " - "inode %s with parent %s", - uuid_utoa(link_inode->gfid), uuid_utoa(parent->gfid)); + gf_msg_callingfn(THIS->name, GF_LOG_ERROR, 0, + LG_MSG_DENTRY_CREATE_FAILED, + "dentry create failed on " + "inode %s with parent %s", + uuid_utoa_r(link_inode->gfid, link_uuid_str), + uuid_utoa_r(parent->gfid, parent_uuid_str)); errno = ENOMEM; return NULL; } |