mirror of
https://github.com/ckolivas/lrzip.git
synced 2026-01-03 23:19:56 +01:00
Try limiting stream_read in unzip_literal and just returning how much was read.
This commit is contained in:
parent
9a3bfe33d1
commit
3879807865
14
runzip.c
14
runzip.c
|
|
@ -65,6 +65,7 @@ static i64 read_header(void *ss, uchar *head)
|
|||
|
||||
static i64 unzip_literal(void *ss, i64 len, int fd_out, uint32 *cksum)
|
||||
{
|
||||
i64 stream_read;
|
||||
uchar *buf;
|
||||
|
||||
if (unlikely(len < 0))
|
||||
|
|
@ -74,14 +75,17 @@ static i64 unzip_literal(void *ss, i64 len, int fd_out, uint32 *cksum)
|
|||
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(stream_read == -1 ))
|
||||
fatal("Failed to read_stream in unzip_literal\n");
|
||||
|
||||
*cksum = CrcUpdate(*cksum, 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, stream_read);
|
||||
|
||||
free(buf);
|
||||
return len;
|
||||
return stream_read;
|
||||
}
|
||||
|
||||
static i64 unzip_match(void *ss, i64 len, int fd_out, int fd_hist, uint32 *cksum, int chunk_bytes)
|
||||
|
|
|
|||
2
stream.c
2
stream.c
|
|
@ -1259,7 +1259,7 @@ i64 read_stream(void *ss, int stream, uchar *p, i64 len)
|
|||
while (len) {
|
||||
i64 n;
|
||||
|
||||
n = MIN(sinfo->s[stream].buflen-sinfo->s[stream].bufp, len);
|
||||
n = MIN(sinfo->s[stream].buflen - sinfo->s[stream].bufp, len);
|
||||
|
||||
if (n > 0) {
|
||||
memcpy(p, sinfo->s[stream].buf + sinfo->s[stream].bufp, n);
|
||||
|
|
|
|||
Loading…
Reference in a new issue