From: Oliver Chang <ochang@google.com>
To: linux-bluetooth@vger.kernel.org
Cc: hadess@hadess.net, Oliver Chang <ochang@google.com>
Subject: [PATCH BlueZ 1/1] Fixed heap-buffer-overflow in `compute_seq_size`.
Date: Sun, 10 Aug 2025 06:46:58 +0000 [thread overview]
Message-ID: <20250810064656.1810093-4-ochang@google.com> (raw)
In-Reply-To: <20250810064656.1810093-2-ochang@google.com>
By adding checks for sequence/alternate types in element_end to avoid a
type confusion.
This issue was found by OSS-Fuzz.
This can be triggered by using an input of
`<sequence><foo/><text/></sequence>` against the harness in
https://github.com/google/oss-fuzz/blob/master/projects/bluez/fuzz_xml.c
https://issues.oss-fuzz.com/issues/42516062
https://oss-fuzz.com/testcase-detail/5896441415729152
---
src/sdp-xml.c | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/src/sdp-xml.c b/src/sdp-xml.c
index 5efa62ab8..81bd11140 100644
--- a/src/sdp-xml.c
+++ b/src/sdp-xml.c
@@ -545,6 +545,13 @@ static void element_end(GMarkupParseContext *context,
}
if (!strcmp(element_name, "sequence")) {
+ if (!SDP_IS_SEQ(ctx_data->stack_head->data->dtd)) {
+ g_set_error(err, G_MARKUP_ERROR, G_MARKUP_ERROR_INVALID_CONTENT,
+ "Unexpected data type %d for sequence",
+ ctx_data->stack_head->data->dtd);
+ return;
+ }
+
ctx_data->stack_head->data->unitSize = compute_seq_size(ctx_data->stack_head->data);
if (ctx_data->stack_head->data->unitSize > USHRT_MAX) {
@@ -557,6 +564,13 @@ static void element_end(GMarkupParseContext *context,
ctx_data->stack_head->data->unitSize += sizeof(uint8_t);
}
} else if (!strcmp(element_name, "alternate")) {
+ if (!SDP_IS_ALT(ctx_data->stack_head->data->dtd)) {
+ g_set_error(err, G_MARKUP_ERROR, G_MARKUP_ERROR_INVALID_CONTENT,
+ "Unexpected data type %d for alternate",
+ ctx_data->stack_head->data->dtd);
+ return;
+ }
+
ctx_data->stack_head->data->unitSize = compute_seq_size(ctx_data->stack_head->data);
if (ctx_data->stack_head->data->unitSize > USHRT_MAX) {
--
2.50.1.703.g449372360f-goog
next prev parent reply other threads:[~2025-08-10 6:47 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-08-10 6:46 [PATCH BlueZ 0/1] *** Fixed heap-buffer-overflow in `compute_seq_size` *** Oliver Chang
2025-08-10 6:46 ` Oliver Chang [this message]
2025-08-10 7:22 ` [PATCH BlueZ 1/1] Fixed heap-buffer-overflow in `compute_seq_size` Paul Menzel
2025-08-10 8:20 ` Oliver Chang
2025-08-10 20:20 ` Paul Menzel
2025-08-10 8:09 ` *** Fixed heap-buffer-overflow in `compute_seq_size` *** bluez.test.bot
-- strict thread matches above, loose matches on Subject: below --
2025-08-08 1:34 [PATCH BlueZ 0/1] Fixed a buffer overflow found by OSS-Fuzz Oliver Chang
2025-08-08 1:34 ` [PATCH BlueZ 1/1] Fixed heap-buffer-overflow in `compute_seq_size` Oliver Chang
2025-08-08 9:34 ` Bastien Nocera
[not found] ` <CAFqAZOL4iKjuxa=ubwFCGHyfgtuGBCW7F1US=1sYSoeWiMZpTg@mail.gmail.com>
2025-08-08 11:45 ` Oliver Chang
2025-08-08 14:08 ` Bastien Nocera
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=20250810064656.1810093-4-ochang@google.com \
--to=ochang@google.com \
--cc=hadess@hadess.net \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.