Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp10821121ybi; Thu, 25 Jul 2019 05:45:01 -0700 (PDT) X-Google-Smtp-Source: APXvYqwiAR7J2Qjd3Ovs1z3On2KWKKQPW/MLJoTh1nVGtZ/i6gwkyuXNua4mP8HJ4dvAMyZtdQuA X-Received: by 2002:a6b:7602:: with SMTP id g2mr71546418iom.82.1564058701902; Thu, 25 Jul 2019 05:45:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1564058701; cv=none; d=google.com; s=arc-20160816; b=IGBvbLVxFe2a8XAaUh34vKrKY9QC9PPVVJ2na7g+VcFu/ELPy7QnyIPI1VpibvH1B1 vTm8f8w+NvAKXy3NGFc3b+POI93WhALzx2uOZAy6U2WqutZ2agu7RDdxghnhfwdCz+WZ w23r6XHeD03+hQ89hJ0iUgXYJ3sH/WypeNgPJeHkZHK94WiwCoq0sAZ69H60S2T+MDiD cI3lkYJdPlixnG2Sj67pD3nFb+4/598BC9A/48ox73AHY0iwproA7f5w83XIINcHDU2k /HIVH6WATG5ZZrDxsCMQ5ygr/j6JBv79kamN0mYniPD4dzMHUi45wnnq2a4FWFgjKqnM 71cw== 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=4vWZxijFrCIkrmaihouwzhm3/yYh1xKm2hMyiO9HK/0=; b=Yo7HI9C0jV+u7TjFVwgzRmiAVKfo9vqMYTNHex8zsz1PmLvGCNUQJRk0OQNdJcLcct v2dbp603zZ6SwVnigqoA3ZABuPixW6HjFpXZYBRpSc2SXpTQC20dqY+iXlh106Z30KbV jJb0HX6Ey/lxC+jwGkwaV0BbHy/L/gGCUI6tzOLQFOxm9T4C7D7k1Ixf+SEhBjRDemKE JAatfLsgCuJNa11bINWrxRTPjYqNk2WBmkZZSvzRqw+povfe1HM2RNRWy5iOOEgFL329 VULNZ0rO/93RhWPG8QoxJm0Lk0fhK5tc3usFzcOhkBwrD3Py0Obm+t3ZEpUC0t6e6ryH JZxA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@silvair-com.20150623.gappssmtp.com header.s=20150623 header.b=e0vZ6gU7; 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 g12si77258848jao.11.2019.07.25.05.44.39; Thu, 25 Jul 2019 05:45:01 -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=e0vZ6gU7; 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 S2389228AbfGYIOi (ORCPT + 99 others); Thu, 25 Jul 2019 04:14:38 -0400 Received: from mail-lj1-f196.google.com ([209.85.208.196]:36760 "EHLO mail-lj1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2389116AbfGYIOh (ORCPT ); Thu, 25 Jul 2019 04:14:37 -0400 Received: by mail-lj1-f196.google.com with SMTP id i21so47148905ljj.3 for ; Thu, 25 Jul 2019 01:14:36 -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=4vWZxijFrCIkrmaihouwzhm3/yYh1xKm2hMyiO9HK/0=; b=e0vZ6gU7pIxoDU8+Tht5PO5LAd8Y6wr66ys9MUN8Cxt12glnXl1z+49iT83G+pblgw sSmCreZzUhimO9drLxcfOu2sFYGcnG0AfpxCeMvxEZmSeGxb7CjhUsVrCmJk+B5uLeUq rwbx6nEpuuziuZSLkK5tD2Y6Ih686PQh/457LZQEbUjs18gU/i9C/QGVxQM+2dtbPDvj rsKQ6PcCv5CLUpeGxvWsUbBhHQHgvq7h4vo0U7Ydm3Ibidipfw/T4sVkUSN3vw2tIjPx MyyeXG+WyJK9TtqdDG/11nDFAjfjED4vDx2iqhLwaiHGp9gj3gwGX+WNEB5/5vApxUkY 78Xg== 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=4vWZxijFrCIkrmaihouwzhm3/yYh1xKm2hMyiO9HK/0=; b=OrFseFhRo4Am6Qw8e1TvGgqblzfFtCyGqe2YX2cu0d2a3CT6ozG7KiqunPGpICqLrs 6wbCXBUOnRKGmnmQH4T6z4GsWe5w8rIAsA1e8giTgvDnk9X/9eCoBudWwHAsXurlQlNr B3tizBbqssv6FRxeRUD40WPO+FEBf+u1Ij/bfO8uS/3eeAtxht6qGB0w7OEjvcecuGiZ gqIyQJRBsVGyn2TqmJxTvb2x5B35yWOC5rcFX4J0Y0Dc0hi3X1n4daJZsko6zJR21sPx 1iuNvmPdM/skVOtsPmBgphVwkcUchdBReSitj+c7okRB6kptVylwY9aWc6mUexHIebrj NArg== X-Gm-Message-State: APjAAAVwCOpJHznpCIoNbSgQZ5pM3qJ5v9mQ573D3hoW222oPI/xxTgU zXC83f3R6Onq9m8u/sRpv9Oyyd9xd4c= X-Received: by 2002:a2e:9a49:: with SMTP id k9mr44857137ljj.78.1564042475362; Thu, 25 Jul 2019 01:14:35 -0700 (PDT) Received: from mlowasrzechonek2133.silvair.lan ([217.153.94.18]) by smtp.gmail.com with ESMTPSA id 199sm9015251ljf.44.2019.07.25.01.14.34 for (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Thu, 25 Jul 2019 01:14:34 -0700 (PDT) From: =?UTF-8?q?Micha=C5=82=20Lowas-Rzechonek?= To: linux-bluetooth@vger.kernel.org Subject: [PATCH BlueZ v3 4/5] mesh: Check that element indexes are consecutive Date: Thu, 25 Jul 2019 10:14:23 +0200 Message-Id: <20190725081424.22621-5-michal.lowas-rzechonek@silvair.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190725081424.22621-1-michal.lowas-rzechonek@silvair.com> References: <20190725081424.22621-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 5a1866bea..1b58d9395 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.19.1