[PATCH BlueZ v2 2/5] shared/shell: prevent integer overflow in bt_shell_init()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



An integer overflow will occur if index < offest. It is necessary
to prevent this case.

Found with the SVACE static analysis tool.
---
 V1 -> V2: added check index >= 0, casting index to size_t
 src/shared/shell.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/shared/shell.c b/src/shared/shell.c
index add4fa131..48de8ab1b 100644
--- a/src/shared/shell.c
+++ b/src/shared/shell.c
@@ -1333,7 +1333,7 @@ void bt_shell_init(int argc, char **argv, const struct bt_shell_opt *opt)
 				}
 			}
 
-			if (opt) {
+			if (opt && index >= 0 && (size_t)index >= offset) {
 				if (c != opt->options[index - offset].val) {
 					usage(argc, argv, opt);
 					exit(EXIT_SUCCESS);
-- 
2.43.0





[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux