From owner-svn-src-head@freebsd.org Fri May 25 19:35:34 2018 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 E0A28EF1FED for ; Fri, 25 May 2018 19:35:33 +0000 (UTC) (envelope-from shawn.webb@hardenedbsd.org) Received: from mail-wm0-x22b.google.com (mail-wm0-x22b.google.com [IPv6:2a00:1450:400c:c09::22b]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "Google Internet Authority G2" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 2B25270800 for ; Fri, 25 May 2018 19:35:33 +0000 (UTC) (envelope-from shawn.webb@hardenedbsd.org) Received: by mail-wm0-x22b.google.com with SMTP id j4-v6so17102373wme.1 for ; Fri, 25 May 2018 12:35:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=hardenedbsd-org.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=PuSxm9Fch/IuRG8NCV5EKJYow+f00tWALotpMhozFn4=; b=hQm4bEMeqSnU6HNtRo02genOgOmHFtGkj+Cjw7vEyIM5Tv4q33trLGezZ/TCvlllC4 S5kaZrEJTQk/D+gfipt3T2J+ooj/8elTIw6WZasbecAkURMUDda2PQCNwhzJepOuENzm xqxx3I9qZhAdE+xutz6SwM3mqyQpfxX9FPzXIKn/HLSOuY44L9OqZ48FWcYmo+gMyHhV xdlf9gMYWc0V+l9rxzX2bnB63J5P/6fVC49M0nL3HXBu1wy7Tqm5wjdo+mDKrokgkQZ8 nxnar4z+Bjq1rgb/wnL7/oEE2YwT9kIOLQJFtHQ57csHQVX042EeL3AjNWnV2C6N9ou1 +W/w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to:user-agent; bh=PuSxm9Fch/IuRG8NCV5EKJYow+f00tWALotpMhozFn4=; b=Y1h8mdR84grfKJnSNkB7fsxXntBc10UHbnMvJKzJYnBXdfSw96FOYBRQ3NPUM8SP/K 8yDKluOg5V9Jw3WRSQxoChdz5fxvgiWwIEeSlBqseM8w05mqhPFDRy2JBdH56h19964Y 6jJZph7gNs588JXjo6MpQcEcIRHmL956VBkmNR7lgT5r53tDYf30/4Afa3GxvxGxaKo7 S9Ce0fEFXjexB6RYgRoShXXeqzOjksH8RruJtp/8eNnAyrwHeATVAqM6M6uNNue7c7tt /EroG6HhZxXrT/xUEVqWsO/R58EHrwZ00gCIgAmlUS9PYw+xN1wt2xuaJBGaQCG0w5Cg pLXw== X-Gm-Message-State: ALKqPweinLo/nW45x3NXXTYsZ/1VwULvXN5ZNlM+MIl+Bt30qUXn3Zu4 wFSd74szgvz7UCy6TpVw/jJ8pQ== X-Google-Smtp-Source: ADUXVKL/Dlo3xGSVJBfirIa12kZ5BYCepMjaxVIg3LGwvdPTH+azGlWe56GHQhUYakTOdLN4FIaM0g== X-Received: by 2002:a1c:ec82:: with SMTP id h2-v6mr2522206wmi.137.1527276931974; Fri, 25 May 2018 12:35:31 -0700 (PDT) Received: from mutt-hbsd ([91.203.145.9]) by smtp.gmail.com with ESMTPSA id n23-v6sm6564545wmc.23.2018.05.25.12.35.28 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Fri, 25 May 2018 12:35:30 -0700 (PDT) Date: Fri, 25 May 2018 15:35:14 -0400 From: Shawn Webb To: Konstantin Belousov Cc: Marcelo Araujo , svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org Subject: Re: svn commit: r334216 - head/usr.sbin/bhyve Message-ID: <20180525193514.jsh2l674xlhq6b7d@mutt-hbsd> References: <201805251854.w4PIseSi073002@repo.freebsd.org> <20180525190846.GL88128@kib.kiev.ua> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="ttoaj4wfu3jzojbt" Content-Disposition: inline In-Reply-To: <20180525190846.GL88128@kib.kiev.ua> X-Operating-System: FreeBSD mutt-hbsd 12.0-CURRENT FreeBSD 12.0-CURRENT X-PGP-Key: http://pgp.mit.edu/pks/lookup?op=vindex&search=0x6A84658F52456EEE User-Agent: NeoMutt/20180323 X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.26 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: Fri, 25 May 2018 19:35:34 -0000 --ttoaj4wfu3jzojbt Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Fri, May 25, 2018 at 10:08:46PM +0300, Konstantin Belousov wrote: > On Fri, May 25, 2018 at 06:54:40PM +0000, Marcelo Araujo wrote: > > Author: araujo > > Date: Fri May 25 18:54:40 2018 > > New Revision: 334216 > > URL: https://svnweb.freebsd.org/changeset/base/334216 > >=20 > > Log: > > After a long discussion about assert(3), we gonna use a HardenedBSD > > approach to chek strdup(3) memory allocation. > > =20 > > Submitted by: Shaw Webb > > Reported by: brooks > > Obtained from: HardenedBSD > >=20 > > Modified: > > head/usr.sbin/bhyve/bhyverun.c > >=20 > > Modified: head/usr.sbin/bhyve/bhyverun.c > > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D > > --- head/usr.sbin/bhyve/bhyverun.c Fri May 25 18:11:13 2018 (r334215) > > +++ head/usr.sbin/bhyve/bhyverun.c Fri May 25 18:54:40 2018 (r334216) > > @@ -193,7 +193,8 @@ topology_parse(const char *opt) > > c =3D 1, n =3D 1, s =3D 1, t =3D 1; > > ns =3D false, scts =3D false; > > str =3D strdup(opt); > > - assert(str !=3D NULL); > > + if (str =3D=3D NULL) > > + goto out; > > =20 > > while ((cp =3D strsep(&str, ",")) !=3D NULL) { > > if (sscanf(cp, "%i%n", &tmp, &chk) =3D=3D 1) { > > @@ -225,6 +226,7 @@ topology_parse(const char *opt) > > goto out; > > } > > free(str); > > + str =3D NULL; > > =20 > > /* > > * Range check 1 <=3D n <=3D UINT16_MAX all values > > @@ -253,7 +255,8 @@ topology_parse(const char *opt) > > return(0); > > =20 > > out: > > - free(str); > > + if (str !=3D NULL) > This check is useless. Free(3) is fine handling NULL argument. Good catch. Thanks! --=20 Shawn Webb Cofounder and Security Engineer HardenedBSD Tor-ified Signal: +1 443-546-8752 Tor+XMPP+OTR: lattera@is.a.hacker.sx GPG Key ID: 0x6A84658F52456EEE GPG Key Fingerprint: 2ABA B6BD EF6A F486 BE89 3D9E 6A84 658F 5245 6EEE --ttoaj4wfu3jzojbt Content-Type: application/pgp-signature; name="signature.asc" -----BEGIN PGP SIGNATURE----- iQIzBAEBCAAdFiEEKrq2ve9q9Ia+iT2eaoRlj1JFbu4FAlsIZW8ACgkQaoRlj1JF bu61BhAAxyOGMsdmz2oHuymLmI/85evKlt/k2gr0zXOzzaUAxrOhE0skV2UOBtlu Ze6af5cVwka3035C+HWm8Bcuqw9t+EfkWQ4/1qgCMj86b5izOWriqwhB/D9sIISk GMrMZnnDHZOa6A2+5k/fZXGs5zJamLEWawBfWHhFf4IQnoyAQSJ4RlEG56QlwI52 xauGv2Sn+KKnQEDuwfjGYC3DtrkGiMtdH1OkahxYvMamrNjIBaGl3hCi1USDJMLM ZBlPen5FDDN/0seNawzRMIJmcBRvEGiom5C+Z0IxqZ0DYeBev1kDqdB6e69F7rOG 3YKiLJ7se4sutcwy3xyRfzUsU6kULwvIgnnRZtSKylNg+r0qgNkGZanucQcNRaFs ki9C5ZFIfw/NqAmhHpKCu6AhgETX5tl8MtxtCOBQ//tgnvRw/xrhCmXTgZeMVXW6 wdObYqKb4KZr4I0+eDJNQ9yptpWDEw/ryjht8T2z/nE0cchDJkdA69P0+2hXxzV8 mtobbd7RgXJt7hx6Hyn6tFqCAVYgnnOjxXJBnkjSLN11dqy8EuNIxKzwifCKTxKx UwOgg0GgMOn3aLTat3NNAkwdmxx6e1Kfc9HuWwBjowR8Eu5jKtZVYjtRBqaCtQct d+MgFX5IsRxcCZfcY+17P/wPmWi2Qa/rf2biTTX3TS93iMrZ52A= =vRX3 -----END PGP SIGNATURE----- --ttoaj4wfu3jzojbt--