Patchwork [BUG:1756,1/4,v2] protocol/server: be consistent in setting rsp.dict_len and rsp.dict

login
register
Submitter Anand Avati
Date 2010-10-12 06:51:32
Message ID <20101012065132.GA21979@dev.gluster.com>
Download mbox | patch
Permalink /patch/5458/
State Accepted
Headers show

Comments

Anand Avati - 2010-10-12 06:51:32
in cases where op_ret was -1 and dict was not NULL, the code was
setting a dictionary length but not the serialized dictionary. This
would cause crashes in the xdr serialization function

Signed-off-by: Anand V. Avati <avati@blackhole.gluster.com>
---
 xlators/protocol/server/src/server3_1-fops.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

Patch

diff --git a/xlators/protocol/server/src/server3_1-fops.c b/xlators/protocol/server/src/server3_1-fops.c
index 821729c..0c6db91 100644
--- a/xlators/protocol/server/src/server3_1-fops.c
+++ b/xlators/protocol/server/src/server3_1-fops.c
@@ -88,7 +88,7 @@  server_lookup_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
                 return 0;
         }
 
-        if (dict) {
+        if ((op_ret >= 0) && dict) {
                 rsp.dict.dict_len = dict_serialized_length (dict);
                 if (rsp.dict.dict_len < 0) {
                         gf_log (this->name, GF_LOG_ERROR,
@@ -98,10 +98,9 @@  server_lookup_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
                         op_ret   = -1;
                         op_errno = EINVAL;
                         rsp.dict.dict_len = 0;
+                        goto out;
                 }
-        }
 
-        if ((op_ret >= 0) && dict) {
                 rsp.dict.dict_val = GF_CALLOC (1, rsp.dict.dict_len,
                                                gf_server_mt_rsp_buf_t);
                 if (!rsp.dict.dict_val) {
@@ -118,6 +117,7 @@  server_lookup_cbk (call_frame_t *frame, void *cookie, xlator_t *this,
                         op_ret = -1;
                         op_errno = -ret;
                         rsp.dict.dict_len = 0;
+                        goto out;
                 }
         }