linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] avoid garbled names and segmentation faults in "hcitool scan" command
@ 2021-10-20 12:11 Bisseling
  0 siblings, 0 replies; only message in thread
From: Bisseling @ 2021-10-20 12:11 UTC (permalink / raw)
  To: linux-bluetooth

[-- Attachment #1: Type: text/plain, Size: 669 bytes --]

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';

[-- Attachment #2: 0001-Use-correct-index-variable-when-patching-characters-.patch --]
[-- Type: text/x-patch, Size: 779 bytes --]

From 9843309ca33dc33d9c9ae989cc9dee19cb5ad219 Mon Sep 17 00:00:00 2001
From: Georg Bisseling <spam@bisseling.de>
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


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2021-10-20 12:11 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-10-20 12:11 [PATCH] avoid garbled names and segmentation faults in "hcitool scan" command Bisseling

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).