From owner-freebsd-questions Tue Feb 20 11:47:54 2001 Delivered-To: freebsd-questions@freebsd.org Received: from obsecurity.dyndns.org (adsl-64-165-226-53.dsl.lsan03.pacbell.net [64.165.226.53]) by hub.freebsd.org (Postfix) with ESMTP id 86E9337B491 for ; Tue, 20 Feb 2001 11:47:51 -0800 (PST) (envelope-from kris@obsecurity.org) Received: by obsecurity.dyndns.org (Postfix, from userid 1000) id 38E7266F2E; Tue, 20 Feb 2001 11:47:51 -0800 (PST) Date: Tue, 20 Feb 2001 11:47:51 -0800 From: Kris Kennaway To: Arthur Boynagryan Cc: freebsd-questions@freebsd.org Subject: Re: Alternative to gets() function? Message-ID: <20010220114751.A35631@mollari.cthul.hu> References: <000401c09a62$1f1caf60$4a07a8c0@user0000011909> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-md5; protocol="application/pgp-signature"; boundary="gBBFr7Ir9EOA20Yy" Content-Disposition: inline User-Agent: Mutt/1.2.5i In-Reply-To: <000401c09a62$1f1caf60$4a07a8c0@user0000011909>; from boynagar@armentel.com on Mon, Feb 19, 2001 at 02:52:57PM +0400 Sender: owner-freebsd-questions@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG --gBBFr7Ir9EOA20Yy Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Mon, Feb 19, 2001 at 02:52:57PM +0400, Arthur Boynagryan wrote: > Hi all! >=20 > I've been reading man page for gets() and fgets() and noticed=20 > the following: >=20 > "Since it is usually impossible to ensure that the next input line is less > than some arbitrary length, and because overflowing the input buffer is > almost invariably a security violation, programs should NEVER use gets()." >=20 > What can you recommend instead of gets()? Does this also apply to=20 > fgets()? I'm mostly interested in fgets(). fgets() takes a length parameter so it knows how long the buffer is and will not overflow it. Use fgets(). Kris --gBBFr7Ir9EOA20Yy Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.0.4 (FreeBSD) Comment: For info see http://www.gnupg.org iD8DBQE6ksnmWry0BWjoQKURAmKOAKCZgvt+luH8BG6uOuVrYw6wUDqSVQCg8dqn SR/yFHeyuMmp+GhYDwpPBRw= =P0vX -----END PGP SIGNATURE----- --gBBFr7Ir9EOA20Yy-- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message