[PATCH BlueZ 1/1] tools/hciconfig: Check device name (hci0 etc.)

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

 



Check device name length given to argv.
If the length of device name is shorter than 4,
that's an error.
---
 tools/hciconfig.c | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/tools/hciconfig.c b/tools/hciconfig.c
index ddc17c4b5..aad37dd56 100644
--- a/tools/hciconfig.c
+++ b/tools/hciconfig.c
@@ -2027,7 +2027,13 @@ int main(int argc, char *argv[])
         exit(0);
     }

-    di.dev_id = atoi(argv[0] + 3);
+    if (strlen(argv[0]) > 3) {
+        di.dev_id = atoi(argv[0] + 3);
+    } else {
+        fprintf(stderr, "Invalid device name: %s\n", argv[0]);
+        exit(1);
+    }
+
     argc--; argv++;

     if (ioctl(ctl, HCIGETDEVINFO, (void *) &di)) {
-- 
2.17.1



[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