summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMohammed Azhar Padariyakam <mpadariy@redhat.com>2017-11-02 14:57:28 +0530
committerAmar Tumballi <amarts@redhat.com>2017-11-06 07:42:51 +0000
commit2891f993ac1cee6198661682039cf499a0824f2e (patch)
tree0b7849361a2c33ac315fe715bf156636397fdfa3
parentaf8604d5e9826df57aee7aba235d2e77a7e7f8fb (diff)
server-helpers: Coverity Fix CONSTANT_EXPRESSION_RESULT in serialize_rsp_direntp
Issue : "trav->dict.dict_len > 4294967295U" is always false regardless of the values of its operands. .But dict_serialized_length can return < 0 when error happens. Solution : Remove the comparison which always turns out to be false and add a new condition for error checking. Fix : The if-condition was renewed. Coverity-Id: 108 from [1] [1]: https://download.gluster.org/pub/gluster/glusterfs/static-analysis/master/glusterfs-coverity/2017-10-30-9aa574a5/html/ Change-Id: I9956b6ca7c4bf7444f19aadd3b32fceac011a44e BUG: 789278 Signed-off-by: Mohammed Azhar Padariyakam <mpadariy@redhat.com>
-rw-r--r--xlators/protocol/server/src/server-helpers.c7
1 files changed, 5 insertions, 2 deletions
diff --git a/xlators/protocol/server/src/server-helpers.c b/xlators/protocol/server/src/server-helpers.c
index 385e5b70ee8..35f6cd00564 100644
--- a/xlators/protocol/server/src/server-helpers.c
+++ b/xlators/protocol/server/src/server-helpers.c
@@ -856,6 +856,7 @@ serialize_rsp_direntp (gf_dirent_t *entries, gfs3_readdirp_rsp *rsp)
gfs3_dirplist *trav = NULL;
gfs3_dirplist *prev = NULL;
int ret = -1;
+ int temp = 0;
GF_VALIDATE_OR_GOTO ("server", entries, out);
GF_VALIDATE_OR_GOTO ("server", rsp, out);
@@ -875,8 +876,9 @@ serialize_rsp_direntp (gf_dirent_t *entries, gfs3_readdirp_rsp *rsp)
/* if 'dict' is present, pack it */
if (entry->dict) {
- trav->dict.dict_len = dict_serialized_length (entry->dict);
- if (trav->dict.dict_len > UINT_MAX) {
+ temp = dict_serialized_length (entry->dict);
+
+ if (temp < 0) {
gf_msg (THIS->name, GF_LOG_ERROR, EINVAL,
PS_MSG_INVALID_ENTRY, "failed to get "
"serialized length of reply dict");
@@ -884,6 +886,7 @@ serialize_rsp_direntp (gf_dirent_t *entries, gfs3_readdirp_rsp *rsp)
trav->dict.dict_len = 0;
goto out;
}
+ trav->dict.dict_len = temp;
trav->dict.dict_val = GF_CALLOC (1, trav->dict.dict_len,
gf_server_mt_rsp_buf_t);