2022-09-23 15:02:52

by Christian Eggers

[permalink] [raw]
Subject: [PATCH BlueZ v2 0/9] properties_changed: check for NULL iterator

v2:
----
- 7/9: don't call memcpy(x, NULL, 0) [Scan Build]
- 9/9: shorten GIT summary [GitLint]

Christian Eggers (9):
advertising: parse_secondary: fix loop condition
advertising: parse_secondary: fix mask value
advertising: parse_secondary: check for NULL iterator
advertising: parse_min_interval: reset min_interval if iter is NULL
advertising: parse_[min|max]_interval: reset value if iter is NULL
advertising: parse_tx_power: reset value if iter is NULL
client/gatt: proxy_property_changed: check for NULL iterator
gatt: proxy_property_changed: check for NULL iterator
battery: provided_battery_property_changed_cb: check iterator

client/gatt.c | 17 ++++++++++-------
src/advertising.c | 22 +++++++++++++++++-----
src/battery.c | 10 ++++++----
src/gatt-database.c | 20 +++++++++++---------
4 files changed, 44 insertions(+), 25 deletions(-)

--
2.35.3


2022-09-23 15:03:51

by Christian Eggers

[permalink] [raw]
Subject: [PATCH BlueZ v2 3/9] advertising: parse_secondary: check for NULL iterator

The passed iterator can be NULL as in
gdbus/client.c::properties_changed():
...
proxy->prop_func(..., ..., iter=NULL, ...)
+--src/advertising.c::properties_changed(..., ..., iter, ...);
+--parse_secondary(iter, ...);
...
---
src/advertising.c | 6 ++++++
1 file changed, 6 insertions(+)

diff --git a/src/advertising.c b/src/advertising.c
index 42ac627604fe..6d8d06edd34f 100644
--- a/src/advertising.c
+++ b/src/advertising.c
@@ -1047,6 +1047,12 @@ static bool parse_secondary(DBusMessageIter *iter,
const char *str;
struct adv_secondary *sec;

+ if (!iter) {
+ /* Reset secondary channels */
+ client->flags &= ~MGMT_ADV_FLAG_SEC_MASK;
+ return true;
+ }
+
if (dbus_message_iter_get_arg_type(iter) != DBUS_TYPE_STRING)
return false;

--
2.35.3

2022-09-23 15:04:12

by Christian Eggers

[permalink] [raw]
Subject: [PATCH BlueZ v2 5/9] advertising: parse_[min|max]_interval: reset value if iter is NULL

Set property to its default value (as done in all other methods listed
in parsers[]).
---
src/advertising.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/advertising.c b/src/advertising.c
index fbfd90b4e300..25df2297b3c1 100644
--- a/src/advertising.c
+++ b/src/advertising.c
@@ -1120,8 +1120,10 @@ static bool parse_max_interval(DBusMessageIter *iter,
if (!(g_dbus_get_flags() & G_DBUS_FLAG_ENABLE_EXPERIMENTAL))
return true;

- if (!iter)
+ if (!iter) {
+ client->max_interval = 0;
return false;
+ }

if (dbus_message_iter_get_arg_type(iter) != DBUS_TYPE_UINT32)
return false;
--
2.35.3

2022-09-23 15:04:44

by Christian Eggers

[permalink] [raw]
Subject: [PATCH BlueZ v2 6/9] advertising: parse_tx_power: reset value if iter is NULL

Set property to its default value (as done in all other methods listed
in parsers[]).
---
src/advertising.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/advertising.c b/src/advertising.c
index 25df2297b3c1..f9748b1328bc 100644
--- a/src/advertising.c
+++ b/src/advertising.c
@@ -1153,8 +1153,10 @@ static bool parse_tx_power(DBusMessageIter *iter,
if (!(g_dbus_get_flags() & G_DBUS_FLAG_ENABLE_EXPERIMENTAL))
return true;

- if (!iter)
+ if (!iter) {
+ client->tx_power = ADV_TX_POWER_NO_PREFERENCE;
return false;
+ }

if (dbus_message_iter_get_arg_type(iter) != DBUS_TYPE_INT16)
return false;
--
2.35.3

2022-09-23 15:04:59

by Christian Eggers

[permalink] [raw]
Subject: [PATCH BlueZ v2 4/9] advertising: parse_min_interval: reset min_interval if iter is NULL

Set property to its default value (as done in all other methods listed
in parsers[]).
---
src/advertising.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/src/advertising.c b/src/advertising.c
index 6d8d06edd34f..fbfd90b4e300 100644
--- a/src/advertising.c
+++ b/src/advertising.c
@@ -1087,8 +1087,10 @@ static bool parse_min_interval(DBusMessageIter *iter,
if (!(g_dbus_get_flags() & G_DBUS_FLAG_ENABLE_EXPERIMENTAL))
return true;

- if (!iter)
+ if (!iter) {
+ client->min_interval = 0;
return false;
+ }

if (dbus_message_iter_get_arg_type(iter) != DBUS_TYPE_UINT32)
return false;
--
2.35.3

2022-09-23 15:05:02

by Christian Eggers

[permalink] [raw]
Subject: [PATCH BlueZ v2 9/9] battery: provided_battery_property_changed_cb: check iterator

The passed iterator can be NULL as in
gdbus/client.c::properties_changed():
...
proxy->prop_func(..., ..., iter=NULL, ...)
+--src/battery.c::provided_battery_property_changed_cb(, , iter, );
+--dbus_message_iter_get_arg_type(iter);
...
---
src/battery.c | 10 ++++++----
1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/src/battery.c b/src/battery.c
index 77fee22b6e61..88a53e80e890 100644
--- a/src/battery.c
+++ b/src/battery.c
@@ -252,7 +252,7 @@ static void provided_battery_property_changed_cb(GDBusProxy *proxy,
DBusMessageIter *iter,
void *user_data)
{
- uint8_t percentage;
+ uint8_t percentage = 0;
const char *export_path;
DBusMessageIter dev_iter;

@@ -264,10 +264,12 @@ static void provided_battery_property_changed_cb(GDBusProxy *proxy,
if (strcmp(name, "Percentage") != 0)
return;

- if (dbus_message_iter_get_arg_type(iter) != DBUS_TYPE_BYTE)
- return;
+ if (iter) {
+ if (dbus_message_iter_get_arg_type(iter) != DBUS_TYPE_BYTE)
+ return;

- dbus_message_iter_get_basic(iter, &percentage);
+ dbus_message_iter_get_basic(iter, &percentage);
+ }

DBG("battery percentage changed on %s, percentage = %d",
g_dbus_proxy_get_path(proxy), percentage);
--
2.35.3

2022-09-23 15:05:03

by Christian Eggers

[permalink] [raw]
Subject: [PATCH BlueZ v2 8/9] gatt: proxy_property_changed: check for NULL iterator

The passed iterator can be NULL as in
src/gatt-database.c::properties_changed():
...
proxy->prop_func(..., ..., iter=NULL, ...)
+--client/gatt.c::property_changed_cb(..., ..., iter, ...);
+--dbus_message_iter_get_arg_type(iter);
...
---
src/gatt-database.c | 20 +++++++++++---------
1 file changed, 11 insertions(+), 9 deletions(-)

diff --git a/src/gatt-database.c b/src/gatt-database.c
index c72f4a4d5c54..ea282d4bc193 100644
--- a/src/gatt-database.c
+++ b/src/gatt-database.c
@@ -2867,17 +2867,19 @@ static void property_changed_cb(GDBusProxy *proxy, const char *name,
if (strcmp(name, "Value"))
return;

- if (dbus_message_iter_get_arg_type(iter) != DBUS_TYPE_ARRAY) {
- DBG("Malformed \"Value\" property received");
- return;
- }
+ if (iter) {
+ if (dbus_message_iter_get_arg_type(iter) != DBUS_TYPE_ARRAY) {
+ DBG("Malformed \"Value\" property received");
+ return;
+ }

- dbus_message_iter_recurse(iter, &array);
- dbus_message_iter_get_fixed_array(&array, &value, &len);
+ dbus_message_iter_recurse(iter, &array);
+ dbus_message_iter_get_fixed_array(&array, &value, &len);

- if (len < 0) {
- DBG("Malformed \"Value\" property received");
- return;
+ if (len < 0) {
+ DBG("Malformed \"Value\" property received");
+ return;
+ }
}

/* Truncate the value if it's too large */
--
2.35.3

2022-09-23 15:05:25

by Christian Eggers

[permalink] [raw]
Subject: [PATCH BlueZ v2 1/9] advertising: parse_secondary: fix loop condition

"secondary" isn't an array of pointers, so the iterator can never be
NULL.
---
src/advertising.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/advertising.c b/src/advertising.c
index 1fe371a9f345..15ef44def031 100644
--- a/src/advertising.c
+++ b/src/advertising.c
@@ -1055,7 +1055,7 @@ static bool parse_secondary(DBusMessageIter *iter,

dbus_message_iter_get_basic(iter, &str);

- for (sec = secondary; sec && sec->name; sec++) {
+ for (sec = secondary; sec->name; sec++) {
if (strcmp(str, sec->name))
continue;

--
2.35.3

2022-09-23 15:58:20

by bluez.test.bot

[permalink] [raw]
Subject: RE: properties_changed: check for NULL iterator

This is automated email and please do not reply to this email!

Dear submitter,

Thank you for submitting the patches to the linux bluetooth mailing list.
This is a CI test results with your patch series:
PW Link:https://patchwork.kernel.org/project/bluetooth/list/?series=679920

---Test result---

Test Summary:
CheckPatch PASS 4.24 seconds
GitLint FAIL 2.93 seconds
Prep - Setup ELL PASS 31.70 seconds
Build - Prep PASS 0.62 seconds
Build - Configure PASS 7.06 seconds
Build - Make PASS 884.89 seconds
Make Check PASS 11.33 seconds
Make Check w/Valgrind PASS 344.83 seconds
Make Distcheck PASS 211.00 seconds
Build w/ext ELL - Configure PASS 7.14 seconds
Build w/ext ELL - Make PASS 116.89 seconds
Incremental Build w/ patches PASS 533.39 seconds
Scan Build PASS 715.27 seconds

Details
##############################
Test: GitLint - FAIL
Desc: Run gitlint with rule in .gitlint
Output:
[BlueZ,v2,4/9] advertising: parse_min_interval: reset min_interval if iter is NULL
1: T1 Title exceeds max length (82>80): "[BlueZ,v2,4/9] advertising: parse_min_interval: reset min_interval if iter is NULL"




---
Regards,
Linux Bluetooth

2022-09-23 19:28:50

by Luiz Augusto von Dentz

[permalink] [raw]
Subject: Re: [PATCH BlueZ v2 0/9] properties_changed: check for NULL iterator

Hi Christian,

On Fri, Sep 23, 2022 at 8:02 AM Christian Eggers <[email protected]> wrote:

Perhaps you should rephrase to mention the NULL iter is actually the
result of invalidate properties.

> v2:
> ----
> - 7/9: don't call memcpy(x, NULL, 0) [Scan Build]
> - 9/9: shorten GIT summary [GitLint]
>
> Christian Eggers (9):
> advertising: parse_secondary: fix loop condition
> advertising: parse_secondary: fix mask value
> advertising: parse_secondary: check for NULL iterator
> advertising: parse_min_interval: reset min_interval if iter is NULL
> advertising: parse_[min|max]_interval: reset value if iter is NULL
> advertising: parse_tx_power: reset value if iter is NULL
> client/gatt: proxy_property_changed: check for NULL iterator
> gatt: proxy_property_changed: check for NULL iterator
> battery: provided_battery_property_changed_cb: check iterator
>
> client/gatt.c | 17 ++++++++++-------
> src/advertising.c | 22 +++++++++++++++++-----
> src/battery.c | 10 ++++++----
> src/gatt-database.c | 20 +++++++++++---------
> 4 files changed, 44 insertions(+), 25 deletions(-)
>
> --
> 2.35.3
>


--
Luiz Augusto von Dentz

2022-09-23 20:58:11

by patchwork-bot+bluetooth

[permalink] [raw]
Subject: Re: [PATCH BlueZ v2 0/9] properties_changed: check for NULL iterator

Hello:

This series was applied to bluetooth/bluez.git (master)
by Luiz Augusto von Dentz <[email protected]>:

On Fri, 23 Sep 2022 16:55:53 +0200 you wrote:
> v2:
> ----
> - 7/9: don't call memcpy(x, NULL, 0) [Scan Build]
> - 9/9: shorten GIT summary [GitLint]
>
> Christian Eggers (9):
> advertising: parse_secondary: fix loop condition
> advertising: parse_secondary: fix mask value
> advertising: parse_secondary: check for NULL iterator
> advertising: parse_min_interval: reset min_interval if iter is NULL
> advertising: parse_[min|max]_interval: reset value if iter is NULL
> advertising: parse_tx_power: reset value if iter is NULL
> client/gatt: proxy_property_changed: check for NULL iterator
> gatt: proxy_property_changed: check for NULL iterator
> battery: provided_battery_property_changed_cb: check iterator
>
> [...]

Here is the summary with links:
- [BlueZ,v2,1/9] advertising: parse_secondary: fix loop condition
https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=47821c473102
- [BlueZ,v2,2/9] advertising: parse_secondary: fix mask value
https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=2e4327816587
- [BlueZ,v2,3/9] advertising: parse_secondary: check for NULL iterator
https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=732eaa7ccf85
- [BlueZ,v2,4/9] advertising: parse_min_interval: reset min_interval if iter is NULL
https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=abfb3a807c39
- [BlueZ,v2,5/9] advertising: parse_[min|max]_interval: reset value if iter is NULL
https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=a18d66862da1
- [BlueZ,v2,6/9] advertising: parse_tx_power: reset value if iter is NULL
https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=47346e5390bb
- [BlueZ,v2,7/9] client/gatt: proxy_property_changed: check for NULL iterator
(no matching commit)
- [BlueZ,v2,8/9] gatt: proxy_property_changed: check for NULL iterator
https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=f5cbe08af22e
- [BlueZ,v2,9/9] battery: provided_battery_property_changed_cb: check iterator
https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=15895e401e1e

You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html


2022-09-29 16:51:34

by bluez.test.bot

[permalink] [raw]
Subject: RE: properties_changed: check for NULL iterator

This is an automated email and please do not reply to this email.

Dear Submitter,

Thank you for submitting the patches to the linux bluetooth mailing list.
While preparing the CI tests, the patches you submitted couldn't be applied to the current HEAD of the repository.

----- Output -----
error: patch failed: src/advertising.c:1055
error: src/advertising.c: patch does not apply
hint: Use 'git am --show-current-patch' to see the failed patch


Please resolve the issue and submit the patches again.


---
Regards,
Linux Bluetooth

2022-09-29 17:50:35

by bluez.test.bot

[permalink] [raw]
Subject: RE: properties_changed: check for NULL iterator

This is an automated email and please do not reply to this email.

Dear Submitter,

Thank you for submitting the patches to the linux bluetooth mailing list.
While preparing the CI tests, the patches you submitted couldn't be applied to the current HEAD of the repository.

----- Output -----
error: patch failed: src/advertising.c:1055
error: src/advertising.c: patch does not apply
hint: Use 'git am --show-current-patch' to see the failed patch


Please resolve the issue and submit the patches again.


---
Regards,
Linux Bluetooth

2022-09-29 18:50:38

by bluez.test.bot

[permalink] [raw]
Subject: RE: properties_changed: check for NULL iterator

This is an automated email and please do not reply to this email.

Dear Submitter,

Thank you for submitting the patches to the linux bluetooth mailing list.
While preparing the CI tests, the patches you submitted couldn't be applied to the current HEAD of the repository.

----- Output -----
error: patch failed: src/advertising.c:1055
error: src/advertising.c: patch does not apply
hint: Use 'git am --show-current-patch' to see the failed patch


Please resolve the issue and submit the patches again.


---
Regards,
Linux Bluetooth

2022-09-29 19:05:55

by bluez.test.bot

[permalink] [raw]
Subject: RE: properties_changed: check for NULL iterator

This is an automated email and please do not reply to this email.

Dear Submitter,

Thank you for submitting the patches to the linux bluetooth mailing list.
While preparing the CI tests, the patches you submitted couldn't be applied to the current HEAD of the repository.

----- Output -----
error: patch failed: src/advertising.c:1055
error: src/advertising.c: patch does not apply
hint: Use 'git am --show-current-patch' to see the failed patch


Please resolve the issue and submit the patches again.


---
Regards,
Linux Bluetooth

2022-09-29 19:55:23

by bluez.test.bot

[permalink] [raw]
Subject: RE: properties_changed: check for NULL iterator

This is an automated email and please do not reply to this email.

Dear Submitter,

Thank you for submitting the patches to the linux bluetooth mailing list.
While preparing the CI tests, the patches you submitted couldn't be applied to the current HEAD of the repository.

----- Output -----
error: patch failed: src/advertising.c:1055
error: src/advertising.c: patch does not apply
hint: Use 'git am --show-current-patch' to see the failed patch


Please resolve the issue and submit the patches again.


---
Regards,
Linux Bluetooth

2022-09-29 19:58:10

by bluez.test.bot

[permalink] [raw]
Subject: RE: properties_changed: check for NULL iterator

This is an automated email and please do not reply to this email.

Dear Submitter,

Thank you for submitting the patches to the linux bluetooth mailing list.
While preparing the CI tests, the patches you submitted couldn't be applied to the current HEAD of the repository.

----- Output -----
error: patch failed: src/advertising.c:1055
error: src/advertising.c: patch does not apply
hint: Use 'git am --show-current-patch' to see the failed patch


Please resolve the issue and submit the patches again.


---
Regards,
Linux Bluetooth

2022-09-29 20:42:25

by bluez.test.bot

[permalink] [raw]
Subject: RE: properties_changed: check for NULL iterator

This is an automated email and please do not reply to this email.

Dear Submitter,

Thank you for submitting the patches to the linux bluetooth mailing list.
While preparing the CI tests, the patches you submitted couldn't be applied to the current HEAD of the repository.

----- Output -----
error: patch failed: src/advertising.c:1055
error: src/advertising.c: patch does not apply
hint: Use 'git am --show-current-patch' to see the failed patch


Please resolve the issue and submit the patches again.


---
Regards,
Linux Bluetooth

2022-09-29 21:01:14

by bluez.test.bot

[permalink] [raw]
Subject: RE: properties_changed: check for NULL iterator

This is an automated email and please do not reply to this email.

Dear Submitter,

Thank you for submitting the patches to the linux bluetooth mailing list.
While preparing the CI tests, the patches you submitted couldn't be applied to the current HEAD of the repository.

----- Output -----
error: patch failed: src/advertising.c:1055
error: src/advertising.c: patch does not apply
hint: Use 'git am --show-current-patch' to see the failed patch


Please resolve the issue and submit the patches again.


---
Regards,
Linux Bluetooth

2022-09-29 21:41:26

by bluez.test.bot

[permalink] [raw]
Subject: RE: properties_changed: check for NULL iterator

This is an automated email and please do not reply to this email.

Dear Submitter,

Thank you for submitting the patches to the linux bluetooth mailing list.
While preparing the CI tests, the patches you submitted couldn't be applied to the current HEAD of the repository.

----- Output -----
error: patch failed: src/advertising.c:1055
error: src/advertising.c: patch does not apply
hint: Use 'git am --show-current-patch' to see the failed patch


Please resolve the issue and submit the patches again.


---
Regards,
Linux Bluetooth

2022-09-29 22:01:29

by bluez.test.bot

[permalink] [raw]
Subject: RE: properties_changed: check for NULL iterator

This is an automated email and please do not reply to this email.

Dear Submitter,

Thank you for submitting the patches to the linux bluetooth mailing list.
While preparing the CI tests, the patches you submitted couldn't be applied to the current HEAD of the repository.

----- Output -----
error: patch failed: src/advertising.c:1055
error: src/advertising.c: patch does not apply
hint: Use 'git am --show-current-patch' to see the failed patch


Please resolve the issue and submit the patches again.


---
Regards,
Linux Bluetooth

2022-09-29 22:46:38

by bluez.test.bot

[permalink] [raw]
Subject: RE: properties_changed: check for NULL iterator

This is an automated email and please do not reply to this email.

Dear Submitter,

Thank you for submitting the patches to the linux bluetooth mailing list.
While preparing the CI tests, the patches you submitted couldn't be applied to the current HEAD of the repository.

----- Output -----
error: patch failed: src/advertising.c:1055
error: src/advertising.c: patch does not apply
hint: Use 'git am --show-current-patch' to see the failed patch


Please resolve the issue and submit the patches again.


---
Regards,
Linux Bluetooth

2022-09-29 22:57:08

by bluez.test.bot

[permalink] [raw]
Subject: RE: properties_changed: check for NULL iterator

This is an automated email and please do not reply to this email.

Dear Submitter,

Thank you for submitting the patches to the linux bluetooth mailing list.
While preparing the CI tests, the patches you submitted couldn't be applied to the current HEAD of the repository.

----- Output -----
error: patch failed: src/advertising.c:1055
error: src/advertising.c: patch does not apply
hint: Use 'git am --show-current-patch' to see the failed patch


Please resolve the issue and submit the patches again.


---
Regards,
Linux Bluetooth

2022-09-29 23:49:29

by bluez.test.bot

[permalink] [raw]
Subject: RE: properties_changed: check for NULL iterator

This is an automated email and please do not reply to this email.

Dear Submitter,

Thank you for submitting the patches to the linux bluetooth mailing list.
While preparing the CI tests, the patches you submitted couldn't be applied to the current HEAD of the repository.

----- Output -----
error: patch failed: src/advertising.c:1055
error: src/advertising.c: patch does not apply
hint: Use 'git am --show-current-patch' to see the failed patch


Please resolve the issue and submit the patches again.


---
Regards,
Linux Bluetooth

2022-09-30 00:24:47

by bluez.test.bot

[permalink] [raw]
Subject: RE: properties_changed: check for NULL iterator

This is an automated email and please do not reply to this email.

Dear Submitter,

Thank you for submitting the patches to the linux bluetooth mailing list.
While preparing the CI tests, the patches you submitted couldn't be applied to the current HEAD of the repository.

----- Output -----
error: patch failed: src/advertising.c:1055
error: src/advertising.c: patch does not apply
hint: Use 'git am --show-current-patch' to see the failed patch


Please resolve the issue and submit the patches again.


---
Regards,
Linux Bluetooth