Date: Fri, 30 Dec 1994 22:02:51 -0500 From: Thomas David Rivers <rivers%ponds@ncren.net> To: freebsd-hackers@wcarchive.cdrom.com, freebsd-bugs@freebsd.org, rivers@ncren.net, biljir%squink@ncren.net Subject: Pretty serious bug in compress(1). Message-ID: <199412310302.WAA03568@ponds.UUCP>
next in thread | raw e-mail | index | archive | help
A down-feed news site of mine complained after my upgrade to 2.0R that some of his news batches were being botched instead of batched. I took a quick look at things to discover that the compress(1) program had been broken in the move from 1.1.5 to 2.0, but probably not in a way that anyone else would notice. In particular, this site can't handle 16-bit compression, so I use '-b 12' on the news feed. But, compress(1) was using a magic number in the file (will zwrite was in it's cookie) that indicated it was a 16-bit compressed file. You can demonstrate this problem by using the following: cd /tmp cp /etc/passwd /tmp compress -b 12 passwd file passwd.Z the output of the file command will indicate this is a 16-bit compressed file, when, in fact, it is a 12-bit compressed file. When uncompress/compress -d gets this file, it begins to apply 16-bit tables to the input, and sometimes fails in the middle, producing junk. Although, it won't do it with every input (because of the LZW hash lengths, etc...) it's not too hard to stumble on some where the uncompression fails. The following diff to zopen.c in /usr/src/usr.bin/compress will correct the problem. Also, someone may want to check on the zopen/zwrite() routines now in libc.a. *** zopen.c.ori Fri May 27 08:30:59 1994 --- zopen.c Sat Dec 31 11:05:29 1994 *************** *** 258,264 **** if (fwrite(magic_header, sizeof(char), sizeof(magic_header), fp) != sizeof(magic_header)) return (-1); ! tmp = (u_char)(BITS | block_compress); if (fwrite(&tmp, sizeof(char), sizeof(tmp), fp) != sizeof(tmp)) return (-1); --- 258,264 ---- if (fwrite(magic_header, sizeof(char), sizeof(magic_header), fp) != sizeof(magic_header)) return (-1); ! tmp = (u_char)((maxbits) | block_compress); if (fwrite(&tmp, sizeof(char), sizeof(tmp), fp) != sizeof(tmp)) return (-1); Hopefully, this can make it into 2.1... - Dave Rivers -
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199412310302.WAA03568>