Author: hselasky
Date: Sun Apr 19 14:25:56 2020
New Revision: 360095
URL: https://svnweb.freebsd.org/changeset/base/360095

Log:
  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

Modified:
  head/usr.sbin/bluetooth/hccontrol/util.c

Modified: head/usr.sbin/bluetooth/hccontrol/util.c
==============================================================================
--- head/usr.sbin/bluetooth/hccontrol/util.c    Sun Apr 19 14:22:21 2020        
(r360094)
+++ head/usr.sbin/bluetooth/hccontrol/util.c    Sun Apr 19 14:25:56 2020        
(r360095)
@@ -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 
 
                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, i
 
                memset(buffer, 0, size);
                len1 = 0;
+               size--;
 
                for (n = 0; n < SIZE(t); n++) {
                        for (i = 0; i < SIZE(t[n]); i++) {
_______________________________________________
svn-src-all@freebsd.org mailing list
https://lists.freebsd.org/mailman/listinfo/svn-src-all
To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"

Reply via email to