summaryrefslogtreecommitdiffstats
path: root/xlators
diff options
context:
space:
mode:
authorRaghavendra G <rgowdapp@redhat.com>2014-09-16 13:55:03 -0400
committerVijay Bellur <vbellur@redhat.com>2014-09-16 21:25:56 -0700
commita6499d32292ca5a1418e1c785d617317226b2f53 (patch)
tree74e54b4399efc67c5f1207da1405c1c470ad1a8a /xlators
parent11d222932d8c52a5d734cb4d33804a98ded89c92 (diff)
cluster/dht: fix memory corruption in locking api.
<man 3 qsort> The contents of the array are sorted in ascending order according to a comparison function pointed to by compar, which is called with two arguments that "point to the objects being compared". </man 3 qsort> qsort passes "pointers to members of the array" to comparision function. Since the members of the array happen to be (dht_lock_t *), the arguments passed to dht_lock_request_cmp are of type (dht_lock_t **). Previously we assumed them to be of type (dht_lock_t *), which resulted in memory corruption. Change-Id: Iee0758704434beaff3c3a1ad48d549cbdc9e1c96 BUG: 1142406 Signed-off-by: Raghavendra G <rgowdapp@redhat.com> Reviewed-on-master: http://review.gluster.org/8659 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Shyamsundar Ranganathan <srangana@redhat.com> Reviewed-by: Vijay Bellur <vbellur@redhat.com> Reviewed-on: http://review.gluster.org/8750
Diffstat (limited to 'xlators')
-rw-r--r--xlators/cluster/dht/src/dht-helper.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/xlators/cluster/dht/src/dht-helper.c b/xlators/cluster/dht/src/dht-helper.c
index b9715c6d1b6..c3cfc7d6066 100644
--- a/xlators/cluster/dht/src/dht-helper.c
+++ b/xlators/cluster/dht/src/dht-helper.c
@@ -1728,8 +1728,8 @@ dht_lock_request_cmp (const void *val1, const void *val2)
dht_lock_t *lock2 = NULL;
int ret = 0;
- lock1 = (dht_lock_t *)val1;
- lock2 = (dht_lock_t *)val2;
+ lock1 = *(dht_lock_t **)val1;
+ lock2 = *(dht_lock_t **)val2;
GF_VALIDATE_OR_GOTO ("dht-locks", lock1, out);
GF_VALIDATE_OR_GOTO ("dht-locks", lock2, out);