linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH BlueZ] main.conf: Fix parsing of uint32_t values
@ 2023-09-11 20:54 Luiz Augusto von Dentz
  2023-09-12  2:00 ` [BlueZ] " bluez.test.bot
  2023-09-12 18:50 ` [PATCH BlueZ] " patchwork-bot+bluetooth
  0 siblings, 2 replies; 3+ messages in thread
From: Luiz Augusto von Dentz @ 2023-09-11 20:54 UTC (permalink / raw)
  To: linux-bluetooth

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

Passing UINT32_MAX as int may overfollow causing errors such as:

bluetoothd[2688495]: src/main.c:parse_config_int()
General.TemporaryTimeout = 60 is out of range (> -1)

Fixes: https://github.com/bluez/bluez/issues/583#issuecomment-1713447461
---
 src/main.c | 12 +++++++-----
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/src/main.c b/src/main.c
index b5a6f8e5562f..cddf1396197b 100644
--- a/src/main.c
+++ b/src/main.c
@@ -440,9 +440,9 @@ static bool parse_config_string(GKeyFile *config, const char *group,
 
 static bool parse_config_int(GKeyFile *config, const char *group,
 					const char *key, int *val,
-					int min, int max)
+					size_t min, size_t max)
 {
-	int tmp;
+	size_t tmp;
 	char *str = NULL;
 	char *endptr = NULL;
 
@@ -456,12 +456,14 @@ static bool parse_config_int(GKeyFile *config, const char *group,
 	}
 
 	if (tmp < min) {
-		warn("%s.%s = %d is out of range (< %d)", group, key, tmp, min);
+		warn("%s.%s = %zu is out of range (< %zu)", group, key, tmp,
+									min);
 		return false;
 	}
 
 	if (tmp > max) {
-		warn("%s.%s = %d is out of range (> %d)", group, key, tmp, max);
+		warn("%s.%s = %zu is out of range (> %zu)", group, key, tmp,
+									max);
 		return false;
 	}
 
@@ -774,7 +776,7 @@ static bool parse_config_u32(GKeyFile *config, const char *group,
 {
 	int tmp;
 
-	if (!parse_config_int(config, group, key, &tmp, 0, UINT32_MAX))
+	if (!parse_config_int(config, group, key, &tmp, min, max))
 		return false;
 
 	if (val)
-- 
2.41.0


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

* RE: [BlueZ] main.conf: Fix parsing of uint32_t values
  2023-09-11 20:54 [PATCH BlueZ] main.conf: Fix parsing of uint32_t values Luiz Augusto von Dentz
@ 2023-09-12  2:00 ` bluez.test.bot
  2023-09-12 18:50 ` [PATCH BlueZ] " patchwork-bot+bluetooth
  1 sibling, 0 replies; 3+ messages in thread
From: bluez.test.bot @ 2023-09-12  2:00 UTC (permalink / raw)
  To: linux-bluetooth, luiz.dentz

[-- Attachment #1: Type: text/plain, Size: 947 bytes --]

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=783189

---Test result---

Test Summary:
CheckPatch                    PASS      0.37 seconds
GitLint                       PASS      0.23 seconds
BuildEll                      PASS      30.30 seconds
BluezMake                     PASS      990.49 seconds
MakeCheck                     PASS      12.41 seconds
MakeDistcheck                 PASS      166.24 seconds
CheckValgrind                 PASS      267.46 seconds
CheckSmatch                   PASS      374.40 seconds
bluezmakeextell               PASS      111.83 seconds
IncrementalBuild              PASS      871.01 seconds
ScanBuild                     PASS      1167.57 seconds



---
Regards,
Linux Bluetooth


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

* Re: [PATCH BlueZ] main.conf: Fix parsing of uint32_t values
  2023-09-11 20:54 [PATCH BlueZ] main.conf: Fix parsing of uint32_t values Luiz Augusto von Dentz
  2023-09-12  2:00 ` [BlueZ] " bluez.test.bot
@ 2023-09-12 18:50 ` patchwork-bot+bluetooth
  1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+bluetooth @ 2023-09-12 18:50 UTC (permalink / raw)
  To: Luiz Augusto von Dentz; +Cc: linux-bluetooth

Hello:

This patch was applied to bluetooth/bluez.git (master)
by Luiz Augusto von Dentz <luiz.von.dentz@intel.com>:

On Mon, 11 Sep 2023 13:54:47 -0700 you wrote:
> From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>
> 
> Passing UINT32_MAX as int may overfollow causing errors such as:
> 
> bluetoothd[2688495]: src/main.c:parse_config_int()
> General.TemporaryTimeout = 60 is out of range (> -1)
> 
> [...]

Here is the summary with links:
  - [BlueZ] main.conf: Fix parsing of uint32_t values
    https://git.kernel.org/pub/scm/bluetooth/bluez.git/?id=53542db3d6c6

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



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

end of thread, other threads:[~2023-09-12 18:50 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-09-11 20:54 [PATCH BlueZ] main.conf: Fix parsing of uint32_t values Luiz Augusto von Dentz
2023-09-12  2:00 ` [BlueZ] " bluez.test.bot
2023-09-12 18:50 ` [PATCH BlueZ] " patchwork-bot+bluetooth

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