aboutsummaryrefslogtreecommitdiff
path: root/linux/lib
diff options
context:
space:
mode:
Diffstat (limited to 'linux/lib')
-rw-r--r--linux/lib/decompress_unxz.c12
-rw-r--r--linux/lib/xz/Kconfig13
-rw-r--r--linux/lib/xz/xz_crc32.c2
-rw-r--r--linux/lib/xz/xz_crc64.c8
-rw-r--r--linux/lib/xz/xz_dec_bcj.c4
-rw-r--r--linux/lib/xz/xz_dec_lzma2.c193
-rw-r--r--linux/lib/xz/xz_dec_stream.c86
-rw-r--r--linux/lib/xz/xz_dec_syms.c9
-rw-r--r--linux/lib/xz/xz_lzma2.h2
-rw-r--r--linux/lib/xz/xz_private.h3
-rw-r--r--linux/lib/xz/xz_stream.h2
11 files changed, 30 insertions, 304 deletions
diff --git a/linux/lib/decompress_unxz.c b/linux/lib/decompress_unxz.c
index 7dfdde7..9f34eb5 100644
--- a/linux/lib/decompress_unxz.c
+++ b/linux/lib/decompress_unxz.c
@@ -20,10 +20,10 @@
*
* The worst case for in-place decompression is that the beginning of
* the file is compressed extremely well, and the rest of the file is
- * incompressible. Thus, we must look for worst-case expansion when the
- * compressor is encoding incompressible data.
+ * uncompressible. Thus, we must look for worst-case expansion when the
+ * compressor is encoding uncompressible data.
*
- * The structure of the .xz file in case of a compressed kernel is as follows.
+ * The structure of the .xz file in case of a compresed kernel is as follows.
* Sizes (as bytes) of the fields are in parenthesis.
*
* Stream Header (12)
@@ -58,7 +58,7 @@
* uncompressed size of the payload is in practice never less than the
* payload size itself. The LZMA2 format would allow uncompressed size
* to be less than the payload size, but no sane compressor creates such
- * files. LZMA2 supports storing incompressible data in uncompressed form,
+ * files. LZMA2 supports storing uncompressible data in uncompressed form,
* so there's never a need to create payloads whose uncompressed size is
* smaller than the compressed size.
*
@@ -167,8 +167,8 @@
* memeq and memzero are not used much and any remotely sane implementation
* is fast enough. memcpy/memmove speed matters in multi-call mode, but
* the kernel image is decompressed in single-call mode, in which only
- * memmove speed can matter and only if there is a lot of incompressible data
- * (LZMA2 stores incompressible chunks in uncompressed form). Thus, the
+ * memcpy speed can matter and only if there is a lot of uncompressible data
+ * (LZMA2 stores uncompressible chunks in uncompressed form). Thus, the
* functions below should just be kept small; it's probably not worth
* optimizing for speed.
*/
diff --git a/linux/lib/xz/Kconfig b/linux/lib/xz/Kconfig
index 3e58caf..08837db 100644
--- a/linux/lib/xz/Kconfig
+++ b/linux/lib/xz/Kconfig
@@ -38,19 +38,6 @@ config XZ_DEC_SPARC
default y if SPARC
select XZ_DEC_BCJ
-config XZ_DEC_MICROLZMA
- bool "MicroLZMA decoder"
- default n
- help
- MicroLZMA is a header format variant where the first byte
- of a raw LZMA stream (without the end of stream marker) has
- been replaced with a bitwise-negation of the lc/lp/pb
- properties byte. MicroLZMA was created to be used in EROFS
- but can be used by other things too where wasting minimal
- amount of space for headers is important.
-
- Unless you know that you need this, say N.
-
endif
config XZ_DEC_BCJ
diff --git a/linux/lib/xz/xz_crc32.c b/linux/lib/xz/xz_crc32.c
index 5627b00..34532d1 100644
--- a/linux/lib/xz/xz_crc32.c
+++ b/linux/lib/xz/xz_crc32.c
@@ -2,7 +2,7 @@
* CRC32 using the polynomial from IEEE-802.3
*
* Authors: Lasse Collin <lasse.collin@tukaani.org>
- * Igor Pavlov <https://7-zip.org/>
+ * Igor Pavlov <http://7-zip.org/>
*
* This file has been put into the public domain.
* You can do whatever you want with this file.
diff --git a/linux/lib/xz/xz_crc64.c b/linux/lib/xz/xz_crc64.c
index 60c40f6..ca1caee 100644
--- a/linux/lib/xz/xz_crc64.c
+++ b/linux/lib/xz/xz_crc64.c
@@ -4,7 +4,7 @@
* This file is similar to xz_crc32.c. See the comments there.
*
* Authors: Lasse Collin <lasse.collin@tukaani.org>
- * Igor Pavlov <https://7-zip.org/>
+ * Igor Pavlov <http://7-zip.org/>
*
* This file has been put into the public domain.
* You can do whatever you want with this file.
@@ -20,11 +20,7 @@ STATIC_RW_DATA uint64_t xz_crc64_table[256];
XZ_EXTERN void xz_crc64_init(void)
{
- /*
- * The ULL suffix is needed for -std=gnu89 compatibility
- * on 32-bit platforms.
- */
- const uint64_t poly = 0xC96C5795D7870F42ULL;
+ const uint64_t poly = 0xC96C5795D7870F42;
uint32_t i;
uint32_t j;
diff --git a/linux/lib/xz/xz_dec_bcj.c b/linux/lib/xz/xz_dec_bcj.c
index ef449e9..a768e6d 100644
--- a/linux/lib/xz/xz_dec_bcj.c
+++ b/linux/lib/xz/xz_dec_bcj.c
@@ -2,7 +2,7 @@
* Branch/Call/Jump (BCJ) filter decoders
*
* Authors: Lasse Collin <lasse.collin@tukaani.org>
- * Igor Pavlov <https://7-zip.org/>
+ * Igor Pavlov <http://7-zip.org/>
*
* This file has been put into the public domain.
* You can do whatever you want with this file.
@@ -422,7 +422,7 @@ XZ_EXTERN enum xz_ret xz_dec_bcj_run(struct xz_dec_bcj *s,
/*
* Flush pending already filtered data to the output buffer. Return
- * immediately if we couldn't flush everything, or if the next
+ * immediatelly if we couldn't flush everything, or if the next
* filter in the chain had already returned XZ_STREAM_END.
*/
if (s->temp.filtered > 0) {
diff --git a/linux/lib/xz/xz_dec_lzma2.c b/linux/lib/xz/xz_dec_lzma2.c
index c929f1c..08c3c80 100644
--- a/linux/lib/xz/xz_dec_lzma2.c
+++ b/linux/lib/xz/xz_dec_lzma2.c
@@ -2,7 +2,7 @@
* LZMA2 decoder
*
* Authors: Lasse Collin <lasse.collin@tukaani.org>
- * Igor Pavlov <https://7-zip.org/>
+ * Igor Pavlov <http://7-zip.org/>
*
* This file has been put into the public domain.
* You can do whatever you want with this file.
@@ -147,8 +147,8 @@ struct lzma_dec {
/*
* LZMA properties or related bit masks (number of literal
- * context bits, a mask derived from the number of literal
- * position bits, and a mask derived from the number
+ * context bits, a mask dervied from the number of literal
+ * position bits, and a mask dervied from the number
* position bits)
*/
uint32_t lc;
@@ -248,10 +248,6 @@ struct lzma2_dec {
* before the first LZMA chunk.
*/
bool need_props;
-
-#ifdef XZ_DEC_MICROLZMA
- bool pedantic_microlzma;
-#endif
};
struct xz_dec_lzma2 {
@@ -391,14 +387,7 @@ static void dict_uncompressed(struct dictionary *dict, struct xz_buf *b,
*left -= copy_size;
- /*
- * If doing in-place decompression in single-call mode and the
- * uncompressed size of the file is larger than the caller
- * thought (i.e. it is invalid input!), the buffers below may
- * overlap and cause undefined behavior with memcpy().
- * With valid inputs memcpy() would be fine here.
- */
- memmove(dict->buf + dict->pos, b->in + b->in_pos, copy_size);
+ memcpy(dict->buf + dict->pos, b->in + b->in_pos, copy_size);
dict->pos += copy_size;
if (dict->full < dict->pos)
@@ -408,11 +397,7 @@ static void dict_uncompressed(struct dictionary *dict, struct xz_buf *b,
if (dict->pos == dict->end)
dict->pos = 0;
- /*
- * Like above but for multi-call mode: use memmove()
- * to avoid undefined behavior with invalid input.
- */
- memmove(b->out + b->out_pos, b->in + b->in_pos,
+ memcpy(b->out + b->out_pos, b->in + b->in_pos,
copy_size);
}
@@ -423,12 +408,6 @@ static void dict_uncompressed(struct dictionary *dict, struct xz_buf *b,
}
}
-#ifdef XZ_DEC_MICROLZMA
-# define DICT_FLUSH_SUPPORTS_SKIPPING true
-#else
-# define DICT_FLUSH_SUPPORTS_SKIPPING false
-#endif
-
/*
* Flush pending data from dictionary to b->out. It is assumed that there is
* enough space in b->out. This is guaranteed because caller uses dict_limit()
@@ -442,19 +421,8 @@ static uint32_t dict_flush(struct dictionary *dict, struct xz_buf *b)
if (dict->pos == dict->end)
dict->pos = 0;
- /*
- * These buffers cannot overlap even if doing in-place
- * decompression because in multi-call mode dict->buf
- * has been allocated by us in this file; it's not
- * provided by the caller like in single-call mode.
- *
- * With MicroLZMA, b->out can be NULL to skip bytes that
- * the caller doesn't need. This cannot be done with XZ
- * because it would break BCJ filters.
- */
- if (!DICT_FLUSH_SUPPORTS_SKIPPING || b->out != NULL)
- memcpy(b->out + b->out_pos, dict->buf + dict->start,
- copy_size);
+ memcpy(b->out + b->out_pos, dict->buf + dict->start,
+ copy_size);
}
dict->start = dict->pos;
@@ -516,11 +484,11 @@ static __always_inline void rc_normalize(struct rc_dec *rc)
}
/*
- * Decode one bit. In some versions, this function has been split in three
+ * Decode one bit. In some versions, this function has been splitted in three
* functions so that the compiler is supposed to be able to more easily avoid
* an extra branch. In this particular version of the LZMA decoder, this
* doesn't seem to be a good idea (tested with GCC 3.3.6, 3.4.6, and 4.3.3
- * on x86). Using a non-split version results in nicer looking code too.
+ * on x86). Using a non-splitted version results in nicer looking code too.
*
* NOTE: This must return an int. Do not make it return a bool or the speed
* of the code generated by GCC 3.x decreases 10-15 %. (GCC 4.3 doesn't care,
@@ -793,7 +761,7 @@ static bool lzma_main(struct xz_dec_lzma2 *s)
}
/*
- * Reset the LZMA decoder and range decoder state. Dictionary is not reset
+ * Reset the LZMA decoder and range decoder state. Dictionary is nore reset
* here, because LZMA state may be reset without resetting the dictionary.
*/
static void lzma_reset(struct xz_dec_lzma2 *s)
@@ -806,7 +774,6 @@ static void lzma_reset(struct xz_dec_lzma2 *s)
s->lzma.rep1 = 0;
s->lzma.rep2 = 0;
s->lzma.rep3 = 0;
- s->lzma.len = 0;
/*
* All probabilities are initialized to the same value. This hack
@@ -1179,7 +1146,6 @@ XZ_EXTERN enum xz_ret xz_dec_lzma2_reset(struct xz_dec_lzma2 *s, uint8_t props)
if (DEC_IS_DYNALLOC(s->dict.mode)) {
if (s->dict.allocated < s->dict.size) {
- s->dict.allocated = s->dict.size;
vfree(s->dict.buf);
s->dict.buf = vmalloc(s->dict.size);
if (s->dict.buf == NULL) {
@@ -1190,6 +1156,8 @@ XZ_EXTERN enum xz_ret xz_dec_lzma2_reset(struct xz_dec_lzma2 *s, uint8_t props)
}
}
+ s->lzma.len = 0;
+
s->lzma2.sequence = SEQ_CONTROL;
s->lzma2.need_dict_reset = true;
@@ -1205,140 +1173,3 @@ XZ_EXTERN void xz_dec_lzma2_end(struct xz_dec_lzma2 *s)
kfree(s);
}
-
-#ifdef XZ_DEC_MICROLZMA
-/* This is a wrapper struct to have a nice struct name in the public API. */
-struct xz_dec_microlzma {
- struct xz_dec_lzma2 s;
-};
-
-enum xz_ret xz_dec_microlzma_run(struct xz_dec_microlzma *s_ptr,
- struct xz_buf *b)
-{
- struct xz_dec_lzma2 *s = &s_ptr->s;
-
- /*
- * sequence is SEQ_PROPERTIES before the first input byte,
- * SEQ_LZMA_PREPARE until a total of five bytes have been read,
- * and SEQ_LZMA_RUN for the rest of the input stream.
- */
- if (s->lzma2.sequence != SEQ_LZMA_RUN) {
- if (s->lzma2.sequence == SEQ_PROPERTIES) {
- /* One byte is needed for the props. */
- if (b->in_pos >= b->in_size)
- return XZ_OK;
-
- /*
- * Don't increment b->in_pos here. The same byte is
- * also passed to rc_read_init() which will ignore it.
- */
- if (!lzma_props(s, ~b->in[b->in_pos]))
- return XZ_DATA_ERROR;
-
- s->lzma2.sequence = SEQ_LZMA_PREPARE;
- }
-
- /*
- * xz_dec_microlzma_reset() doesn't validate the compressed
- * size so we do it here. We have to limit the maximum size
- * to avoid integer overflows in lzma2_lzma(). 3 GiB is a nice
- * round number and much more than users of this code should
- * ever need.
- */
- if (s->lzma2.compressed < RC_INIT_BYTES
- || s->lzma2.compressed > (3U << 30))
- return XZ_DATA_ERROR;
-
- if (!rc_read_init(&s->rc, b))
- return XZ_OK;
-
- s->lzma2.compressed -= RC_INIT_BYTES;
- s->lzma2.sequence = SEQ_LZMA_RUN;
-
- dict_reset(&s->dict, b);
- }
-
- /* This is to allow increasing b->out_size between calls. */
- if (DEC_IS_SINGLE(s->dict.mode))
- s->dict.end = b->out_size - b->out_pos;
-
- while (true) {
- dict_limit(&s->dict, min_t(size_t, b->out_size - b->out_pos,
- s->lzma2.uncompressed));
-
- if (!lzma2_lzma(s, b))
- return XZ_DATA_ERROR;
-
- s->lzma2.uncompressed -= dict_flush(&s->dict, b);
-
- if (s->lzma2.uncompressed == 0) {
- if (s->lzma2.pedantic_microlzma) {
- if (s->lzma2.compressed > 0 || s->lzma.len > 0
- || !rc_is_finished(&s->rc))
- return XZ_DATA_ERROR;
- }
-
- return XZ_STREAM_END;
- }
-
- if (b->out_pos == b->out_size)
- return XZ_OK;
-
- if (b->in_pos == b->in_size
- && s->temp.size < s->lzma2.compressed)
- return XZ_OK;
- }
-}
-
-struct xz_dec_microlzma *xz_dec_microlzma_alloc(enum xz_mode mode,
- uint32_t dict_size)
-{
- struct xz_dec_microlzma *s;
-
- /* Restrict dict_size to the same range as in the LZMA2 code. */
- if (dict_size < 4096 || dict_size > (3U << 30))
- return NULL;
-
- s = kmalloc(sizeof(*s), GFP_KERNEL);
- if (s == NULL)
- return NULL;
-
- s->s.dict.mode = mode;
- s->s.dict.size = dict_size;
-
- if (DEC_IS_MULTI(mode)) {
- s->s.dict.end = dict_size;
-
- s->s.dict.buf = vmalloc(dict_size);
- if (s->s.dict.buf == NULL) {
- kfree(s);
- return NULL;
- }
- }
-
- return s;
-}
-
-void xz_dec_microlzma_reset(struct xz_dec_microlzma *s, uint32_t comp_size,
- uint32_t uncomp_size, int uncomp_size_is_exact)
-{
- /*
- * comp_size is validated in xz_dec_microlzma_run().
- * uncomp_size can safely be anything.
- */
- s->s.lzma2.compressed = comp_size;
- s->s.lzma2.uncompressed = uncomp_size;
- s->s.lzma2.pedantic_microlzma = uncomp_size_is_exact;
-
- s->s.lzma2.sequence = SEQ_PROPERTIES;
- s->s.temp.size = 0;
-}
-
-void xz_dec_microlzma_end(struct xz_dec_microlzma *s)
-{
- if (DEC_IS_MULTI(s->s.dict.mode))
- vfree(s->s.dict.buf);
-
- kfree(s);
-}
-#endif
diff --git a/linux/lib/xz/xz_dec_stream.c b/linux/lib/xz/xz_dec_stream.c
index 2c41f5f..f69581b 100644
--- a/linux/lib/xz/xz_dec_stream.c
+++ b/linux/lib/xz/xz_dec_stream.c
@@ -35,8 +35,7 @@ struct xz_dec {
SEQ_INDEX,
SEQ_INDEX_PADDING,
SEQ_INDEX_CRC32,
- SEQ_STREAM_FOOTER,
- SEQ_STREAM_PADDING
+ SEQ_STREAM_FOOTER
} sequence;
/* Position in variable-length integers and Check fields */
@@ -424,12 +423,12 @@ static enum xz_ret dec_stream_header(struct xz_dec *s)
* check types too, but then the check won't be verified and
* a warning (XZ_UNSUPPORTED_CHECK) will be given.
*/
- if (s->temp.buf[HEADER_MAGIC_SIZE + 1] > XZ_CHECK_MAX)
- return XZ_OPTIONS_ERROR;
-
s->check_type = s->temp.buf[HEADER_MAGIC_SIZE + 1];
#ifdef XZ_DEC_ANY_CHECK
+ if (s->check_type > XZ_CHECK_MAX)
+ return XZ_OPTIONS_ERROR;
+
if (s->check_type > XZ_CHECK_CRC32 && !IS_CRC64(s->check_type))
return XZ_UNSUPPORTED_CHECK;
#else
@@ -743,10 +742,6 @@ static enum xz_ret dec_main(struct xz_dec *s, struct xz_buf *b)
return XZ_OK;
return dec_stream_footer(s);
-
- case SEQ_STREAM_PADDING:
- /* Never reached, only silencing a warning */
- break;
}
}
@@ -814,79 +809,6 @@ XZ_EXTERN enum xz_ret xz_dec_run(struct xz_dec *s, struct xz_buf *b)
return ret;
}
-#ifdef XZ_DEC_CONCATENATED
-XZ_EXTERN enum xz_ret xz_dec_catrun(struct xz_dec *s, struct xz_buf *b,
- int finish)
-{
- enum xz_ret ret;
-
- if (DEC_IS_SINGLE(s->mode)) {
- xz_dec_reset(s);
- finish = true;
- }
-
- while (true) {
- if (s->sequence == SEQ_STREAM_PADDING) {
- /*
- * Skip Stream Padding. Its size must be a multiple
- * of four bytes which is tracked with s->pos.
- */
- while (true) {
- if (b->in_pos == b->in_size) {
- /*
- * Note that if we are repeatedly
- * given no input and finish is false,
- * we will keep returning XZ_OK even
- * though no progress is being made.
- * The lack of XZ_BUF_ERROR support
- * isn't a problem here because a
- * reasonable caller will eventually
- * provide more input or set finish
- * to true.
- */
- if (!finish)
- return XZ_OK;
-
- if (s->pos != 0)
- return XZ_DATA_ERROR;
-
- return XZ_STREAM_END;
- }
-
- if (b->in[b->in_pos] != 0x00) {
- if (s->pos != 0)
- return XZ_DATA_ERROR;
-
- break;
- }
-
- ++b->in_pos;
- s->pos = (s->pos + 1) & 3;
- }
-
- /*
- * More input remains. It should be a new Stream.
- *
- * In single-call mode xz_dec_run() will always call
- * xz_dec_reset(). Thus, we need to do it here only
- * in multi-call mode.
- */
- if (DEC_IS_MULTI(s->mode))
- xz_dec_reset(s);
- }
-
- ret = xz_dec_run(s, b);
-
- if (ret != XZ_STREAM_END)
- break;
-
- s->sequence = SEQ_STREAM_PADDING;
- }
-
- return ret;
-}
-#endif
-
XZ_EXTERN struct xz_dec *xz_dec_init(enum xz_mode mode, uint32_t dict_max)
{
struct xz_dec *s = kmalloc(sizeof(*s), GFP_KERNEL);
diff --git a/linux/lib/xz/xz_dec_syms.c b/linux/lib/xz/xz_dec_syms.c
index 61098c6..32eb3c0 100644
--- a/linux/lib/xz/xz_dec_syms.c
+++ b/linux/lib/xz/xz_dec_syms.c
@@ -15,15 +15,8 @@ EXPORT_SYMBOL(xz_dec_reset);
EXPORT_SYMBOL(xz_dec_run);
EXPORT_SYMBOL(xz_dec_end);
-#ifdef CONFIG_XZ_DEC_MICROLZMA
-EXPORT_SYMBOL(xz_dec_microlzma_alloc);
-EXPORT_SYMBOL(xz_dec_microlzma_reset);
-EXPORT_SYMBOL(xz_dec_microlzma_run);
-EXPORT_SYMBOL(xz_dec_microlzma_end);
-#endif
-
MODULE_DESCRIPTION("XZ decompressor");
-MODULE_VERSION("1.1");
+MODULE_VERSION("1.0");
MODULE_AUTHOR("Lasse Collin <lasse.collin@tukaani.org> and Igor Pavlov");
/*
diff --git a/linux/lib/xz/xz_lzma2.h b/linux/lib/xz/xz_lzma2.h
index 92d852d..071d67b 100644
--- a/linux/lib/xz/xz_lzma2.h
+++ b/linux/lib/xz/xz_lzma2.h
@@ -2,7 +2,7 @@
* LZMA2 definitions
*
* Authors: Lasse Collin <lasse.collin@tukaani.org>
- * Igor Pavlov <https://7-zip.org/>
+ * Igor Pavlov <http://7-zip.org/>
*
* This file has been put into the public domain.
* You can do whatever you want with this file.
diff --git a/linux/lib/xz/xz_private.h b/linux/lib/xz/xz_private.h
index d9fd49b..482b90f 100644
--- a/linux/lib/xz/xz_private.h
+++ b/linux/lib/xz/xz_private.h
@@ -37,9 +37,6 @@
# ifdef CONFIG_XZ_DEC_SPARC
# define XZ_DEC_SPARC
# endif
-# ifdef CONFIG_XZ_DEC_MICROLZMA
-# define XZ_DEC_MICROLZMA
-# endif
# define memeq(a, b, size) (memcmp(a, b, size) == 0)
# define memzero(buf, size) memset(buf, 0, size)
# endif
diff --git a/linux/lib/xz/xz_stream.h b/linux/lib/xz/xz_stream.h
index 430bb3a..66cb5a7 100644
--- a/linux/lib/xz/xz_stream.h
+++ b/linux/lib/xz/xz_stream.h
@@ -19,7 +19,7 @@
/*
* See the .xz file format specification at
- * https://tukaani.org/xz/xz-file-format.txt
+ * http://tukaani.org/xz/xz-file-format.txt
* to understand the container format.
*/