a3470f
From 1aa17a84422024a4941843474b58f78827b9d2c9 Mon Sep 17 00:00:00 2001
a3470f
From: Amar Tumballi <amarts@redhat.com>
a3470f
Date: Tue, 24 Jul 2018 13:25:12 +0530
a3470f
Subject: [PATCH 336/351] dict: handle negative key/value length while
a3470f
 unserialize
a3470f
a3470f
BUG: 1607407
a3470f
Change-Id: Ie56df0da46c242846a1ba51ccb9e011af118b119
a3470f
Signed-off-by: Amar Tumballi <amarts@redhat.com>
a3470f
Reviewed-on: https://code.engineering.redhat.com/gerrit/145895
a3470f
Reviewed-by: Pranith Kumar Karampuri <pkarampu@redhat.com>
a3470f
Reviewed-by: Atin Mukherjee <amukherj@redhat.com>
a3470f
Tested-by: Atin Mukherjee <amukherj@redhat.com>
a3470f
---
a3470f
 libglusterfs/src/dict.c | 3 ++-
a3470f
 1 file changed, 2 insertions(+), 1 deletion(-)
a3470f
a3470f
diff --git a/libglusterfs/src/dict.c b/libglusterfs/src/dict.c
a3470f
index 36d91a7..40458ca 100644
a3470f
--- a/libglusterfs/src/dict.c
a3470f
+++ b/libglusterfs/src/dict.c
a3470f
@@ -3003,7 +3003,8 @@ dict_unserialize (char *orig_buf, int32_t size, dict_t **fill)
a3470f
                 vallen = ntoh32 (hostord);
a3470f
                 buf += DICT_DATA_HDR_VAL_LEN;
a3470f
 
a3470f
-                if ((buf + keylen) > (orig_buf + size)) {
a3470f
+                if ((keylen < 0) || (vallen < 0) ||
a3470f
+                    (buf + keylen) > (orig_buf + size)) {
a3470f
                         gf_msg_callingfn ("dict", GF_LOG_ERROR, 0,
a3470f
                                           LG_MSG_UNDERSIZED_BUF,
a3470f
                                           "undersized buffer passed. "
a3470f
-- 
a3470f
1.8.3.1
a3470f