From owner-cvs-all Mon Mar 18 7:46:12 2002 Delivered-To: cvs-all@freebsd.org Received: from straylight.ringlet.net (discworld.nanolink.com [217.75.135.248]) by hub.freebsd.org (Postfix) with SMTP id 2CC6437B432 for ; Mon, 18 Mar 2002 07:45:09 -0800 (PST) Received: (qmail 32397 invoked by uid 1000); 18 Mar 2002 15:41:46 -0000 Date: Mon, 18 Mar 2002 17:41:45 +0200 From: Peter Pentchev To: Mikhail Teterin Cc: imp@FreeBSD.org, cvs-committers@FreeBSD.org, cvs-all@FreeBSD.org Subject: Re: cvs commit: src/libexec/xtend user.c xtend.c Message-ID: <20020318174145.A10603@straylight.oblivion.bg> Mail-Followup-To: Mikhail Teterin , imp@FreeBSD.org, cvs-committers@FreeBSD.org, cvs-all@FreeBSD.org References: <20020318141639.B1326@straylight.oblivion.bg> <200203181534.g2IFYN3b020895@aldan.algebra.com> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-md5; protocol="application/pgp-signature"; boundary="XsQoSWH+UP9D9v3l" Content-Disposition: inline User-Agent: Mutt/1.2.5.1i In-Reply-To: <200203181534.g2IFYN3b020895@aldan.algebra.com>; from mi@aldan.algebra.com on Mon, Mar 18, 2002 at 10:34:23AM -0500 Sender: owner-cvs-all@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG --XsQoSWH+UP9D9v3l Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Mon, Mar 18, 2002 at 10:34:23AM -0500, Mikhail Teterin wrote: > On 18 Mar, Peter Pentchev wrote: > > On Sun, Mar 17, 2002 at 11:14:59PM -0800, Warner Losh wrote: > >> imp 2002/03/17 23:14:59 PST > >>=20 > >> Modified files: > >> libexec/xtend user.c xtend.c=20 > >> Log: > >> o MAXPATHLEN is the correct constant to use for path names, it inclu= des > >> the NULL. > >> o use snprintf in preference to unchecked strcat in a couple of plac= es that > >> likely can't overflow. Makes it easier to grep for strcpy :-) > >=20 > > /me sprinkles some magic comma dust over the naughty-naughty imp :) > > [IOW, please try the attached patch :] >=20 > Since the X10DIR and X10DUMPNAME are both known at compile time, why not >=20 > - snprintf(dumppath, sizeof(dumppath), "%s/%s", X10DIR, X10DUMPNAME); > + strncpy(dumppath, X10DIR "/" X10DUMPNAME, sizeof(dumppath));=20 >=20 > and so on? (The plain strcpy would do just fine here too, IMO :) strncpy() does not null-terminate properly; strcpy() requires attention from the programmer to make sure that long enough buffers have been provided. snprintf() avoids both of these :) And anyway, the decision to use snprintf() over strcpy() was Warner's -- not that I am trying to evade responsiblity, I fully support it; still, I was just fixing the bugs he introduced in the transition :) G'luck, Peter --=20 Peter Pentchev roam@ringlet.net roam@FreeBSD.org PGP key: http://people.FreeBSD.org/~roam/roam.key.asc Key fingerprint FDBA FD79 C26F 3C51 C95E DF9E ED18 B68D 1619 4553 What would this sentence be like if it weren't self-referential? --XsQoSWH+UP9D9v3l Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.6 (FreeBSD) Comment: For info see http://www.gnupg.org iEYEARECAAYFAjyWCrkACgkQ7Ri2jRYZRVPYkgCcCXnsu9I33nj+YAVXrLaieFwv YQkAn3spQWGlcOn6cFCXS2NKaRXksYDB =y25F -----END PGP SIGNATURE----- --XsQoSWH+UP9D9v3l-- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe cvs-all" in the body of the message