aboutsummaryrefslogtreecommitdiff
path: root/linux/lib/xz
diff options
context:
space:
mode:
Diffstat (limited to 'linux/lib/xz')
-rw-r--r--linux/lib/xz/xz_dec_lzma2.c19
-rw-r--r--linux/lib/xz/xz_dec_stream.c2
2 files changed, 15 insertions, 6 deletions
diff --git a/linux/lib/xz/xz_dec_lzma2.c b/linux/lib/xz/xz_dec_lzma2.c
index d0d5d0c..3710390 100644
--- a/linux/lib/xz/xz_dec_lzma2.c
+++ b/linux/lib/xz/xz_dec_lzma2.c
@@ -788,12 +788,21 @@ static bool XZ_FUNC lzma_props(struct xz_dec_lzma2 *s, uint8_t props)
if (props > (4 * 5 + 4) * 9 + 8)
return false;
- s->lzma.pos_mask = props / (9 * 5);
- props -= s->lzma.pos_mask * 9 * 5;
+ s->lzma.pos_mask = 0;
+ while (props >= 9 * 5) {
+ props -= 9 * 5;
+ ++s->lzma.pos_mask;
+ }
+
s->lzma.pos_mask = (1 << s->lzma.pos_mask) - 1;
- s->lzma.literal_pos_mask = props / 9;
- s->lzma.lc = props - s->lzma.literal_pos_mask * 9;
+ s->lzma.literal_pos_mask = 0;
+ while (props >= 9) {
+ props -= 9;
+ ++s->lzma.literal_pos_mask;
+ }
+
+ s->lzma.lc = props;
if (s->lzma.lc + s->lzma.literal_pos_mask > 4)
return false;
@@ -1112,7 +1121,7 @@ XZ_EXTERN enum xz_ret XZ_FUNC xz_dec_lzma2_reset(
return XZ_OPTIONS_ERROR;
s->dict.size = 2 + (props & 1);
- s->dict.size <<= props / 2 + 11;
+ s->dict.size <<= (props >> 1) + 11;
if (s->dict.allocated > 0 && s->dict.allocated < s->dict.size)
return XZ_MEMLIMIT_ERROR;
diff --git a/linux/lib/xz/xz_dec_stream.c b/linux/lib/xz/xz_dec_stream.c
index c8387b4..9b9dfc0 100644
--- a/linux/lib/xz/xz_dec_stream.c
+++ b/linux/lib/xz/xz_dec_stream.c
@@ -382,7 +382,7 @@ static enum xz_ret XZ_FUNC dec_stream_footer(struct xz_dec *s)
* Index CRC32 field to s->index.size, thus we use s->index.size / 4
* instead of s->index.size / 4 - 1.
*/
- if (s->index.size / 4 != get_le32(s->temp.buf + 4))
+ if ((s->index.size >> 2) != get_le32(s->temp.buf + 4))
return XZ_DATA_ERROR;
if (s->temp.buf[8] != 0 || s->temp.buf[9] != s->has_crc32)