Linux bluetooth development
 help / color / mirror / Atom feed
From: Luiz Augusto von Dentz <luiz.dentz@gmail.com>
To: linux-bluetooth@vger.kernel.org
Subject: [PATCH BlueZ v2 4/5] shared/micp: Fix reading Mute State from an empty notification
Date: Wed, 11 Nov 2026 15:39:48 -0500	[thread overview]
Message-ID: <20261111203949.3874673-5-luiz.dentz@gmail.com> (raw)
In-Reply-To: <20261111203949.3874673-1-luiz.dentz@gmail.com>

From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

micp_mute_state_notify copied one byte from the notification value
without checking its length, so a notification with no value made it
read past the value.

Pull the byte from the value instead and ignore the notification if it
is missing.

Fixes: 5c788b73 ("src/shared/micp.c: To implement MICP profile MICS service")
Assisted-by: OpenCode:claude-sonnet-5.5
---
 src/shared/micp.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/src/shared/micp.c b/src/shared/micp.c
index 98baff689fcc..7df8f8346f55 100644
--- a/src/shared/micp.c
+++ b/src/shared/micp.c
@@ -717,9 +717,16 @@ static void micp_mute_state_notify(struct bt_micp *micp, uint16_t value_handle,
 					const uint8_t *value, uint16_t length,
 					void *user_data)
 {
+	struct iovec iov = {
+		.iov_base = (void *)value,
+		.iov_len = length,
+	};
 	uint8_t mute_state;
 
-	memcpy(&mute_state, value, sizeof(mute_state));
+	if (!util_iov_pull_u8(&iov, &mute_state)) {
+		DBG(micp, "Unable to get Mute state");
+		return;
+	}
 
 	DBG(micp, "Mute state: 0x%x", mute_state);
 }
-- 
2.56.0


  parent reply	other threads:[~2026-11-11 20:39 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-11 20:39 [PATCH BlueZ v2 0/5] shared: Use util_iov helpers in gatt-db, hog, asha and micp Luiz Augusto von Dentz
2026-11-11 20:39 ` [PATCH BlueZ v2 1/5] shared/gatt-db: Use util_iov helpers to build and parse values Luiz Augusto von Dentz
2026-11-12  2:09   ` shared: Use util_iov helpers in gatt-db, hog, asha and micp bluez.test.bot
2026-11-11 20:39 ` [PATCH BlueZ v2 2/5] shared/hog: Use util_iov helpers to parse characteristic values Luiz Augusto von Dentz
2026-11-11 20:39 ` [PATCH BlueZ v2 3/5] shared/asha: " Luiz Augusto von Dentz
2026-11-11 20:39 ` Luiz Augusto von Dentz [this message]
2026-11-11 20:39 ` [PATCH BlueZ v2 5/5] shared/micp: Use util_iov_pull_mem instead of a local helper Luiz Augusto von Dentz
2026-11-12 17:50 ` [PATCH BlueZ v2 0/5] shared: Use util_iov helpers in gatt-db, hog, asha and micp patchwork-bot+bluetooth

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20261111203949.3874673-5-luiz.dentz@gmail.com \
    --to=luiz.dentz@gmail.com \
    --cc=linux-bluetooth@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox