diff options
author | root <root> | 2006-09-27 13:51:51 +0000 |
---|---|---|
committer | root <root> | 2006-09-27 13:51:51 +0000 |
commit | 7599804b6e0f7b3c6548833755d3537c5ac9d8c3 (patch) | |
tree | 7bddc5b32f4af9ec7f355883d2375374087e4ded | |
parent | 22d6294e4c833573c3c165110e8c244833dd3eb6 (diff) |
*** empty log message ***
-rw-r--r-- | Changes | 2 | ||||
-rw-r--r-- | lzf.c | 20 |
2 files changed, 21 insertions, 1 deletions
@@ -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 @@ -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 <uncompressed data> * "ZV\1" 2-byte-csize 2-byte-usize <compressed data> * "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; |