Date: Fri, 25 May 2018 15:35:14 -0400 From: Shawn Webb <shawn.webb@hardenedbsd.org> To: Konstantin Belousov <kostikbel@gmail.com> Cc: Marcelo Araujo <araujo@FreeBSD.org>, 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> In-Reply-To: <20180525190846.GL88128@kib.kiev.ua> References: <201805251854.w4PIseSi073002@repo.freebsd.org> <20180525190846.GL88128@kib.kiev.ua>
next in thread | previous in thread | raw e-mail | index | archive | help
--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 <shawn.webb@hardenedbsd.org> > > 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--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20180525193514.jsh2l674xlhq6b7d>