Fix possible race condition between zpaq_decompress_buf() and clear_rulist() function as reported by wcventure.

This commit is contained in:
Con Kolivas 2022-02-26 10:11:49 +11:00
parent 23407bc8f7
commit 4b3942103b
3 changed files with 9 additions and 6 deletions

View file

@ -842,8 +842,14 @@ bool decompress_file(rzip_control *control)
print_progress("Decompressing...\n");
if (unlikely(runzip_fd(control, fd_in, fd_out, fd_hist, expected_size) < 0))
if (unlikely(runzip_fd(control, fd_in, fd_out, fd_hist, expected_size) < 0)) {
clear_rulist(control);
return false;
}
/* We can now safely delete sinfo and pthread data of all threads
* created. */
clear_rulist(control);
if (STDOUT && !TMP_OUTBUF) {
if (unlikely(!dump_tmpoutfile(control, fd_out)))

View file

@ -249,7 +249,7 @@ static i64 unzip_match(rzip_control *control, void *ss, i64 len, uint32 *cksum,
return total;
}
static void clear_rulist(rzip_control *control)
void clear_rulist(rzip_control *control)
{
while (control->ruhead) {
struct runzip_node *node = control->ruhead;
@ -381,10 +381,6 @@ static i64 runzip_chunk(rzip_control *control, int fd_in, i64 expected_size, i64
if (unlikely(close_stream_in(control, ss)))
fatal("Failed to close stream!\n");
/* We can now safely delete sinfo and pthread data of all threads
* created. */
clear_rulist(control);
return total;
}

View file

@ -22,6 +22,7 @@
#include "lrzip_private.h"
void clear_rulist(rzip_control *control);
i64 runzip_fd(rzip_control *control, int fd_in, int fd_out, int fd_hist, i64 expected_size);
#endif