From 88d60b324d1affa96a5890bd4525660e0308eb52 Mon Sep 17 00:00:00 2001
From: Thomas Lindroth <thomas.lindroth@gmail.com>
Date: Sat, 15 Feb 2020 17:14:43 -0800
Subject: [PATCH] cseek: reset avail_in/out for cfh->xzs (bug 708736)

Reset avail_in/out for cfh->xzs in order to correct interaction
with the crefill function. This solves a seek error for tarsync
as reported in bug 708736.

Bug: https://bugs.gentoo.org/708736
Signed-off-by: Zac Medico <zmedico@gentoo.org>
---
 libcfile/cfile.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/libcfile/cfile.c b/libcfile/cfile.c
index b8c86e0..f57017c 100644
--- a/libcfile/cfile.c
+++ b/libcfile/cfile.c
@@ -709,6 +709,7 @@ cseek(cfile *cfh, ssize_t offset, int offset_type)
 			if(lzma_stream_decoder(cfh->xzs, UINT64_MAX, LZMA_TELL_UNSUPPORTED_CHECK)!=LZMA_OK) {
 				return IO_ERROR;
 			}
+			cfh->xzs->avail_in = cfh->xzs->avail_out = 0;
 			cfh->raw.pos = cfh->raw.offset = cfh->raw.end = cfh->data.pos =
 				cfh->data.offset = cfh->data.end = 0;
 			if(ensure_lseek_position(cfh)) {
