From 7599804b6e0f7b3c6548833755d3537c5ac9d8c3 Mon Sep 17 00:00:00 2001 From: root Date: Wed, 27 Sep 2006 13:51:51 +0000 Subject: *** empty log message *** --- Changes | 2 ++ lzf.c | 20 +++++++++++++++++++- 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/Changes b/Changes index 8d6346e..68e8bcf 100644 --- a/Changes +++ b/Changes @@ -1,6 +1,8 @@ +1.7 - remove bogus broken horrific "unlzf" patch by Scott Feeney, note to self: never accept well-meant patches. + - make lzf more robust in presence of padding bytes or sudden eof. 1.6 Fri Jul 7 17:31:26 CEST 2006 - the lzf example utility will now uncompress if invoked diff --git a/lzf.c b/lzf.c index b4bce98..0101be0 100644 --- a/lzf.c +++ b/lzf.c @@ -71,6 +71,7 @@ usage (int ec) /* * Anatomy: an lzf file consists of any number of blocks in the following format: * + * \x00 EOF (optional) * "ZV\0" 2-byte-usize * "ZV\1" 2-byte-csize 2-byte-usize * "ZV\2" 4-byte-crc32-0xdebb20e3 (NYI) @@ -136,7 +137,24 @@ static void decompress (void) u8 header[3+2+2]; for(;;) { - if (fread (header, 3+2, 1, stdin) != 1) + int hdrsize = fread (header, 1, 3+2, stdin); + + /* check for \0 record */ + if (hdrsize) + { + if (!header[0]) + break; + else if (hdrsize != 3+2) + { + if (feof (stdin)) + fprintf (stderr, "decompress: invalid stream - short header\n"); + else + perror ("decompress"); + + exit (1); + } + } + else { if (feof (stdin)) break; -- cgit v1.2.3