Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp8454290ybi; Tue, 23 Jul 2019 08:50:41 -0700 (PDT) X-Google-Smtp-Source: APXvYqyhifCAT0iRuUpC9RwtPnf172Vsw0VwlIkuHXFsZz42xwRFA3yEcu12Re1FEn+vphoLhvcJ X-Received: by 2002:a17:90a:26ef:: with SMTP id m102mr81865594pje.50.1563897041689; Tue, 23 Jul 2019 08:50:41 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1563897041; cv=none; d=google.com; s=arc-20160816; b=at4VwS6OSfhYBj4i2Q7V7X6chIFACBkQDNJIbtT2V9ApUOTa9jl5pKaDLP4gzUqZ/O ztxYCKuZa0xvp6Nkd4nh+8/bk3VKI/NNO0b7erdDQ9+knfaRIsoLJJ/HczhP/Zu5XU2i nyq1PvpAsU1RQrmm7QtZ/65ORj6dEM8NzqYBr+OcK3NK26BZ4+dqV/RWnAq5Qh9NCJIc gH7zevZZTvAs4bI3tRwXYXmzjJiWlp6SQXhRIeU7MAjY2oROIQSO46Dl7zzflEbDXzFD RD1bwszzeaU0cIBDOHNUhO5LY2dapVJKfy87xeesunHyFVs/WfIdGgMbD1W8XdKjD8dI MUog== 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=BnIf+ZgYdmO2D7WkXt5x3wzW/Af9phA5gGRMDubhoqw=; b=ua2QWQ1RkrI8CqX2TNkasgAW9JgJQ6eiqBR96Ldpy3eJZbjK8gy1/D2RpKg16EnA7F GSMooRSR2B8LW3yk4P1IqPyP98IKrEIV0FI65dqzv0/jVQkYw+aDNZcFXUD17p1iMiAV tKT+61mp/y/U/TxYlWtgi5urqFIed5WEbSKoHpIXi/PuJgtULXuStPD2C8LZU6VTN5SG 109VcQIerc6OElhI5YJ3sMC7H+jM8q1ZtUifaVB1VjVa3BW2dlupTr8KuVJmxtPXER3c Agij60f60rgk3l0ZGGpb0lIB7HTPUWFluGQp6bI+S5GJ4FZpsZKiITwbmuFxWQu8Pd6X eoqA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@silvair-com.20150623.gappssmtp.com header.s=20150623 header.b=naHeW1DS; 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 a191si12799867pge.93.2019.07.23.08.50.26; Tue, 23 Jul 2019 08:50:41 -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=naHeW1DS; 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 S1732896AbfGWKGk (ORCPT + 99 others); Tue, 23 Jul 2019 06:06:40 -0400 Received: from mail-lj1-f195.google.com ([209.85.208.195]:46021 "EHLO mail-lj1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726293AbfGWKGh (ORCPT ); Tue, 23 Jul 2019 06:06:37 -0400 Received: by mail-lj1-f195.google.com with SMTP id m23so40394311lje.12 for ; Tue, 23 Jul 2019 03:06: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=BnIf+ZgYdmO2D7WkXt5x3wzW/Af9phA5gGRMDubhoqw=; b=naHeW1DSFLQqMQmolwSFyGld7lRrqdjH04gIEd1gj+nUl3eEk3YxUj9kH1ueyL8G/e Q3JRjH1FT7aksTj637cwCx48iyJb9kPOzAAwUokBuGtH1iU/8s+eO5UOEPZCrsGZJJG7 nR4UtryrUCHD5w26haJZj1Q/82cZ3I95gPDt5SIPMt97dS+DY29b+tjc2PEtKVqn186y 7Guztyb44zs9oJ7d33c2cpkcNsgH4yf38/s8t98wlTowIMOyy6xJmTLDOzr9NCBVrmWW xPnpk/h/REjyVA0oZb3m1dxCIV4h60qhrAzSAKb0Gzw8mwmZCKfroN4oLbGd0Oz8/e09 +F5w== 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=BnIf+ZgYdmO2D7WkXt5x3wzW/Af9phA5gGRMDubhoqw=; b=pfVAafwZqA1XD7Exz1Z/X5MhjXJBGYK6hgiL2Xp9IbgodBIMv0phigaSlOwC9qhQpF xxZgz8+dHgBCDrY71xrxW3v4HS/dkveIzkxTmc4Z30AxbbxRWhGdAlHZ53HUKF55yi9i Dn0UtlPPbkw8c4t852x2Pyu5dLt+0/7DPM+DixZB9pYldE6xJWCBfF/0zCzr4AAFIOys +9Zsh2wD4Hypu5yaSAfK+rSFafKVfw2iiFV5WJ21MpQPWrMwYJLEK6uZ/tXYkr1lW1Um ACQKH4jxYXFczJqLmjq6oQzX4K9W4vu5AJ9Et/tzrKxTfv+QFjXS+8JFPpA4ir14m4z4 WkiQ== X-Gm-Message-State: APjAAAXM4ET9qo7g2ZxzZvUai7jIocgY8eEs8Ph6pH6SBqWrDDFehyuG y0tdinnQ5XelbAYRfwhw8MI5v2FdSsk= X-Received: by 2002:a2e:88d3:: with SMTP id a19mr39661174ljk.32.1563876395542; Tue, 23 Jul 2019 03:06:35 -0700 (PDT) Received: from mlowasrzechonek2133.silvair.lan ([217.153.94.18]) by smtp.gmail.com with ESMTPSA id h129sm6395260lfd.74.2019.07.23.03.06.34 for (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Tue, 23 Jul 2019 03:06:34 -0700 (PDT) From: =?UTF-8?q?Micha=C5=82=20Lowas-Rzechonek?= To: linux-bluetooth@vger.kernel.org Subject: [PATCH BlueZ v2 4/5] mesh: Check that element indexes are consecutive Date: Tue, 23 Jul 2019 12:06:22 +0200 Message-Id: <20190723100623.6957-5-michal.lowas-rzechonek@silvair.com> X-Mailer: git-send-email 2.19.1 In-Reply-To: <20190723100623.6957-1-michal.lowas-rzechonek@silvair.com> References: <20190723100623.6957-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 This patch checks that application does not omit element indexes. --- mesh/node.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/mesh/node.c b/mesh/node.c index bfb0dc5b4..8ff75c110 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