Make the memusage functions of LZMA1 and LZMA2 decoders
to validate the filter options.
This commit is contained in:
parent
c58f469be5
commit
c596fda40b
@ -261,11 +261,8 @@ lzma_lzma2_decoder_init(lzma_next_coder *next, lzma_allocator *allocator,
|
|||||||
extern uint64_t
|
extern uint64_t
|
||||||
lzma_lzma2_decoder_memusage(const void *options)
|
lzma_lzma2_decoder_memusage(const void *options)
|
||||||
{
|
{
|
||||||
const uint64_t lzma_memusage = lzma_lzma_decoder_memusage(options);
|
return sizeof(lzma_coder)
|
||||||
if (lzma_memusage == UINT64_MAX)
|
+ lzma_lzma_decoder_memusage_nocheck(options);
|
||||||
return UINT64_MAX;
|
|
||||||
|
|
||||||
return sizeof(lzma_coder) + lzma_memusage;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -1012,14 +1012,20 @@ lzma_lzma_lclppb_decode(lzma_options_lzma *options, uint8_t byte)
|
|||||||
|
|
||||||
|
|
||||||
extern uint64_t
|
extern uint64_t
|
||||||
lzma_lzma_decoder_memusage(const void *options)
|
lzma_lzma_decoder_memusage_nocheck(const void *options)
|
||||||
{
|
{
|
||||||
const lzma_options_lzma *const opt = options;
|
const lzma_options_lzma *const opt = options;
|
||||||
const uint64_t lz_memusage = lzma_lz_decoder_memusage(opt->dict_size);
|
return sizeof(lzma_coder) + lzma_lz_decoder_memusage(opt->dict_size);
|
||||||
if (lz_memusage == UINT64_MAX)
|
}
|
||||||
|
|
||||||
|
|
||||||
|
extern uint64_t
|
||||||
|
lzma_lzma_decoder_memusage(const void *options)
|
||||||
|
{
|
||||||
|
if (!is_lclppb_valid(options))
|
||||||
return UINT64_MAX;
|
return UINT64_MAX;
|
||||||
|
|
||||||
return sizeof(lzma_coder) + lz_memusage;
|
return lzma_lzma_decoder_memusage_nocheck(options);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -49,6 +49,11 @@ extern bool lzma_lzma_lclppb_decode(
|
|||||||
extern lzma_ret lzma_lzma_decoder_create(
|
extern lzma_ret lzma_lzma_decoder_create(
|
||||||
lzma_lz_decoder *lz, lzma_allocator *allocator,
|
lzma_lz_decoder *lz, lzma_allocator *allocator,
|
||||||
const void *opt, size_t *dict_size);
|
const void *opt, size_t *dict_size);
|
||||||
|
|
||||||
|
/// Gets memory usage without validating lc/lp/pb. This is used by LZMA2
|
||||||
|
/// decoder, because raw LZMA2 decoding doesn't need lc/lp/pb.
|
||||||
|
extern uint64_t lzma_lzma_decoder_memusage_nocheck(const void *options);
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user