Jim,
Below is a patch to the patch.
A test case will be forthcoming (I need to create a case that delicately
crosses a buffer boundary). Once I get a test case working, you can push it.
By the way, I found an even more serious incarnation of the original bug shown
by this test case:
$ echo -n x | gzip124 -cdf | wc -c
0
$ echo -n x | gzip14 -cdf | wc -c
0
It should be the same as cat:
$ echo -n x | cat | wc -c
1
$ echo -n x | ./gzip -cdf | wc -c
1
Test cases to add for completeness are:
$ echo -n | ./gzip -cdf | wc -c
$ echo -n x | ./gzip -cdf | wc -c
$ echo -n xy | ./gzip -cdf | wc -c
$ echo -n xyz | ./gzip -cdf | wc -c
Those should return 0, 1, 2, and 3 respectively.
Mark
--- gzip-1.4p1.c 2010-02-02 23:11:45.000000000 -0800
+++ gzip.c 2010-02-03 07:39:18.000000000 -0800
@@ -1398,7 +1398,8 @@
} else if (force && to_stdout && !list) { /* pass input unchanged */
method = STORED;
work = copy;
- inptr--;
+ if (imagic1 != EOF)
+ inptr--;
last_member = 1;
if (imagic0 != EOF) {
write_buf(fileno(stdout), magic, 1);