mirror of
https://github.com/ckolivas/lrzip.git
synced 2025-12-06 07:12:00 +01:00
Cope with corrupt/crafted archive stream overruns.
This commit is contained in:
parent
3cadc63e39
commit
a81248e47d
3
stream.c
3
stream.c
|
|
@ -1710,6 +1710,7 @@ out:
|
||||||
|
|
||||||
print_maxverbose("Taking decompressed data from thread %ld\n", s->unext_thread);
|
print_maxverbose("Taking decompressed data from thread %ld\n", s->unext_thread);
|
||||||
s->buf = ucthread[s->unext_thread].s_buf;
|
s->buf = ucthread[s->unext_thread].s_buf;
|
||||||
|
ucthread[s->unext_thread].s_buf = NULL;
|
||||||
s->buflen = ucthread[s->unext_thread].u_len;
|
s->buflen = ucthread[s->unext_thread].u_len;
|
||||||
sinfo->ram_alloced -= s->buflen;
|
sinfo->ram_alloced -= s->buflen;
|
||||||
s->bufp = 0;
|
s->bufp = 0;
|
||||||
|
|
@ -1755,6 +1756,8 @@ i64 read_stream(rzip_control *control, void *ss, int streamno, uchar *p, i64 len
|
||||||
n = MIN(s->buflen - s->bufp, len);
|
n = MIN(s->buflen - s->bufp, len);
|
||||||
|
|
||||||
if (n > 0) {
|
if (n > 0) {
|
||||||
|
if (unlikely(!s->buf))
|
||||||
|
failure_return(("Stream ran out prematurely, likely corrupt archive\n"), -1);
|
||||||
memcpy(p, s->buf + s->bufp, n);
|
memcpy(p, s->buf + s->bufp, n);
|
||||||
s->bufp += n;
|
s->bufp += n;
|
||||||
p += n;
|
p += n;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue