Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 11 Jul 2019 11:05:12 -0400
From:      Shawn Webb <shawn.webb@hardenedbsd.org>
To:        Enji Cooper <yaneurabeya@gmail.com>
Cc:        Philip Paeps <philip@FreeBSD.org>, svn-src-head@freebsd.org, svn-src-all <svn-src-all@freebsd.org>, src-committers <src-committers@freebsd.org>
Subject:   Re: svn commit: r349896 - head/contrib/telnet/telnet
Message-ID:  <20190711150512.usrjdmg4fcoobshr@mutt-hbsd>
In-Reply-To: <6031EBD8-84D7-46D4-A3E5-D78427D084B1@gmail.com>
References:  <201907102236.x6AMaFLI067550@repo.freebsd.org> <6031EBD8-84D7-46D4-A3E5-D78427D084B1@gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help

--qakgcoku6qo52req
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Thu, Jul 11, 2019 at 01:02:15AM -0700, Enji Cooper wrote:
>=20
> > On Jul 10, 2019, at 3:36 PM, Philip Paeps <philip@FreeBSD.org> wrote:
> >=20
> > Author: philip
> > Date: Wed Jul 10 22:36:14 2019
> > New Revision: 349896
> > URL: https://svnweb.freebsd.org/changeset/base/349896
> >=20
> > Log:
> >  telnet: fix minor style violation
> >=20
> >  While here also fix a very unlikely NULL pointer dereference.
> >=20
> >  Submitted by:	Shawn Webb <shawn.webb@hardenedbsd.org>
> >=20
> > Modified:
> >  head/contrib/telnet/telnet/commands.c
> >=20
> > Modified: head/contrib/telnet/telnet/commands.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/contrib/telnet/telnet/commands.c	Wed Jul 10 22:23:59 2019	(r34=
9895)
> > +++ head/contrib/telnet/telnet/commands.c	Wed Jul 10 22:36:14 2019	(r34=
9896)
> > @@ -45,6 +45,7 @@ __FBSDID("$FreeBSD$");
> > #include <sys/socket.h>
> > #include <netinet/in.h>
> >=20
> > +#include <assert.h>
> > #include <ctype.h>
> > #include <err.h>
> > #include <errno.h>
> > @@ -1654,11 +1655,13 @@ env_init(void)
> > 		|| (strncmp((char *)ep->value, "unix:", 5) =3D=3D 0))) {
> > 		char hbuf[256+1];
> > 		char *cp2 =3D strchr((char *)ep->value, ':');
> > +                size_t buflen;
> >=20
> > 		gethostname(hbuf, sizeof(hbuf));
> > 		hbuf[sizeof(hbuf)-1] =3D '\0';
> > -                unsigned int buflen =3D strlen(hbuf) + strlen(cp2) + 1;
> > + 		buflen =3D strlen(hbuf) + strlen(cp2) + 1;
> > 		cp =3D (char *)malloc(sizeof(char)*buflen);
> > +		assert(cp !=3D NULL);
>=20
> This will unfortunately still segfault if assert is compiled out of the s=
ystem as a no-op (-DNDEBUG).
>=20
> I genuinely think using asprintf instead is the way to go, as Eitan and W=
arner brought up, since it reduces complexity in the program.

https://gist.github.com/d49121a3e9a14b93868360edf32673f1

Thanks,

--=20
Shawn Webb
Cofounder / Security Engineer
HardenedBSD

Tor-ified Signal:    +1 443-546-8752
Tor+XMPP+OTR:        lattera@is.a.hacker.sx
GPG Key ID:          0xFF2E67A277F8E1FA
GPG Key Fingerprint: D206 BB45 15E0 9C49 0CF9  3633 C85B 0AF8 AB23 0FB2

--qakgcoku6qo52req
Content-Type: application/pgp-signature; name="signature.asc"

-----BEGIN PGP SIGNATURE-----

iQIzBAEBCAAdFiEEA6TL67gupaZ9nzhT/y5nonf44foFAl0nUCIACgkQ/y5nonf4
4fpJ7w/+NrzKkVZS9+LTrSIKC2EfdLI9eRmxMgejmz4zEkOH89CZszNeL8dGHrjV
yd6STzisox8agg/EH/cYVVFSfHRmxS9mwZUzVOh3/kkcLj4cZ5KYnNWVJXrim7Zk
vMAmrxway/X/XftwnVNFrFUAdSagfO9z7N6o+wy4npiAlam8llpNPF57REZs+Ymm
xvp/LC0qJa5tOdQFUTe7MtUDlZcYGAaxb6w2tU2h8t86fI33jvLCe/NVrnKja2In
d0Ej7x/bD07i9hBRB9iOLL8EHuH3RosLItSXwijaK0tChs2V9cxVc+G5mGBKf8OB
9XDqgugxh3dDek3UBjjua/7ZTk8GTz9W/Duc4G1Irp8oTbxYmHL0kJUZJS8P+DVZ
pwB0vgebpiU13BLFVQv5G6LiychvpPV/acgnO1pkuQBlHSibyEP7vDS1icUKRAbN
CldN8Svi/PnLQf+tPoOqOVSgwpeQRdtfBQi4i/cLbtQTSbMOjGBkUq8Tu4xy3707
falDgksqLZw/N5RqhdI3mH9u+7/TjCeqaClY1shFKmgnH1/wbdp6IDc29UZvyhHT
IH2gma0Eiiz/ADr+oy+eoixHp/P4rOddYkd6DUyTJ6OE9l9R0qFNNWXwAExs4giE
lws7yvW1y9XWf0y2jHLBToWKKryv3jHZ+Z6touYOqcbzyGEjkJk=
=MU7h
-----END PGP SIGNATURE-----

--qakgcoku6qo52req--



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