summaryrefslogtreecommitdiffstats
path: root/xlators/storage/posix/src/posix-helpers.c
diff options
context:
space:
mode:
authorXavi Hernandez <xhernandez@redhat.com>2019-12-20 14:14:32 +0100
committerRinku Kothiya <rkothiya@redhat.com>2020-03-16 08:21:00 +0000
commitdfaaace24d26d8e39f7783e99ac7440eafeced74 (patch)
treeb7718bf5f276dbe46f400105930288d8b1ef20bf /xlators/storage/posix/src/posix-helpers.c
parent87f1163e83339b2c2923106e0d9a45e8a327bb7a (diff)
multiple: fix bad type cast
When using inode_ctx_get() or inode_ctx_set(), a 'uint64_t *' is expected. In many cases, the value to retrieve or store is a pointer, which will be of smaller size in some architectures (for example 32-bits). In this case, directly passing the address of the pointer casted to an 'uint64_t *' is wrong and can cause memory corruption. Backport of: > Change-Id: Iae616da9dda528df6743fa2f65ae5cff5ad23258 > Signed-off-by: Xavi Hernandez <xhernandez@redhat.com> > Fixes: bz#1785611 Change-Id: Iae616da9dda528df6743fa2f65ae5cff5ad23258 Signed-off-by: Xavi Hernandez <xhernandez@redhat.com> Fixes: bz#1785323
Diffstat (limited to 'xlators/storage/posix/src/posix-helpers.c')
-rw-r--r--xlators/storage/posix/src/posix-helpers.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/xlators/storage/posix/src/posix-helpers.c b/xlators/storage/posix/src/posix-helpers.c
index d2beeed1f4a..0ee412875ef 100644
--- a/xlators/storage/posix/src/posix-helpers.c
+++ b/xlators/storage/posix/src/posix-helpers.c
@@ -2828,7 +2828,8 @@ __posix_inode_ctx_get(inode_t *inode, xlator_t *this)
pthread_mutex_init(&ctx_p->write_atomic_lock, NULL);
pthread_mutex_init(&ctx_p->pgfid_lock, NULL);
- ret = __inode_ctx_set(inode, this, (uint64_t *)&ctx_p);
+ ctx_uint = (uint64_t)(uintptr_t)ctx_p;
+ ret = __inode_ctx_set(inode, this, &ctx_uint);
if (ret < 0) {
pthread_mutex_destroy(&ctx_p->xattrop_lock);
pthread_mutex_destroy(&ctx_p->write_atomic_lock);