From: Luiz Augusto von Dentz <luiz.dentz@gmail.com>
To: linux-bluetooth@vger.kernel.org
Subject: [PATCH BlueZ] advertising: Fix crash when if client invalidate property
Date: Fri, 19 Jan 2018 11:37:07 -0200 [thread overview]
Message-ID: <20180119133707.18249-1-luiz.dentz@gmail.com> (raw)
From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
If a property is invalidated the iter is set to NULL which should be
checked and properly reset.
---
src/advertising.c | 54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 54 insertions(+)
diff --git a/src/advertising.c b/src/advertising.c
index 94a8c4050..f00db86bd 100644
--- a/src/advertising.c
+++ b/src/advertising.c
@@ -203,6 +203,9 @@ static bool parse_type(DBusMessageIter *iter, struct btd_adv_client *client)
{
const char *msg_type;
+ if (!iter)
+ return true;
+
if (dbus_message_iter_get_arg_type(iter) != DBUS_TYPE_STRING)
return false;
@@ -226,6 +229,11 @@ static bool parse_service_uuids(DBusMessageIter *iter,
{
DBusMessageIter ariter;
+ if (!iter) {
+ bt_ad_clear_service_uuid(client->data);
+ return true;
+ }
+
if (dbus_message_iter_get_arg_type(iter) != DBUS_TYPE_ARRAY)
return false;
@@ -262,6 +270,11 @@ static bool parse_solicit_uuids(DBusMessageIter *iter,
{
DBusMessageIter ariter;
+ if (!iter) {
+ bt_ad_clear_solicit_uuid(client->data);
+ return true;
+ }
+
if (dbus_message_iter_get_arg_type(iter) != DBUS_TYPE_ARRAY)
return false;
@@ -298,6 +311,11 @@ static bool parse_manufacturer_data(DBusMessageIter *iter,
{
DBusMessageIter entries;
+ if (!iter) {
+ bt_ad_clear_manufacturer_data(client->data);
+ return true;
+ }
+
if (dbus_message_iter_get_arg_type(iter) != DBUS_TYPE_ARRAY)
return false;
@@ -353,6 +371,11 @@ static bool parse_service_data(DBusMessageIter *iter,
{
DBusMessageIter entries;
+ if (!iter) {
+ bt_ad_clear_service_data(client->data);
+ return true;
+ }
+
if (dbus_message_iter_get_arg_type(iter) != DBUS_TYPE_ARRAY)
return false;
@@ -422,11 +445,19 @@ static bool parse_includes(DBusMessageIter *iter,
{
DBusMessageIter entries;
+ if (!iter) {
+ client->flags = 0;
+ return true;
+ }
+
if (dbus_message_iter_get_arg_type(iter) != DBUS_TYPE_ARRAY)
return false;
dbus_message_iter_recurse(iter, &entries);
+ /* Reset flags before parsing */
+ client->flags = 0;
+
while (dbus_message_iter_get_arg_type(&entries) == DBUS_TYPE_STRING) {
const char *str;
struct adv_include *inc;
@@ -456,6 +487,12 @@ static bool parse_local_name(DBusMessageIter *iter,
{
const char *name;
+ if (!iter) {
+ free(client->name);
+ client->name = NULL;
+ return true;
+ }
+
if (dbus_message_iter_get_arg_type(iter) != DBUS_TYPE_STRING)
return false;
@@ -475,6 +512,11 @@ static bool parse_local_name(DBusMessageIter *iter,
static bool parse_appearance(DBusMessageIter *iter,
struct btd_adv_client *client)
{
+ if (!iter) {
+ client->appearance = 0;
+ return true;
+ }
+
if (dbus_message_iter_get_arg_type(iter) != DBUS_TYPE_UINT16)
return false;
@@ -491,6 +533,11 @@ static bool parse_appearance(DBusMessageIter *iter,
static bool parse_duration(DBusMessageIter *iter,
struct btd_adv_client *client)
{
+ if (!iter) {
+ client->duration = 0;
+ return true;
+ }
+
if (dbus_message_iter_get_arg_type(iter) != DBUS_TYPE_UINT16)
return false;
@@ -516,6 +563,13 @@ static gboolean client_timeout(void *user_data)
static bool parse_timeout(DBusMessageIter *iter,
struct btd_adv_client *client)
{
+ if (!iter) {
+ client->timeout = 0;
+ g_source_remove(client->to_id);
+ client->to_id = 0;
+ return true;
+ }
+
if (dbus_message_iter_get_arg_type(iter) != DBUS_TYPE_UINT16)
return false;
--
2.14.3
next reply other threads:[~2018-01-19 13:37 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-01-19 13:37 Luiz Augusto von Dentz [this message]
2018-03-06 8:53 ` [PATCH BlueZ] advertising: Fix crash when if client invalidate property Luiz Augusto von Dentz
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=20180119133707.18249-1-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;
as well as URLs for NNTP newsgroup(s).