[PATCH] avoid garbled names and segmentation faults in "hcitool scan" command

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

 



diff --git a/tools/hcitool.c b/tools/hcitool.c
index b6f4a4e66..11e2f7841 100644
--- a/tools/hcitool.c
+++ b/tools/hcitool.c
@@ -673,8 +673,8 @@ static void cmd_scan(int dev_id, int argc, char **argv)
                                strcpy(name, "n/a");

                        for (n = 0; n < 248 && name[n]; n++) {
-                               if ((unsigned char) name[i] < 32 ||
name[i] == 127)
-                                       name[i] = '.';
+                               if ((unsigned char) name[n] < 32 ||
name[n] == 127)
+                                       name[n] = '.';
                        }

                        name[248] = '\0';
>From 9843309ca33dc33d9c9ae989cc9dee19cb5ad219 Mon Sep 17 00:00:00 2001
From: Georg Bisseling <spam@xxxxxxxxxxxx>
Date: Tue, 22 Sep 2020 16:06:02 +0200
Subject: [PATCH] Use correct index variable when patching characters in name

---
 tools/hcitool.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/tools/hcitool.c b/tools/hcitool.c
index b6f4a4e66..11e2f7841 100644
--- a/tools/hcitool.c
+++ b/tools/hcitool.c
@@ -673,8 +673,8 @@ static void cmd_scan(int dev_id, int argc, char **argv)
 				strcpy(name, "n/a");
 
 			for (n = 0; n < 248 && name[n]; n++) {
-				if ((unsigned char) name[i] < 32 || name[i] == 127)
-					name[i] = '.';
+				if ((unsigned char) name[n] < 32 || name[n] == 127)
+					name[n] = '.';
 			}
 
 			name[248] = '\0';
-- 
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