sdp: Fix Out-of-bounds heap read in service_search_attr_req function 33/150033/1
authorLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
Wed, 13 Sep 2017 07:01:40 +0000 (10:01 +0300)
committerDoHyun Pyun <dh79.pyun@samsung.com>
Thu, 14 Sep 2017 05:16:20 +0000 (14:16 +0900)
Check if there is enough data to continue otherwise return an error.
(CVE-2017-1000250)

Change-Id: I45d44d1bad703fa22af0f1d13cf710686ad64aae
Signed-off-by: DoHyun Pyun <dh79.pyun@samsung.com>
src/sdpd-request.c

index 1eefdce..318d044 100755 (executable)
@@ -917,7 +917,7 @@ static int service_search_attr_req(sdp_req_t *req, sdp_buf_t *buf)
        } else {
                /* continuation State exists -> get from cache */
                sdp_buf_t *pCache = sdp_get_cached_rsp(cstate);
-               if (pCache) {
+               if (pCache && cstate->cStateValue.maxBytesSent < pCache->data_size) {
                        uint16_t sent = MIN(max, pCache->data_size - cstate->cStateValue.maxBytesSent);
                        pResponse = pCache->data;
                        memcpy(buf->data, pResponse + cstate->cStateValue.maxBytesSent, sent);