Re: hopefully, a fix for an old uncompress(1) bug
Peter Pentchev <[email protected]> Mon, 6 Jan 2003 10:09:50 +0200
| Newsgroups | gmane.os.freebsd.devel.audit |
|---|---|
| Message-ID | <[email protected]> |
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
> ===================================================================
> 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 = zopen(in, "r", bits)) == 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
--
Peter Pentchev [email protected] [email protected]
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
===================================================================
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 = oreg = !exists || S_ISREG(sb.st_mode);
ifp = ofp = NULL;
- if ((ofp = fopen(out, "w")) == NULL) {
- cwarn("%s", out);
- return;
- }
-
if ((ifp = zopen(in, "r", bits)) == NULL) {
cwarn("%s", in);
goto err;
@@ -316,6 +311,10 @@
if (!S_ISREG(sb.st_mode))
isreg = 0;
+ if ((ofp = fopen(out, "w")) == NULL) {
+ cwarn("%s", out);
+ goto err;
+ }
while ((nr = fread(buf, 1, sizeof(buf), ifp)) != 0)
if (fwrite(buf, 1, nr, ofp) != nr) {
cwarn("%s", out);
signature.asc
(application/pgp-signature, 187 B)
-----BEGIN PGP SIGNATURE----- Version: GnuPG v1.2.1 (FreeBSD) iD8DBQE+GTnN7Ri2jRYZRVMRAnD0AKCZX1XfaZWR4pPdhJKh/hAY7C6hswCffgBz mi9ZmYanRLWwBAe/T1CMfqI= =C3ql -----END PGP SIGNATURE-----