diff --git a/lrzip.c b/lrzip.c index 8fcdc0a..a6ad4a0 100644 --- a/lrzip.c +++ b/lrzip.c @@ -57,7 +57,10 @@ void write_magic(rzip_control *control, int fd_in, int fd_out) if (unlikely(fstat(fd_in, &st))) fatal("bad magic file descriptor!?\n"); - memcpy(&magic[6], &control->st_size, 8); + /* File size is stored as zero for streaming STDOUT blocks when the + * file size is unknown. */ + if (!STDIN || !STDOUT || control->eof) + memcpy(&magic[6], &control->st_size, 8); /* save LZMA compression flags */ if (LZMA_COMPRESS) { diff --git a/lrzip_private.h b/lrzip_private.h index 9935ee6..bff5b2f 100644 --- a/lrzip_private.h +++ b/lrzip_private.h @@ -180,6 +180,7 @@ struct rzip_control { int encrypt; i64 secs; i64 usecs; + int eof; md5_ctx ctx; i64 md5_read; // How far into the file the md5 has done so far }; diff --git a/rzip.c b/rzip.c index febe7c7..15bc752 100644 --- a/rzip.c +++ b/rzip.c @@ -694,7 +694,7 @@ static void mmap_stdin(rzip_control *control, uchar *buf, struct rzip_state *st) if (unlikely(buf == MAP_FAILED)) fatal("Failed to remap to smaller buf in mmap_stdin\n"); st->mmap_size = st->chunk_size = total; - st->stdin_eof = 1; + control->eof = st->stdin_eof = 1; break; } offset_buf += ret;