Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp11256393ybi; Thu, 25 Jul 2019 12:50:14 -0700 (PDT) X-Google-Smtp-Source: APXvYqzT96EXTT72Bs/GHCucKzpvGxE9WfwTdRwW9Fug2HkOhY54p+18Wofc7/sS6yBTLr4ZAtDb X-Received: by 2002:a17:90a:b908:: with SMTP id p8mr6751143pjr.94.1564084214738; Thu, 25 Jul 2019 12:50:14 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564084214; cv=none; d=google.com; s=arc-20160816; b=qnjx7upsH7aSW2wVb7OOZBjLU/L+EqjMX0lxNn1UNdXxY9PSCpJmf1Vu7VIdNQwGmF GaaVVSjRjkkCE+xsWz5bC10aNLDdpaeJyvme8xZGo6w/pnEHH8E2fAkovnkN6LKLkPm4 Gc0nsuZ6DhN3y85fvxDUQDUQNKConbB2Rh10lYSJigoe5sT7LhikfmLyLRjd/ZFl0x0y mtJqkpKMkgbtDQPHCmf3evdhacqwNu0iBXOHgttLFctzvSZvOG48qBpOdC8ifE+wh3X2 ar13Vr6mH68oYrwl2Y5LCgE8YkIIACbMgtohHCMPGNHoXU6cHfYhXAzLLmAOu9dyoFno 3CPw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:to:from :dkim-signature; bh=QpkYN7FS0vv7AK1SdnAf8oOSyU+XRiuQBNES0LDTrxg=; b=YojK4p557Bh5QY+DbUXp9J4XT6uOTxyLAH2RtHRFWZNRdBj3boXIfJx3lpbHUwDgpU wiEQWuIaZHl5jUUoe8o4YE4xbAmbtXiUWTbcEKVlEo9nAc2fT1t37KaIC7JzyxGNWNsN yF7lAaPHB0NyP3PQ1GHsFJvSp5923HKV4/wYYOsnwcpWHPzeXmkiUTSYncMLrnFkIPNn wvvhVhXHBO0w4jK3UA5pFg9Zk/1KLRXPFOaSJ8Kj3XEx6JCY3VNnPgZYpjrk0VSCquws VUfPmREOOlZCxxwES6cobOwu2wiig7Kevm+BV6+9DRlUHMoKw/mBBRdMVMGeWDXa/nCN 3j9Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@silvair-com.20150623.gappssmtp.com header.s=20150623 header.b=V50dBrLS; spf=pass (google.com: best guess record for domain of linux-bluetooth-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d38si18072023pgl.519.2019.07.25.12.50.00; Thu, 25 Jul 2019 12:50:14 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-bluetooth-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@silvair-com.20150623.gappssmtp.com header.s=20150623 header.b=V50dBrLS; spf=pass (google.com: best guess record for domain of linux-bluetooth-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-bluetooth-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1725819AbfGYTts (ORCPT + 99 others); Thu, 25 Jul 2019 15:49:48 -0400 Received: from mail-lf1-f68.google.com ([209.85.167.68]:45599 "EHLO mail-lf1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726349AbfGYTts (ORCPT ); Thu, 25 Jul 2019 15:49:48 -0400 Received: by mail-lf1-f68.google.com with SMTP id u10so35376835lfm.12 for ; Thu, 25 Jul 2019 12:49:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=silvair-com.20150623.gappssmtp.com; s=20150623; h=from:to:subject:date:message-id:in-reply-to:references:mime-version :content-transfer-encoding; bh=QpkYN7FS0vv7AK1SdnAf8oOSyU+XRiuQBNES0LDTrxg=; b=V50dBrLS9WLQx5rOAzapvtheAEUw7txzXbe1DHGIj5mz1+NBnv7uylHfOoWHis333u tsMQy8O9NjW+o11wppfzQaBAofL5kzc5MzgR7vRoqGnurePlJcGhQxIY+hJuFtmV92tL apByd2EEq7eqvFxMdWUC93lnKmAfeJoV7bfATyUlJENfMbyVxT8pzvhpEQIspWBEGXun Qghe+LkG3soLN2AnIs7/wi5E6tlAQACK5JJcnkwmjaDiFRzcAGvnXQGK1jh6RrSYrWwN ZmQECaclLcqLFoTHzur8QmNTXL1a0fZLihT3tOEvWJZ9dbLi9iOOhLmlfcOBci3nsbmL e1Sg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=QpkYN7FS0vv7AK1SdnAf8oOSyU+XRiuQBNES0LDTrxg=; b=A7DJM38BWILjz5erwdVjg/VGpyyOAfSn9gAMIV7mcOqOyDk6lzj8qiYRdJQi6MFe0N YJG4B+g95iXcbAHlcXTOC4lQI/8hLWr502uxR3WEx1HPqbp03pUBz7ZC115DnNoCPp0W x1MAfYb4/hqexXfFuD6CiTm0gmvsrRRM8xyMAkAD5ZoYxTPapYPohBVgs6599BlRe6rK dlNJKhFRgL/FdKiVipK7zRUYMQbDQwDkEBuikPIC8wyVURkmXD+LvY4IU/9f0mjcRQNj I8nbWOXr68iFy0TL+s1AEY7OgUTh1qrVwy+g8Y2tzsO1fSAXoIlYRc+xB5U/vFaNUgW3 hNXA== X-Gm-Message-State: APjAAAVJ9zMa9GygZ5D4dRUQzZ9wnSZBRc4mOoiVmrbkO1MXUB/rER3t PCRKpvA4tI+p+w/YVmufpB4pgdzxmss= X-Received: by 2002:a19:80c4:: with SMTP id b187mr40569154lfd.122.1564084185907; Thu, 25 Jul 2019 12:49:45 -0700 (PDT) Received: from kynes.internet.domowy (apn-95-40-32-72.dynamic.gprs.plus.pl. [95.40.32.72]) by smtp.gmail.com with ESMTPSA id e62sm9327693ljf.82.2019.07.25.12.49.44 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 25 Jul 2019 12:49:45 -0700 (PDT) From: =?UTF-8?q?Micha=C5=82=20Lowas-Rzechonek?= To: linux-bluetooth@vger.kernel.org Subject: [PATCH BlueZ v4 4/5] mesh: Check that element indexes are consecutive Date: Thu, 25 Jul 2019 21:49:32 +0200 Message-Id: <20190725194933.7321-5-michal.lowas-rzechonek@silvair.com> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190725194933.7321-1-michal.lowas-rzechonek@silvair.com> References: <20190725194933.7321-1-michal.lowas-rzechonek@silvair.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-bluetooth-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-bluetooth@vger.kernel.org --- mesh/node.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/mesh/node.c b/mesh/node.c index 68cce7baf..1709a25ba 100644 --- a/mesh/node.c +++ b/mesh/node.c @@ -898,6 +898,7 @@ uint8_t node_friend_mode_get(struct mesh_node *node) uint16_t node_generate_comp(struct mesh_node *node, uint8_t *buf, uint16_t sz) { uint16_t n, features; + uint16_t num_ele = 0; const struct l_queue_entry *ele_entry; if (!node || !node->comp || sz < MIN_COMP_SIZE) @@ -935,6 +936,11 @@ uint16_t node_generate_comp(struct mesh_node *node, uint8_t *buf, uint16_t sz) uint8_t num_s = 0, num_v = 0; uint8_t *mod_buf; + if (ele->idx != num_ele) + return 0; + + num_ele++; + /* At least fit location and zeros for number of models */ if ((n + 4) > sz) return n; @@ -997,6 +1003,9 @@ element_done: } + if (!num_ele) + return 0; + return n; } -- 2.22.0