diff mbox series

[BlueZ] main.conf: Fix parsing of uint32_t values

Message ID 20230911205447.2689657-1-luiz.dentz@gmail.com (mailing list archive)
State Accepted
Commit 53542db3d6c6bc9991e3f9b0ab05e6ea6cee753d
Headers show
Series [BlueZ] main.conf: Fix parsing of uint32_t values | expand

Checks

Context Check Description
tedd_an/pre-ci_am success Success
tedd_an/CheckPatch success CheckPatch PASS
tedd_an/GitLint success Gitlint PASS
tedd_an/BuildEll success Build ELL PASS
tedd_an/BluezMake success Bluez Make PASS
tedd_an/MakeCheck success Bluez Make Check PASS
tedd_an/MakeDistcheck success Make Distcheck PASS
tedd_an/CheckValgrind success Check Valgrind PASS
tedd_an/CheckSmatch success CheckSparse PASS
tedd_an/bluezmakeextell success Make External ELL PASS
tedd_an/IncrementalBuild success Incremental Build PASS
tedd_an/ScanBuild success Scan Build PASS

Commit Message

Luiz Augusto von Dentz Sept. 11, 2023, 8:54 p.m. UTC
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(-)

Comments

bluez.test.bot@gmail.com Sept. 12, 2023, 2 a.m. UTC | #1
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
patchwork-bot+bluetooth@kernel.org Sept. 12, 2023, 6:50 p.m. UTC | #2
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!
diff mbox series

Patch

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)