From owner-svn-src-all@freebsd.org Thu Jul 11 15:05:15 2019 Return-Path: Delivered-To: svn-src-all@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 EA59915D5F1C for ; Thu, 11 Jul 2019 15:05:14 +0000 (UTC) (envelope-from shawn.webb@hardenedbsd.org) Received: from mail-vs1-xe41.google.com (mail-vs1-xe41.google.com [IPv6:2607:f8b0:4864:20::e41]) (using TLSv1.3 with cipher TLS_AES_128_GCM_SHA256 (128/128 bits) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (2048 bits) client-digest SHA256) (Client CN "smtp.gmail.com", Issuer "GTS CA 1O1" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 7E61383252 for ; Thu, 11 Jul 2019 15:05:14 +0000 (UTC) (envelope-from shawn.webb@hardenedbsd.org) Received: by mail-vs1-xe41.google.com with SMTP id j26so4389969vsn.10 for ; Thu, 11 Jul 2019 08:05:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=hardenedbsd.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to:user-agent; bh=QDsqdGOsdtsjbY16Uppg0T6oGBbyELyB94B16o7HVUk=; b=UpGtA/U4IzVa1NxBWbsIq+edC1eGFb2i2k2BgmU5ODVp9bPI8GN0Z1g63iiSBkQCGB l1MAcXbtyHStWJIvnw29TVgFdiBA+TsHoPyZJTgmO/pnxj8aQQ27MD+/WA/+SPcHBBzH m6aMIVLGTXGpccix/xOVcemCaUnSqMDB/FLUJCYYS8KO8IK+XXldp9APNW0/CvETnDxo xN51kKrGLtSP6J+WK1xa+9pz/cQ6Sdp1Z4PCWsHLbAZcGCsFDCkxlRoyKsYMScL3e+FV mjfZ5kd5rJPeg7sXGANTToeaOLY9FB3Y5y6zLjkn3SrBgTBehwfuIQB0+NkVUthwHfPE zt1Q== 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=QDsqdGOsdtsjbY16Uppg0T6oGBbyELyB94B16o7HVUk=; b=sc1C8JLZVUGK4ohsQXEafjDJ9srpTFSzA7wBYI3zTSwjBScrJEu0kHstkOvoumi67Y 2oHRBOptX0JJ9Zw3Br1EIQNaVCTiNUrEpMXLqOll+ZBiz0BFqcG78rGAZIvQOXJmo5y2 zzysoB2agZr//fC6ocfWxh3xhAWN1s7noFXx3xTKK1lJ34Pegd9ca+IhBjZ4/1ZUouWw DbPYzrTM1s1lQlvqc6pxZxUvKKFaQLb5W1xZlfcuGAVIzcU2nomk4zdUv1RXAt/i1F39 FMB7bABIU2ALsP9Ox3Mki/1U5lYJqr4Jvte4CBLdAwhoQR/nIbXd0KsKIt7OwzKRt2os y0PQ== X-Gm-Message-State: APjAAAXFvzxogLeG/VBErtOrn2u/4C8LOduxsCeKvUzF8IC+LWdyE6ag 4J8y4AXdVY8vTC3w2qgJOnmNMw== X-Google-Smtp-Source: APXvYqxcFgHfCfAskJoeb651WV2fqJ2nV0DXcTNLOpHCSLNnDskxQ3v3quUjoFcuyIl2cd8JRgFk5w== X-Received: by 2002:a67:d410:: with SMTP id c16mr5197251vsj.61.1562857513852; Thu, 11 Jul 2019 08:05:13 -0700 (PDT) Received: from mutt-hbsd ([63.88.83.108]) by smtp.gmail.com with ESMTPSA id d134sm1409319vsc.26.2019.07.11.08.05.12 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Thu, 11 Jul 2019 08:05:13 -0700 (PDT) Date: Thu, 11 Jul 2019 11:05:12 -0400 From: Shawn Webb To: Enji Cooper Cc: Philip Paeps , svn-src-head@freebsd.org, svn-src-all , src-committers Subject: Re: svn commit: r349896 - head/contrib/telnet/telnet Message-ID: <20190711150512.usrjdmg4fcoobshr@mutt-hbsd> References: <201907102236.x6AMaFLI067550@repo.freebsd.org> <6031EBD8-84D7-46D4-A3E5-D78427D084B1@gmail.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="qakgcoku6qo52req" Content-Disposition: inline In-Reply-To: <6031EBD8-84D7-46D4-A3E5-D78427D084B1@gmail.com> X-Operating-System: FreeBSD mutt-hbsd 13.0-CURRENT-HBSD FreeBSD 13.0-CURRENT-HBSD X-PGP-Key: http://pgp.mit.edu/pks/lookup?op=vindex&search=0xFF2E67A277F8E1FA User-Agent: NeoMutt/20180716 X-Rspamd-Queue-Id: 7E61383252 X-Spamd-Bar: ------ Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-6.99 / 15.00]; NEURAL_HAM_MEDIUM(-1.00)[-1.000,0]; NEURAL_HAM_SHORT(-0.99)[-0.986,0]; REPLY(-4.00)[]; NEURAL_HAM_LONG(-1.00)[-1.000,0] X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 11 Jul 2019 15:05:15 -0000 --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 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 > >=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 > > #include > >=20 > > +#include > > #include > > #include > > #include > > @@ -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--