aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--crypto/testmgr.h38
-rw-r--r--include/linux/lzo.h15
-rw-r--r--lib/decompress_unlzo.c2
-rw-r--r--lib/lzo/Makefile2
-rw-r--r--lib/lzo/lzo1x_compress.c335
-rw-r--r--lib/lzo/lzo1x_decompress.c255
-rw-r--r--lib/lzo/lzo1x_decompress_safe.c237
-rw-r--r--lib/lzo/lzodefs.h38
8 files changed, 488 insertions, 434 deletions
diff --git a/crypto/testmgr.h b/crypto/testmgr.h
index b5721e0b979c..3db1b7591559 100644
--- a/crypto/testmgr.h
+++ b/crypto/testmgr.h
@@ -25084,38 +25084,40 @@ static struct pcomp_testvec zlib_decomp_tv_template[] = {
25084static struct comp_testvec lzo_comp_tv_template[] = { 25084static struct comp_testvec lzo_comp_tv_template[] = {
25085 { 25085 {
25086 .inlen = 70, 25086 .inlen = 70,
25087 .outlen = 46, 25087 .outlen = 57,
25088 .input = "Join us now and share the software " 25088 .input = "Join us now and share the software "
25089 "Join us now and share the software ", 25089 "Join us now and share the software ",
25090 .output = "\x00\x0d\x4a\x6f\x69\x6e\x20\x75" 25090 .output = "\x00\x0d\x4a\x6f\x69\x6e\x20\x75"
25091 "\x73\x20\x6e\x6f\x77\x20\x61\x6e" 25091 "\x73\x20\x6e\x6f\x77\x20\x61\x6e"
25092 "\x64\x20\x73\x68\x61\x72\x65\x20" 25092 "\x64\x20\x73\x68\x61\x72\x65\x20"
25093 "\x74\x68\x65\x20\x73\x6f\x66\x74" 25093 "\x74\x68\x65\x20\x73\x6f\x66\x74"
25094 "\x77\x70\x01\x01\x4a\x6f\x69\x6e" 25094 "\x77\x70\x01\x32\x88\x00\x0c\x65"
25095 "\x3d\x88\x00\x11\x00\x00", 25095 "\x20\x74\x68\x65\x20\x73\x6f\x66"
25096 "\x74\x77\x61\x72\x65\x20\x11\x00"
25097 "\x00",
25096 }, { 25098 }, {
25097 .inlen = 159, 25099 .inlen = 159,
25098 .outlen = 133, 25100 .outlen = 131,
25099 .input = "This document describes a compression method based on the LZO " 25101 .input = "This document describes a compression method based on the LZO "
25100 "compression algorithm. This document defines the application of " 25102 "compression algorithm. This document defines the application of "
25101 "the LZO algorithm used in UBIFS.", 25103 "the LZO algorithm used in UBIFS.",
25102 .output = "\x00\x2b\x54\x68\x69\x73\x20\x64" 25104 .output = "\x00\x2c\x54\x68\x69\x73\x20\x64"
25103 "\x6f\x63\x75\x6d\x65\x6e\x74\x20" 25105 "\x6f\x63\x75\x6d\x65\x6e\x74\x20"
25104 "\x64\x65\x73\x63\x72\x69\x62\x65" 25106 "\x64\x65\x73\x63\x72\x69\x62\x65"
25105 "\x73\x20\x61\x20\x63\x6f\x6d\x70" 25107 "\x73\x20\x61\x20\x63\x6f\x6d\x70"
25106 "\x72\x65\x73\x73\x69\x6f\x6e\x20" 25108 "\x72\x65\x73\x73\x69\x6f\x6e\x20"
25107 "\x6d\x65\x74\x68\x6f\x64\x20\x62" 25109 "\x6d\x65\x74\x68\x6f\x64\x20\x62"
25108 "\x61\x73\x65\x64\x20\x6f\x6e\x20" 25110 "\x61\x73\x65\x64\x20\x6f\x6e\x20"
25109 "\x74\x68\x65\x20\x4c\x5a\x4f\x2b" 25111 "\x74\x68\x65\x20\x4c\x5a\x4f\x20"
25110 "\x8c\x00\x0d\x61\x6c\x67\x6f\x72" 25112 "\x2a\x8c\x00\x09\x61\x6c\x67\x6f"
25111 "\x69\x74\x68\x6d\x2e\x20\x20\x54" 25113 "\x72\x69\x74\x68\x6d\x2e\x20\x20"
25112 "\x68\x69\x73\x2a\x54\x01\x02\x66" 25114 "\x2e\x54\x01\x03\x66\x69\x6e\x65"
25113 "\x69\x6e\x65\x73\x94\x06\x05\x61" 25115 "\x73\x20\x74\x06\x05\x61\x70\x70"
25114 "\x70\x70\x6c\x69\x63\x61\x74\x76" 25116 "\x6c\x69\x63\x61\x74\x76\x0a\x6f"
25115 "\x0a\x6f\x66\x88\x02\x60\x09\x27" 25117 "\x66\x88\x02\x60\x09\x27\xf0\x00"
25116 "\xf0\x00\x0c\x20\x75\x73\x65\x64" 25118 "\x0c\x20\x75\x73\x65\x64\x20\x69"
25117 "\x20\x69\x6e\x20\x55\x42\x49\x46" 25119 "\x6e\x20\x55\x42\x49\x46\x53\x2e"
25118 "\x53\x2e\x11\x00\x00", 25120 "\x11\x00\x00",
25119 }, 25121 },
25120}; 25122};
25121 25123
diff --git a/include/linux/lzo.h b/include/linux/lzo.h
index d793497ec1ca..a0848d9377e5 100644
--- a/include/linux/lzo.h
+++ b/include/linux/lzo.h
@@ -4,28 +4,28 @@
4 * LZO Public Kernel Interface 4 * LZO Public Kernel Interface
5 * A mini subset of the LZO real-time data compression library 5 * A mini subset of the LZO real-time data compression library
6 * 6 *
7 * Copyright (C) 1996-2005 Markus F.X.J. Oberhumer <markus@oberhumer.com> 7 * Copyright (C) 1996-2012 Markus F.X.J. Oberhumer <markus@oberhumer.com>
8 * 8 *
9 * The full LZO package can be found at: 9 * The full LZO package can be found at:
10 * http://www.oberhumer.com/opensource/lzo/ 10 * http://www.oberhumer.com/opensource/lzo/
11 * 11 *
12 * Changed for kernel use by: 12 * Changed for Linux kernel use by:
13 * Nitin Gupta <nitingupta910@gmail.com> 13 * Nitin Gupta <nitingupta910@gmail.com>
14 * Richard Purdie <rpurdie@openedhand.com> 14 * Richard Purdie <rpurdie@openedhand.com>
15 */ 15 */
16 16
17#define LZO1X_MEM_COMPRESS (16384 * sizeof(unsigned char *)) 17#define LZO1X_1_MEM_COMPRESS (8192 * sizeof(unsigned short))
18#define LZO1X_1_MEM_COMPRESS LZO1X_MEM_COMPRESS 18#define LZO1X_MEM_COMPRESS LZO1X_1_MEM_COMPRESS
19 19
20#define lzo1x_worst_compress(x) ((x) + ((x) / 16) + 64 + 3) 20#define lzo1x_worst_compress(x) ((x) + ((x) / 16) + 64 + 3)
21 21
22/* This requires 'workmem' of size LZO1X_1_MEM_COMPRESS */ 22/* This requires 'wrkmem' of size LZO1X_1_MEM_COMPRESS */
23int lzo1x_1_compress(const unsigned char *src, size_t src_len, 23int lzo1x_1_compress(const unsigned char *src, size_t src_len,
24 unsigned char *dst, size_t *dst_len, void *wrkmem); 24 unsigned char *dst, size_t *dst_len, void *wrkmem);
25 25
26/* safe decompression with overrun testing */ 26/* safe decompression with overrun testing */
27int lzo1x_decompress_safe(const unsigned char *src, size_t src_len, 27int lzo1x_decompress_safe(const unsigned char *src, size_t src_len,
28 unsigned char *dst, size_t *dst_len); 28 unsigned char *dst, size_t *dst_len);
29 29
30/* 30/*
31 * Return values (< 0 = Error) 31 * Return values (< 0 = Error)
@@ -40,5 +40,6 @@ int lzo1x_decompress_safe(const unsigned char *src, size_t src_len,
40#define LZO_E_EOF_NOT_FOUND (-7) 40#define LZO_E_EOF_NOT_FOUND (-7)
41#define LZO_E_INPUT_NOT_CONSUMED (-8) 41#define LZO_E_INPUT_NOT_CONSUMED (-8)
42#define LZO_E_NOT_YET_IMPLEMENTED (-9) 42#define LZO_E_NOT_YET_IMPLEMENTED (-9)
43#define LZO_E_INVALID_ARGUMENT (-10)
43 44
44#endif 45#endif
diff --git a/lib/decompress_unlzo.c b/lib/decompress_unlzo.c
index 4531294fa62f..960183d4258f 100644
--- a/lib/decompress_unlzo.c
+++ b/lib/decompress_unlzo.c
@@ -31,7 +31,7 @@
31 */ 31 */
32 32
33#ifdef STATIC 33#ifdef STATIC
34#include "lzo/lzo1x_decompress.c" 34#include "lzo/lzo1x_decompress_safe.c"
35#else 35#else
36#include <linux/decompress/unlzo.h> 36#include <linux/decompress/unlzo.h>
37#endif 37#endif
diff --git a/lib/lzo/Makefile b/lib/lzo/Makefile
index e764116ea12d..f0f7d7ca2b83 100644
--- a/lib/lzo/Makefile
+++ b/lib/lzo/Makefile
@@ -1,5 +1,5 @@
1lzo_compress-objs := lzo1x_compress.o 1lzo_compress-objs := lzo1x_compress.o
2lzo_decompress-objs := lzo1x_decompress.o 2lzo_decompress-objs := lzo1x_decompress_safe.o
3 3
4obj-$(CONFIG_LZO_COMPRESS) += lzo_compress.o 4obj-$(CONFIG_LZO_COMPRESS) += lzo_compress.o
5obj-$(CONFIG_LZO_DECOMPRESS) += lzo_decompress.o 5obj-$(CONFIG_LZO_DECOMPRESS) += lzo_decompress.o
diff --git a/lib/lzo/lzo1x_compress.c b/lib/lzo/lzo1x_compress.c
index a6040990a62e..236eb21167b5 100644
--- a/lib/lzo/lzo1x_compress.c
+++ b/lib/lzo/lzo1x_compress.c
@@ -1,194 +1,243 @@
1/* 1/*
2 * LZO1X Compressor from MiniLZO 2 * LZO1X Compressor from LZO
3 * 3 *
4 * Copyright (C) 1996-2005 Markus F.X.J. Oberhumer <markus@oberhumer.com> 4 * Copyright (C) 1996-2012 Markus F.X.J. Oberhumer <markus@oberhumer.com>
5 * 5 *
6 * The full LZO package can be found at: 6 * The full LZO package can be found at:
7 * http://www.oberhumer.com/opensource/lzo/ 7 * http://www.oberhumer.com/opensource/lzo/
8 * 8 *
9 * Changed for kernel use by: 9 * Changed for Linux kernel use by:
10 * Nitin Gupta <nitingupta910@gmail.com> 10 * Nitin Gupta <nitingupta910@gmail.com>
11 * Richard Purdie <rpurdie@openedhand.com> 11 * Richard Purdie <rpurdie@openedhand.com>
12 */ 12 */
13 13
14#include <linux/module.h> 14#include <linux/module.h>
15#include <linux/kernel.h> 15#include <linux/kernel.h>
16#include <linux/lzo.h>
17#include <asm/unaligned.h> 16#include <asm/unaligned.h>
17#include <linux/lzo.h>
18#include "lzodefs.h" 18#include "lzodefs.h"
19 19
20static noinline size_t 20static noinline size_t
21_lzo1x_1_do_compress(const unsigned char *in, size_t in_len, 21lzo1x_1_do_compress(const unsigned char *in, size_t in_len,
22 unsigned char *out, size_t *out_len, void *wrkmem) 22 unsigned char *out, size_t *out_len,
23 size_t ti, void *wrkmem)
23{ 24{
25 const unsigned char *ip;
26 unsigned char *op;
24 const unsigned char * const in_end = in + in_len; 27 const unsigned char * const in_end = in + in_len;
25 const unsigned char * const ip_end = in + in_len - M2_MAX_LEN - 5;