On Wed, Apr 18, 2001 at 08:05:35PM +1000, Glenn McGrath wrote: > I recently made some big changes to gunzip, looks like i didnt test it > well enough. *gag* > I will look into it now, i doubt #3 is anything serious, as ive been > using it a lot with dpkg, dpkg-deb, probably some error messages or > something are getting mixed up in the output stream. There are at least two bugs: one is that fseek() doesn't work on unseekable file handles, like stdin and stdout; the other (that you're fortunately avoiding) is that the order of evaluation in C of the oeprands of arithmetic operators like "+" is undefined. That is, code like: int chars_printed = printf("foo") + printf("bar"); will usually equal 6, but you could get "foobar" printed, "barfoo" printed, or even conceivably something completely different. A rough patch which seems to get it working again is: /* Ignore time stamp(4), extra flags(1), OS type(1) */ - fseek(in_file, 6, SEEK_CUR); + { int i = 0; while (i < 6) { fgetc(in_file); i++; } } + /* fseek(in_file, 6, SEEK_CUR); -- you can't seek on stdin */ if ((flags & extra_field) != 0) { - fseek(in_file, (size_t) fgetc(in_file) + ((size_t)fgetc(in_file) << 8), SEEK_CUR); + int i; + i = fgetc(in_file); + i += fgetc(in_file) << 8; + while (i-- > 0) fgetc(in_file); + /* fseek(in_file, (size_t) fgetc(in_file) + ((size_t)fgetc(in_fi le) << 8), SEEK_CUR); + * -- you can't seek on stdin, and the order of function calls + * in the above isn't guaranteed */ } Dicking around with gzip code is just asking for obscure bugs to bite in you in the bum, though... Cheers, aj -- Anthony Towns <aj@humbug.org.au> <http://azure.humbug.org.au/~aj/> I don't speak for anyone save myself. GPG signed mail preferred. ``_Any_ increase in interface difficulty, in exchange for a benefit you do not understand, cannot perceive, or don't care about, is too much.'' -- John S. Novak, III (The Humblest Man on the Net)
Attachment:
pgpAJ1KjTudjB.pgp
Description: PGP signature