From 1eb12130778f86e3c7d8049676190af50158743d Mon Sep 17 00:00:00 2001 From: araujo Date: Fri, 1 Feb 2019 03:09:11 +0000 Subject: [PATCH] Revert r343634: Mostly a cosmetic change to replace strlen with strnlen. Requested by: kib and imp --- usr.sbin/bhyve/bhyverun.c | 4 ++-- usr.sbin/bhyve/smbiostbl.c | 4 ++-- usr.sbin/bhyve/usb_mouse.c | 3 +-- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/usr.sbin/bhyve/bhyverun.c b/usr.sbin/bhyve/bhyverun.c index dc6e47a22f8d..7be2b0287b8d 100644 --- a/usr.sbin/bhyve/bhyverun.c +++ b/usr.sbin/bhyve/bhyverun.c @@ -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)strnlen(progname, PATH_MAX), "", (int)strnlen(progname, PATH_MAX), "", - (int)strnlen(progname, PATH_MAX), ""); + progname, (int)strlen(progname), "", (int)strlen(progname), "", + (int)strlen(progname), ""); exit(code); } diff --git a/usr.sbin/bhyve/smbiostbl.c b/usr.sbin/bhyve/smbiostbl.c index 27f960423755..f9ee3adace24 100644 --- a/usr.sbin/bhyve/smbiostbl.c +++ b/usr.sbin/bhyve/smbiostbl.c @@ -558,7 +558,7 @@ smbios_generic_initializer(struct smbios_structure *template_entry, int len; string = template_strings[i]; - len = strnlen(string, SMBIOS_MAX_LENGTH) + 1; + len = strlen(string) + 1; memcpy(curaddr, string, len); curaddr += len; } @@ -611,7 +611,7 @@ smbios_type1_initializer(struct smbios_structure *template_entry, return (-1); MD5Init(&mdctx); - MD5Update(&mdctx, vmname, strnlen(vmname, PATH_MAX)); + MD5Update(&mdctx, vmname, strlen(vmname)); MD5Update(&mdctx, hostname, sizeof(hostname)); MD5Final(digest, &mdctx); diff --git a/usr.sbin/bhyve/usb_mouse.c b/usr.sbin/bhyve/usb_mouse.c index a81c9f8314f0..e61301207192 100644 --- a/usr.sbin/bhyve/usb_mouse.c +++ b/usr.sbin/bhyve/usb_mouse.c @@ -70,7 +70,6 @@ enum { UMSTR_MAX }; -#define UMOUSE_DESC_MAX_LEN 32 static const char *umouse_desc_strings[] = { "\x04\x09", "BHYVE", @@ -442,7 +441,7 @@ umouse_request(void *scarg, struct usb_data_xfer *xfer) goto done; } - slen = 2 + strnlen(str, UMOUSE_DESC_MAX_LEN) * 2; + slen = 2 + strlen(str) * 2; udata[0] = slen; udata[1] = UDESC_STRING;