diff mbox series

[BlueZ,v2,3/5] tools/isotest: limit the maximum possible data_size

Message ID 20240705075709.26809-4-r.smirnov@omp.ru (mailing list archive)
State Accepted
Commit c389209ce4554fd8fdd3ca99ea6f73435a056c57
Headers show
Series fix error found by SVACE static analyzer #2 | 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/IncrementalBuild success Incremental Build PASS

Commit Message

Roman Smirnov July 5, 2024, 7:57 a.m. UTC
It is necessary to prevent the possibility of allocating
a large amount of memory.

Found with the SVACE static analysis tool.
---
 tools/isotest.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/tools/isotest.c b/tools/isotest.c
index c1bb6abd2..2cac0e49c 100644
--- a/tools/isotest.c
+++ b/tools/isotest.c
@@ -51,6 +51,8 @@ 
 #define DEFAULT_BIG_ID 0x01
 #define DEFAULT_BIS_ID 0x01
 
+#define MAX_DATA_SIZE 0x40000000
+
 /* Test modes */
 enum {
 	SEND,
@@ -1253,7 +1255,7 @@  int main(int argc, char *argv[])
 			break;
 
 		case 'b':
-			if (optarg)
+			if (optarg && atoi(optarg) < MAX_DATA_SIZE)
 				data_size = atoi(optarg);
 			break;