From 32f2c108d11ad8893511a4e869885caafa28df78 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Lowas-Rzechonek?= Date: Tue, 11 Aug 2020 15:39:07 +0200 Subject: [PATCH] mesh: Fix application key binding lookup Because l_queue_find can't distinguish between entry->data equal to zero and missing entry, has_binding() fails when we bind app key with index 0, via L_UINT_TO_PTR. Bug has been introduced in commit 1a2a6debd --- mesh/model.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/mesh/model.c b/mesh/model.c index 17b58b473..690be29d5 100644 --- a/mesh/model.c +++ b/mesh/model.c @@ -111,7 +111,13 @@ static bool simple_match(const void *a, const void *b) static bool has_binding(struct l_queue *bindings, uint16_t idx) { - return l_queue_find(bindings, simple_match, L_UINT_TO_PTR(idx)) != NULL; + const struct l_queue_entry *entry; + + for (entry = l_queue_get_entries(bindings); entry; entry = entry->next) + if (L_PTR_TO_INT(entry->data) == idx) + return true; + + return false; } static bool find_virt_by_label(const void *a, const void *b) -- 2.47.3