mirror of
https://git.tukaani.org/xz.git
synced 2025-12-12 00:18:45 +00:00
liblzma: Silence two Coverity warnings
lzma_lzma_decoder_memusage() returns UINT64_MAX if lc/lp/pb aren't valid. alone_decoder.c and lzip_decoder.c didn't check the return value because in both it is known that lc/lp/pb are valid. Make them call the _nocheck() variant instead which skips the validation (it already existed for LZMA2's internal use). Fixes: Coverity CID 464658 Fixes: Coverity CID 897069
This commit is contained in:
parent
be365b7010
commit
90b67853d5
@ -128,8 +128,10 @@ alone_decode(void *coder_ptr, const lzma_allocator *allocator,
|
|||||||
lzma_set_ext_size(coder->options, coder->uncompressed_size);
|
lzma_set_ext_size(coder->options, coder->uncompressed_size);
|
||||||
|
|
||||||
// Calculate the memory usage so that it is ready
|
// Calculate the memory usage so that it is ready
|
||||||
// for SEQ_CODER_INIT.
|
// for SEQ_CODER_INIT. We know that lc/lp/pb are valid
|
||||||
coder->memusage = lzma_lzma_decoder_memusage(&coder->options)
|
// so we can use the _nocheck variant.
|
||||||
|
coder->memusage
|
||||||
|
= lzma_lzma_decoder_memusage_nocheck(&coder->options)
|
||||||
+ LZMA_MEMUSAGE_BASE;
|
+ LZMA_MEMUSAGE_BASE;
|
||||||
|
|
||||||
coder->pos = 0;
|
coder->pos = 0;
|
||||||
|
|||||||
@ -212,7 +212,8 @@ lzip_decode(void *coder_ptr, const lzma_allocator *allocator,
|
|||||||
coder->options.pb = LZIP_PB;
|
coder->options.pb = LZIP_PB;
|
||||||
|
|
||||||
// Calculate the memory usage.
|
// Calculate the memory usage.
|
||||||
coder->memusage = lzma_lzma_decoder_memusage(&coder->options)
|
coder->memusage
|
||||||
|
= lzma_lzma_decoder_memusage_nocheck(&coder->options)
|
||||||
+ LZMA_MEMUSAGE_BASE;
|
+ LZMA_MEMUSAGE_BASE;
|
||||||
|
|
||||||
// Initialization is a separate step because if we return
|
// Initialization is a separate step because if we return
|
||||||
|
|||||||
@ -23,6 +23,12 @@ extern lzma_ret lzma_lzma_decoder_init(lzma_next_coder *next,
|
|||||||
|
|
||||||
extern uint64_t lzma_lzma_decoder_memusage(const void *options);
|
extern uint64_t lzma_lzma_decoder_memusage(const void *options);
|
||||||
|
|
||||||
|
/// Gets memory usage without validating lc/lp/pb. This is used by LZMA2
|
||||||
|
/// decoder, because raw LZMA2 decoding doesn't need lc/lp/pb. Also
|
||||||
|
/// alone_decoder.c and lzip_decoder.c use this because there lc/lp/pb
|
||||||
|
/// are known to be valid.
|
||||||
|
extern uint64_t lzma_lzma_decoder_memusage_nocheck(const void *options);
|
||||||
|
|
||||||
extern lzma_ret lzma_lzma_props_decode(
|
extern lzma_ret lzma_lzma_props_decode(
|
||||||
void **options, const lzma_allocator *allocator,
|
void **options, const lzma_allocator *allocator,
|
||||||
const uint8_t *props, size_t props_size);
|
const uint8_t *props, size_t props_size);
|
||||||
@ -42,11 +48,6 @@ extern bool lzma_lzma_lclppb_decode(
|
|||||||
extern lzma_ret lzma_lzma_decoder_create(
|
extern lzma_ret lzma_lzma_decoder_create(
|
||||||
lzma_lz_decoder *lz, const lzma_allocator *allocator,
|
lzma_lz_decoder *lz, const lzma_allocator *allocator,
|
||||||
const lzma_options_lzma *opt, lzma_lz_options *lz_options);
|
const lzma_options_lzma *opt, lzma_lz_options *lz_options);
|
||||||
|
|
||||||
/// 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…
x
Reference in New Issue
Block a user