From owner-svn-src-head@freebsd.org Thu Jan 31 23:46:21 2019 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 9BDA614BC3B8; Thu, 31 Jan 2019 23:46:21 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from kib.kiev.ua (kib.kiev.ua [IPv6:2001:470:d5e7:1::1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 10F7B81BFA; Thu, 31 Jan 2019 23:46:20 +0000 (UTC) (envelope-from kostikbel@gmail.com) Received: from tom.home (kib@localhost [127.0.0.1]) by kib.kiev.ua (8.15.2/8.15.2) with ESMTPS id x0VNk9ZD082817 (version=TLSv1.2 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=NO); Fri, 1 Feb 2019 01:46:12 +0200 (EET) (envelope-from kostikbel@gmail.com) DKIM-Filter: OpenDKIM Filter v2.10.3 kib.kiev.ua x0VNk9ZD082817 Received: (from kostik@localhost) by tom.home (8.15.2/8.15.2/Submit) id x0VNk93h082816; Fri, 1 Feb 2019 01:46:09 +0200 (EET) (envelope-from kostikbel@gmail.com) X-Authentication-Warning: tom.home: kostik set sender to kostikbel@gmail.com using -f Date: Fri, 1 Feb 2019 01:46:09 +0200 From: Konstantin Belousov To: Marcelo Araujo Cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r343634 - head/usr.sbin/bhyve Message-ID: <20190131234609.GZ24863@kib.kiev.ua> References: <201901312332.x0VNWJ6o016057@repo.freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <201901312332.x0VNWJ6o016057@repo.freebsd.org> User-Agent: Mutt/1.11.2 (2019-01-07) X-Spam-Status: No, score=-1.0 required=5.0 tests=ALL_TRUSTED,BAYES_00, DKIM_ADSP_CUSTOM_MED,FORGED_GMAIL_RCVD,FREEMAIL_FROM, NML_ADSP_CUSTOM_MED autolearn=no autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on tom.home X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 31 Jan 2019 23:46:21 -0000 On Thu, Jan 31, 2019 at 11:32:19PM +0000, Marcelo Araujo wrote: > 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. This is not cosmetic, and more, for instance the usage() part of the change does not make any sense to me. > > 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; >