aboutsummaryrefslogtreecommitdiff
path: root/src/xz/coder.c
diff options
context:
space:
mode:
authorLasse Collin <lasse.collin@tukaani.org>2018-12-14 20:34:30 +0200
committerLasse Collin <lasse.collin@tukaani.org>2019-07-13 17:37:55 +0300
commit3ca432d9cce4bf7e793de173dd22025b68611c42 (patch)
treed2e9f555b6500ea9fa63404bb80e386abf770bb4 /src/xz/coder.c
parentxz: Update man page timestamp. (diff)
downloadxz-3ca432d9cce4bf7e793de173dd22025b68611c42.tar.xz
xz: Fix a crash in progress indicator when in passthru mode.
"xz -dcfv not_an_xz_file" crashed (all four options are required to trigger it). It caused xz to call lzma_get_progress(&strm, ...) when no coder was initialized in strm. In this situation strm.internal is NULL which leads to a crash in lzma_get_progress(). The bug was introduced when xz started using lzma_get_progress() to get progress info for multi-threaded compression, so the bug is present in versions 5.1.3alpha and higher. Thanks to Filip Palian <Filip.Palian@pjwstk.edu.pl> for the bug report.
Diffstat (limited to 'src/xz/coder.c')
-rw-r--r--src/xz/coder.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/src/xz/coder.c b/src/xz/coder.c
index 3c6a01cb..f36d1bf2 100644
--- a/src/xz/coder.c
+++ b/src/xz/coder.c
@@ -902,16 +902,19 @@ coder_run(const char *filename)
mytime_set_start_time();
// Initialize the progress indicator.
+ const bool is_passthru = init_ret
+ == CODER_INIT_PASSTHRU;
const uint64_t in_size
= pair->src_st.st_size <= 0
? 0 : pair->src_st.st_size;
- message_progress_start(&strm, in_size);
+ message_progress_start(&strm,
+ is_passthru, in_size);
// Do the actual coding or passthru.
- if (init_ret == CODER_INIT_NORMAL)
- success = coder_normal(pair);
- else
+ if (is_passthru)
success = coder_passthru(pair);
+ else
+ success = coder_normal(pair);
message_progress_end(success);
}