mirror of https://git.tukaani.org/xz.git
Return LZMA_HEADER_ERROR if LZMA_SYNC_FLUSH is used with any
of the so called simple filters. If there is demand, limited support for LZMA_SYNC_FLUSH may be added in future. After this commit, using LZMA_SYNC_FLUSH shouldn't cause undefined behavior in any situation.
This commit is contained in:
parent
e988ea1d1a
commit
f9842f7127
|
@ -64,6 +64,15 @@
|
||||||
*
|
*
|
||||||
* If options with non-default values have been specified when encoding,
|
* If options with non-default values have been specified when encoding,
|
||||||
* the same options must also be specified when decoding.
|
* the same options must also be specified when decoding.
|
||||||
|
*
|
||||||
|
* \note At the moment, none of the simple filters support
|
||||||
|
* LZMA_SYNC_FLUSH. If LZMA_SYNC_FLUSH is specified,
|
||||||
|
* LZMA_HEADER_ERROR will be returned. If there is need,
|
||||||
|
* partial support for LZMA_SYNC_FLUSH can be added in future.
|
||||||
|
* Partial means that flushing would be possible only at
|
||||||
|
* offsets that are multiple of 2, 4, or 16 depending on
|
||||||
|
* the filter, except x86 which cannot be made to support
|
||||||
|
* LZMA_SYNC_FLUSH predictably.
|
||||||
*/
|
*/
|
||||||
typedef struct {
|
typedef struct {
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -101,6 +101,14 @@ simple_code(lzma_coder *coder, lzma_allocator *allocator,
|
||||||
size_t in_size, uint8_t *restrict out,
|
size_t in_size, uint8_t *restrict out,
|
||||||
size_t *restrict out_pos, size_t out_size, lzma_action action)
|
size_t *restrict out_pos, size_t out_size, lzma_action action)
|
||||||
{
|
{
|
||||||
|
// TODO: Add partial support for LZMA_SYNC_FLUSH. We can support it
|
||||||
|
// in cases when the filter is able to filter everything. With most
|
||||||
|
// simple filters it can be done at offset that is a multiple of 2,
|
||||||
|
// 4, or 16. With x86 filter, it needs good luck, and thus cannot
|
||||||
|
// be made to work predictably.
|
||||||
|
if (action == LZMA_SYNC_FLUSH)
|
||||||
|
return LZMA_HEADER_ERROR;
|
||||||
|
|
||||||
// Flush already filtered data from coder->buffer[] to out[].
|
// Flush already filtered data from coder->buffer[] to out[].
|
||||||
if (coder->pos < coder->filtered) {
|
if (coder->pos < coder->filtered) {
|
||||||
bufcpy(coder->buffer, &coder->pos, coder->filtered,
|
bufcpy(coder->buffer, &coder->pos, coder->filtered,
|
||||||
|
|
Loading…
Reference in New Issue