gluster-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Gluster-devel] [PATCH BUG:493] Remove pointer casting (copy data to pro


From: Hraban Luyat
Subject: [Gluster-devel] [PATCH BUG:493] Remove pointer casting (copy data to proper memory before using it). Fixes bug #493.
Date: Sun, 20 Dec 2009 09:36:13 +0100
User-agent: Mutt/1.5.20 (2009-06-14)

Hello,

See bug #493 for more information on this patch.

http://bugs.gluster.com/cgi-bin/bugzilla3/show_bug.cgi?id=493#c2

This patch assumes that the scope of disk_layout is local wherever it is
used. Seems correct, not really checked, though.

Greetings,

Hraban Luyat

Signed-off-by: Hraban Luyat <address@hidden>
---
 xlators/cluster/dht/src/dht-layout.c |   12 ++++++++----
 1 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/xlators/cluster/dht/src/dht-layout.c 
b/xlators/cluster/dht/src/dht-layout.c
index 4b7b44f..2646f31 100644
--- a/xlators/cluster/dht/src/dht-layout.c
+++ b/xlators/cluster/dht/src/dht-layout.c
@@ -315,7 +315,8 @@ dht_layout_merge (xlator_t *this, dht_layout_t *layout, 
xlator_t *subvol,
        int      i     = 0;
        int      ret   = -1;
        int      err   = -1;
-       int32_t *disk_layout = NULL;
+       int32_t  disk_layout[4];
+       void    *disk_layout_raw = NULL;
 
 
        if (op_ret != 0) {
@@ -338,7 +339,8 @@ dht_layout_merge (xlator_t *this, dht_layout_t *layout, 
xlator_t *subvol,
        if (xattr) {
                /* during lookup and not mkdir */
                ret = dict_get_ptr (xattr, "trusted.glusterfs.dht",
-                                   VOID(&disk_layout));
+                                   &disk_layout_raw);
+               memcpy (disk_layout, disk_layout_raw, sizeof(disk_layout));
        }
 
        if (ret != 0) {
@@ -606,7 +608,8 @@ dht_layout_dir_mismatch (xlator_t *this, dht_layout_t 
*layout, xlator_t *subvol,
        int       ret = 0;
         int       err = 0;
         int       dict_ret = 0;
-       int32_t  *disk_layout = NULL;
+       int32_t   disk_layout[4];
+       void     *disk_layout_raw = NULL;
        int32_t   count = -1;
        uint32_t  start_off = -1;
        uint32_t  stop_off = -1;
@@ -640,7 +643,8 @@ dht_layout_dir_mismatch (xlator_t *this, dht_layout_t 
*layout, xlator_t *subvol,
        }
 
        dict_ret = dict_get_ptr (xattr, "trusted.glusterfs.dht",
-                                 VOID(&disk_layout));
+                                 &disk_layout_raw);
+       memcpy (disk_layout, disk_layout_raw, sizeof(disk_layout));
        
        if (dict_ret < 0) {
                 if (err == 0) {
-- 
1.6.5





reply via email to

[Prev in Thread] Current Thread [Next in Thread]