mirror of
https://github.com/ckolivas/lrzip.git
synced 2025-12-06 07:12:00 +01:00
Make sure to read the full length asked of unzip_literal.
This commit is contained in:
parent
0a32b5f72d
commit
499ae18cef
21
runzip.c
21
runzip.c
|
|
@ -65,23 +65,30 @@ static i64 read_header(void *ss, uchar *head)
|
|||
|
||||
static i64 unzip_literal(void *ss, i64 len, int fd_out, uint32 *cksum)
|
||||
{
|
||||
i64 ret = 0;
|
||||
uchar *buf;
|
||||
|
||||
if (unlikely(len < 0))
|
||||
fatal("len %lld is negative in unzip_literal!\n", len);
|
||||
|
||||
buf = malloc(len);
|
||||
while (len > 0) {
|
||||
i64 stream_read;
|
||||
|
||||
buf = (uchar *)malloc(len);
|
||||
if (unlikely(!buf))
|
||||
fatal("Failed to malloc literal buffer of size %lld\n", len);
|
||||
|
||||
read_stream(ss, 1, buf, len);
|
||||
if (unlikely(write_1g(fd_out, buf, (size_t)len) != (ssize_t)len))
|
||||
fatal("Failed to write literal buffer of size %lld\n", len);
|
||||
stream_read = read_stream(ss, 1, buf, len);
|
||||
if (unlikely(write_1g(fd_out, buf, (size_t)stream_read) != (ssize_t)stream_read))
|
||||
fatal("Failed to write literal buffer of size %lld\n", stream_read);
|
||||
|
||||
*cksum = CrcUpdate(*cksum, buf, len);
|
||||
*cksum = CrcUpdate(*cksum, buf, stream_read);
|
||||
|
||||
free(buf);
|
||||
return len;
|
||||
len -= stream_read;
|
||||
ret += stream_read;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
static i64 unzip_match(void *ss, i64 len, int fd_out, int fd_hist, uint32 *cksum, int chunk_bytes)
|
||||
|
|
@ -106,7 +113,7 @@ static i64 unzip_match(void *ss, i64 len, int fd_out, int fd_hist, uint32 *cksum
|
|||
uchar *buf;
|
||||
n = MIN(len, offset);
|
||||
|
||||
buf = malloc(n);
|
||||
buf = (uchar *)malloc(n);
|
||||
if (unlikely(!buf))
|
||||
fatal("Failed to malloc match buffer of size %lld\n", n);
|
||||
|
||||
|
|
|
|||
2
stream.c
2
stream.c
|
|
@ -1271,7 +1271,7 @@ i64 read_stream(void *ss, int stream, uchar *p, i64 len)
|
|||
|
||||
if (len && sinfo->s[stream].bufp == sinfo->s[stream].buflen) {
|
||||
if (unlikely(fill_buffer(sinfo, stream)))
|
||||
return -1;
|
||||
fatal("Failed to fill_buffer from read_stream\n");
|
||||
if (sinfo->s[stream].bufp == sinfo->s[stream].buflen)
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue