Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 31 Jan 2019 23:32:19 +0000 (UTC)
From:      Marcelo Araujo <araujo@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r343634 - head/usr.sbin/bhyve
Message-ID:  <201901312332.x0VNWJ6o016057@repo.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: araujo
Date: Thu Jan 31 23:32:19 2019
New Revision: 343634
URL: https://svnweb.freebsd.org/changeset/base/343634

Log:
  Mostly a cosmetic change to replace strlen with strnlen.
  
  Obtained from:	Project ACRN
  MFC after:	2 weeks

Modified:
  head/usr.sbin/bhyve/bhyverun.c
  head/usr.sbin/bhyve/smbiostbl.c
  head/usr.sbin/bhyve/usb_mouse.c

Modified: head/usr.sbin/bhyve/bhyverun.c
==============================================================================
--- head/usr.sbin/bhyve/bhyverun.c	Thu Jan 31 23:21:18 2019	(r343633)
+++ head/usr.sbin/bhyve/bhyverun.c	Thu Jan 31 23:32:19 2019	(r343634)
@@ -233,8 +233,8 @@ usage(int code)
 		"       -W: force virtio to use single-vector MSI\n"
 		"       -x: local apic is in x2APIC mode\n"
 		"       -Y: disable MPtable generation\n",
-		progname, (int)strlen(progname), "", (int)strlen(progname), "",
-		(int)strlen(progname), "");
+		progname, (int)strnlen(progname, PATH_MAX), "", (int)strnlen(progname, PATH_MAX), "",
+		(int)strnlen(progname, PATH_MAX), "");
 
 	exit(code);
 }

Modified: head/usr.sbin/bhyve/smbiostbl.c
==============================================================================
--- head/usr.sbin/bhyve/smbiostbl.c	Thu Jan 31 23:21:18 2019	(r343633)
+++ head/usr.sbin/bhyve/smbiostbl.c	Thu Jan 31 23:32:19 2019	(r343634)
@@ -558,7 +558,7 @@ smbios_generic_initializer(struct smbios_structure *te
 			int len;
 
 			string = template_strings[i];
-			len = strlen(string) + 1;
+			len = strnlen(string, SMBIOS_MAX_LENGTH) + 1;
 			memcpy(curaddr, string, len);
 			curaddr += len;
 		}
@@ -611,7 +611,7 @@ smbios_type1_initializer(struct smbios_structure *temp
 			return (-1);
 
 		MD5Init(&mdctx);
-		MD5Update(&mdctx, vmname, strlen(vmname));
+		MD5Update(&mdctx, vmname, strnlen(vmname, PATH_MAX));
 		MD5Update(&mdctx, hostname, sizeof(hostname));
 		MD5Final(digest, &mdctx);
 

Modified: head/usr.sbin/bhyve/usb_mouse.c
==============================================================================
--- head/usr.sbin/bhyve/usb_mouse.c	Thu Jan 31 23:21:18 2019	(r343633)
+++ head/usr.sbin/bhyve/usb_mouse.c	Thu Jan 31 23:32:19 2019	(r343634)
@@ -70,6 +70,7 @@ enum {
 	UMSTR_MAX
 };
 
+#define UMOUSE_DESC_MAX_LEN	32
 static const char *umouse_desc_strings[] = {
 	"\x04\x09",
 	"BHYVE",
@@ -441,7 +442,7 @@ umouse_request(void *scarg, struct usb_data_xfer *xfer
 				goto done;
 			}
 
-			slen = 2 + strlen(str) * 2;
+			slen = 2 + strnlen(str, UMOUSE_DESC_MAX_LEN) * 2;
 			udata[0] = slen;
 			udata[1] = UDESC_STRING;
 



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201901312332.x0VNWJ6o016057>