Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 6 Jan 2003 10:09:50 +0200
From:      Peter Pentchev <roam@ringlet.net>
To:        Giorgos Keramidas <keramida@freebsd.org>
Cc:        freebsd-audit@freebsd.org
Subject:   Re: hopefully, a fix for an old uncompress(1) bug
Message-ID:  <20030106080949.GA382@straylight.oblivion.bg>
In-Reply-To: <20030106062309.GA37109@gothmog.gr>
References:  <20030106062309.GA37109@gothmog.gr>

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

--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




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