From owner-freebsd-audit Mon Jan 6 0:10:46 2003 Delivered-To: freebsd-audit@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id C8CF837B401 for ; Mon, 6 Jan 2003 00:10:43 -0800 (PST) Received: from straylight.ringlet.net (office.sbnd.net [217.75.140.130]) by mx1.FreeBSD.org (Postfix) with SMTP id 83CA543ED8 for ; Mon, 6 Jan 2003 00:10:36 -0800 (PST) (envelope-from roam@ringlet.net) Received: (qmail 4394 invoked by uid 1000); 6 Jan 2003 08:09:50 -0000 Date: Mon, 6 Jan 2003 10:09:50 +0200 From: Peter Pentchev To: Giorgos Keramidas Cc: freebsd-audit@freebsd.org Subject: Re: hopefully, a fix for an old uncompress(1) bug Message-ID: <20030106080949.GA382@straylight.oblivion.bg> Mail-Followup-To: Giorgos Keramidas , freebsd-audit@freebsd.org References: <20030106062309.GA37109@gothmog.gr> Mime-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="envbJBWh7q8WU6mo" Content-Disposition: inline In-Reply-To: <20030106062309.GA37109@gothmog.gr> User-Agent: Mutt/1.5.3i Sender: owner-freebsd-audit@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG --envbJBWh7q8WU6mo Content-Type: text/plain; charset=windows-1251 Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Mon, Jan 06, 2003 at 08:23:09AM +0200, Giorgos Keramidas wrote: > Gary Swearingen brought the following bug to my attention while > posting a `fix' for the manpage of compress(1) and uncompress(1). > Instead of documenting the bug, I thought we might try to fix it. Good catch - to both Gary and you! Just a minor note inline... > %%% > Index: compress.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 > RCS file: /home/ncvs/src/usr.bin/compress/compress.c,v > retrieving revision 1.20 > diff -u -5 -r1.20 compress.c > --- compress.c 28 Jul 2002 15:32:17 -0000 1.20 > +++ compress.c 6 Jan 2003 06:15:06 -0000 > @@ -298,26 +298,25 @@ [snip] > if ((ifp =3D zopen(in, "r", bits)) =3D=3D NULL) { > cwarn("%s", in); > - goto err; > + return; Is this change really needed? It is true that the code at 'err' would be a no-op at this point, when neither ifp nor ofp has been opened, but it strikes me as a bit more semantically correct to invoke the "real" error-handling procedures at any error, just in case something changes in the future and some error-handling does indeed become necessary. Other than that, the patch seems just fine - and it works :) Attached is the version without the 'goto err' change, for the minor convenience of future reviewers and committers. 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 If this sentence didn't exist, somebody would have invented it. Index: src/usr.bin/compress/compress.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 RCS file: /home/ncvs/src/usr.bin/compress/compress.c,v retrieving revision 1.20 diff -u -r1.20 compress.c --- src/usr.bin/compress/compress.c 28 Jul 2002 15:32:17 -0000 1.20 +++ src/usr.bin/compress/compress.c 6 Jan 2003 08:04:51 -0000 @@ -300,11 +300,6 @@ isreg =3D oreg =3D !exists || S_ISREG(sb.st_mode); =20 ifp =3D ofp =3D NULL; - if ((ofp =3D fopen(out, "w")) =3D=3D NULL) { - cwarn("%s", out); - return; - } - if ((ifp =3D zopen(in, "r", bits)) =3D=3D NULL) { cwarn("%s", in); goto err; @@ -316,6 +311,10 @@ if (!S_ISREG(sb.st_mode)) isreg =3D 0; =20 + if ((ofp =3D fopen(out, "w")) =3D=3D NULL) { + cwarn("%s", out); + goto err; + } while ((nr =3D fread(buf, 1, sizeof(buf), ifp)) !=3D 0) if (fwrite(buf, 1, nr, ofp) !=3D nr) { cwarn("%s", out); --envbJBWh7q8WU6mo Content-Type: application/pgp-signature Content-Disposition: inline -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.1 (FreeBSD) iD8DBQE+GTnN7Ri2jRYZRVMRAnD0AKCZX1XfaZWR4pPdhJKh/hAY7C6hswCffgBz mi9ZmYanRLWwBAe/T1CMfqI= =C3ql -----END PGP SIGNATURE----- --envbJBWh7q8WU6mo-- To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-audit" in the body of the message