linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH BlueZ] gatt: Fix possible crash when unable to generate hash
@ 2020-06-03 17:35 Luiz Augusto von Dentz
  2020-06-03 21:06 ` Luiz Augusto von Dentz
  0 siblings, 1 reply; 2+ messages in thread
From: Luiz Augusto von Dentz @ 2020-06-03 17:35 UTC (permalink / raw)
  To: linux-bluetooth

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

gatt_db_get_hash actually depends on crypto so platforms that don't
have it enabled shall not register GATT_CHARAC_DB_HASH as otherwise it
would cause a crash due to hash being NULL.
---
 src/gatt-database.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/src/gatt-database.c b/src/gatt-database.c
index 8cbe09bae..d717bbcde 100644
--- a/src/gatt-database.c
+++ b/src/gatt-database.c
@@ -1211,10 +1211,14 @@ static void populate_gatt_service(struct btd_gatt_database *database)
 				cli_feat_read_cb, cli_feat_write_cb,
 				database);
 
-	bt_uuid16_create(&uuid, GATT_CHARAC_DB_HASH);
-	database->db_hash = gatt_db_service_add_characteristic(service,
+
+	/* Only expose database hash chrc if supported */
+	if (gatt_db_get_hash(database->db)) {
+		bt_uuid16_create(&uuid, GATT_CHARAC_DB_HASH);
+		database->db_hash = gatt_db_service_add_characteristic(service,
 				&uuid, BT_ATT_PERM_READ, BT_GATT_CHRC_PROP_READ,
 				db_hash_read_cb, NULL, database);
+	}
 
 	/* Only enable EATT if there is a socket listening */
 	if (database->eatt_io) {
-- 
2.25.3


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH BlueZ] gatt: Fix possible crash when unable to generate hash
  2020-06-03 17:35 [PATCH BlueZ] gatt: Fix possible crash when unable to generate hash Luiz Augusto von Dentz
@ 2020-06-03 21:06 ` Luiz Augusto von Dentz
  0 siblings, 0 replies; 2+ messages in thread
From: Luiz Augusto von Dentz @ 2020-06-03 21:06 UTC (permalink / raw)
  To: linux-bluetooth

Hi,

On Wed, Jun 3, 2020 at 10:35 AM Luiz Augusto von Dentz
<luiz.dentz@gmail.com> wrote:
>
> From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
>
> gatt_db_get_hash actually depends on crypto so platforms that don't
> have it enabled shall not register GATT_CHARAC_DB_HASH as otherwise it
> would cause a crash due to hash being NULL.
> ---
>  src/gatt-database.c | 8 ++++++--
>  1 file changed, 6 insertions(+), 2 deletions(-)
>
> diff --git a/src/gatt-database.c b/src/gatt-database.c
> index 8cbe09bae..d717bbcde 100644
> --- a/src/gatt-database.c
> +++ b/src/gatt-database.c
> @@ -1211,10 +1211,14 @@ static void populate_gatt_service(struct btd_gatt_database *database)
>                                 cli_feat_read_cb, cli_feat_write_cb,
>                                 database);
>
> -       bt_uuid16_create(&uuid, GATT_CHARAC_DB_HASH);
> -       database->db_hash = gatt_db_service_add_characteristic(service,
> +
> +       /* Only expose database hash chrc if supported */
> +       if (gatt_db_get_hash(database->db)) {
> +               bt_uuid16_create(&uuid, GATT_CHARAC_DB_HASH);
> +               database->db_hash = gatt_db_service_add_characteristic(service,
>                                 &uuid, BT_ATT_PERM_READ, BT_GATT_CHRC_PROP_READ,
>                                 db_hash_read_cb, NULL, database);
> +       }
>
>         /* Only enable EATT if there is a socket listening */
>         if (database->eatt_io) {
> --
> 2.25.3

Push.

-- 
Luiz Augusto von Dentz

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2020-06-03 21:06 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-06-03 17:35 [PATCH BlueZ] gatt: Fix possible crash when unable to generate hash Luiz Augusto von Dentz
2020-06-03 21:06 ` Luiz Augusto von Dentz

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).