summaryrefslogtreecommitdiffstats
path: root/xlators/lib
diff options
context:
space:
mode:
authorPranith Kumar K <pkarampu@redhat.com>2015-03-06 12:37:15 +0530
committerRaghavendra G <rgowdapp@redhat.com>2015-03-09 03:15:06 -0700
commitb5e50cd714d105ff7aa1544182f07fb60320710d (patch)
tree34a7411e442cf2d5ea6935cb9b03f7e111a677f2 /xlators/lib
parent5ab4a17a63acf7215e9dc98276e7547ae527a5a7 (diff)
libxlator: Make sure marker_xattr is valid
Problem: marker_xattr is allocated only when the op_ret is 0. If the final response is a failure, then the marker time is dict_set with key as NULL. this will be changed to ref:<address-of-value> by dict_set, so the value won't appear on the marker-key when the getxattr_cbk is in dht. So dht unwinds with failure EINVAL. Fix: Always populate marker_xattr. Fixed dict mem-leak as well. Change-Id: I1752f277a8852c47b0a2ccce9fd72ee88456ac02 BUG: 1199406 Signed-off-by: Pranith Kumar K <pkarampu@redhat.com> Reviewed-on: http://review.gluster.org/9817 Tested-by: Gluster Build System <jenkins@build.gluster.com> Reviewed-by: Raghavendra G <rgowdapp@redhat.com> Tested-by: Raghavendra G <rgowdapp@redhat.com>
Diffstat (limited to 'xlators/lib')
-rw-r--r--xlators/lib/src/libxlator.c30
1 files changed, 17 insertions, 13 deletions
diff --git a/xlators/lib/src/libxlator.c b/xlators/lib/src/libxlator.c
index 4e680c510ca..0b5036c8ba8 100644
--- a/xlators/lib/src/libxlator.c
+++ b/xlators/lib/src/libxlator.c
@@ -143,10 +143,10 @@ cluster_markerxtime_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
int ret = -1;
uint32_t *net_timebuf = NULL;
uint32_t host_timebuf[2] = {0,};
- char *marker_xattr = NULL;
+ char marker_xattr[128] = {0};
xl_marker_local_t *local = NULL;
- char *vol_uuid = NULL;
char need_unwind = 0;
+ gf_boolean_t unref = _gf_false;
if (!this || !frame || !frame->local || !cookie) {
gf_log ("", GF_LOG_DEBUG, "possible NULL deref");
@@ -161,24 +161,18 @@ cluster_markerxtime_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
goto out;
}
+ snprintf (marker_xattr, sizeof (marker_xattr), "%s.%s.%s",
+ MARKER_XATTR_PREFIX, local->vol_uuid, XTIME);
+
LOCK (&frame->lock);
{
callcnt = --local->call_count;
- vol_uuid = local->vol_uuid;
-
if (op_ret) {
marker_local_incr_errcount (local, op_errno);
goto unlock;
}
- if (!gf_asprintf (&marker_xattr, "%s.%s.%s",
- MARKER_XATTR_PREFIX, vol_uuid, XTIME)) {
- op_errno = ENOMEM;
- goto unlock;
- }
-
-
if (dict_get_ptr (dict, marker_xattr, (void **)&net_timebuf)) {
gf_log (this->name, GF_LOG_WARNING,
"Unable to get <uuid>.xtime attr");
@@ -211,8 +205,16 @@ unlock:
need_unwind = 1;
if (local->count[MCNT_FOUND]) {
- if (!dict)
+ if (!dict) {
dict = dict_new();
+ if (dict) {
+ unref = _gf_true;
+ } else {
+ op_ret = -1;
+ op_errno = ENOMEM;
+ goto out;
+ }
+ }
ret = dict_set_static_bin (dict, marker_xattr,
(void *)local->net_timebuf, 8);
@@ -239,7 +241,9 @@ out:
dict, xdata);
}
- GF_FREE (marker_xattr);
+ if (unref)
+ dict_unref (dict);
+
return 0;
}