diff options
author | Tor Andersson <tor.andersson@artifex.com> | 2018-11-07 16:58:56 +0100 |
---|---|---|
committer | Tor Andersson <tor.andersson@artifex.com> | 2018-11-07 17:00:00 +0100 |
commit | 11c3e6e574f74981459a6401b7d8cd4773f67cc4 (patch) | |
tree | f8a3a4e0b6eb5dcc91428796d09e343ba20e87d3 /source/fitz/stream-read.c | |
parent | 9e604ba1b8f05e94c177266cb7bdf3d2a01b529c (diff) | |
download | mupdf-11c3e6e574f74981459a6401b7d8cd4773f67cc4.tar.xz |
Make compression bomb detection optional.
Diffstat (limited to 'source/fitz/stream-read.c')
-rw-r--r-- | source/fitz/stream-read.c | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/source/fitz/stream-read.c b/source/fitz/stream-read.c index 1a2bda01..9eff8722 100644 --- a/source/fitz/stream-read.c +++ b/source/fitz/stream-read.c @@ -59,6 +59,7 @@ fz_buffer * fz_read_best(fz_context *ctx, fz_stream *stm, size_t initial, int *truncated) { fz_buffer *buf = NULL; + int check_bomb = (initial > 0); size_t n; fz_var(buf); @@ -78,10 +79,8 @@ fz_read_best(fz_context *ctx, fz_stream *stm, size_t initial, int *truncated) if (buf->len == buf->cap) fz_grow_buffer(ctx, buf); - if (buf->len >= MIN_BOMB && buf->len / 200 > initial) - { + if (check_bomb && buf->len >= MIN_BOMB && buf->len / 200 > initial) fz_throw(ctx, FZ_ERROR_GENERIC, "compression bomb detected"); - } n = fz_read(ctx, stm, buf->data + buf->len, buf->cap - buf->len); if (n == 0) |