diff options
| author | root <root> | 2006-07-07 15:34:11 +0000 | 
|---|---|---|
| committer | root <root> | 2006-07-07 15:34:11 +0000 | 
| commit | c236b409799117eb10770bb7225d10d8409dee35 (patch) | |
| tree | bf79a84679f4f35aa2f90e96fea6aecef2d79470 | |
| parent | 62f3e819eab18f9d175408dd7421b137132a728d (diff) | |
*** empty log message ***rel-1_6
| -rw-r--r-- | Changes | 2 | ||||
| -rw-r--r-- | Makefile.in | 2 | ||||
| -rw-r--r-- | cs/CLZF.cs | 2 | ||||
| -rw-r--r-- | lzf.c | 4 | ||||
| -rw-r--r-- | lzfP.h | 2 | ||||
| -rw-r--r-- | lzf_d.c | 30 | 
6 files changed, 36 insertions, 6 deletions
| @@ -6,6 +6,8 @@            data validity.          - help applications that do not pass in the correct length            (such as php) by returning either EINVAL or E2BIG. +        - default HLOG size is now 15 (cpu caches have increased). +        - documentation fixes.  1.51 Thu Apr 14 22:15:46 CEST 2005  	- incorporated C♯ implementation of both the en- and decoder, diff --git a/Makefile.in b/Makefile.in index 21bc031..050b56d 100644 --- a/Makefile.in +++ b/Makefile.in @@ -1,4 +1,4 @@ -VERSION = 1.51 +VERSION = 1.6  prefix = @prefix@  exec_prefix = @exec_prefix@ @@ -328,7 +328,7 @@ namespace LZF.NET  					while ((--len)!=0);  					}  				} -			while (oidx < out_len && iidx < in_len); +			while (iidx < in_len);  			return (int)oidx;  		} @@ -40,6 +40,7 @@  #include <stdio.h>  #include <stdlib.h> +#include <string.h>  #include <assert.h>  #include <unistd.h> @@ -203,6 +204,9 @@ main (int argc, char *argv[])    unsigned int blocksize = 64*1024-1;    enum { m_compress, m_decompress } mode = m_compress; +  if (!strcmp (argv[0] + strlen (argv[0] - 5), "unlzf")) +    mode = m_decompress; +    while ((c = getopt (argc, argv, "cdb:h")) != -1)      switch (c)        { @@ -128,7 +128,7 @@   * (<1% slowdown), but might slow down older cpus considerably.   */  #ifndef CHECK_INPUT -# define CHECK_INPUT 0 +# define CHECK_INPUT 1  #endif  /*****************************************************************************/ @@ -68,6 +68,14 @@ lzf_decompress (const void *const in_data,  unsigned int in_len,                return 0;              } +#if CHECK_INPUT +          if (ip + ctrl > in_end) +            { +              SET_ERRNO (EINVAL); +              return 0; +            } +#endif +  #if USE_MEMCPY            memcpy (op, ip, ctrl);            op += ctrl; @@ -84,9 +92,25 @@ lzf_decompress (const void *const in_data,  unsigned int in_len,            u8 *ref = op - ((ctrl & 0x1f) << 8) - 1; +#if CHECK_INPUT +          if (ip >= in_end) +            { +              SET_ERRNO (EINVAL); +              return 0; +            } +#endif            if (len == 7) -            len += *ip++; -           +            { +              len += *ip++; +#if CHECK_INPUT +              if (ip >= in_end) +                { +                  SET_ERRNO (EINVAL); +                  return 0; +                } +#endif +            } +            ref -= *ip++;            if (op + len + 2 > out_end) @@ -109,7 +133,7 @@ lzf_decompress (const void *const in_data,  unsigned int in_len,            while (--len);          }      } -  while (op < out_end && ip < in_end); +  while (ip < in_end);    return op - (u8 *)out_data;  } | 
