From d5bc23a40ab4f4aad939de67ea08795aae3b1fc9 Mon Sep 17 00:00:00 2001 From: hselasky Date: Sun, 19 Apr 2020 14:25:56 +0000 Subject: [PATCH] Fix cut and paste off-by-one error in hccontrol(8). Make sure strncpy() doesn't write beyond its given buffer. PR: 245739 MFC after: 1 week Sponsored by: Mellanox Technologies --- usr.sbin/bluetooth/hccontrol/util.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/usr.sbin/bluetooth/hccontrol/util.c b/usr.sbin/bluetooth/hccontrol/util.c index 354607cff22..93dcbf2fda4 100644 --- a/usr.sbin/bluetooth/hccontrol/util.c +++ b/usr.sbin/bluetooth/hccontrol/util.c @@ -134,6 +134,7 @@ hci_hmode2str(int mode, char *buffer, int size) int n; memset(buffer, 0, size); + size--; for (n = 0; n < SIZE(t); n++) { int len = strlen(buffer); @@ -347,6 +348,7 @@ hci_features2str(uint8_t *features, char *buffer, int size) memset(buffer, 0, size); len1 = 0; + size--; for (n = 0; n < SIZE(t); n++) { for (i = 0; i < SIZE(t[n]); i++) { @@ -460,6 +462,7 @@ hci_le_features2str(uint8_t *features, char *buffer, int size) memset(buffer, 0, size); len1 = 0; + size--; for (n = 0; n < SIZE(t); n++) { for (i = 0; i < SIZE(t[n]); i++) { -- 2.45.2