diff options
author | Lasse Collin <lasse.collin@tukaani.org> | 2009-11-25 14:22:19 +0200 |
---|---|---|
committer | Lasse Collin <lasse.collin@tukaani.org> | 2009-11-25 14:22:19 +0200 |
commit | 919fbaff860acdaa4bcd216500a0b1c960a6db92 (patch) | |
tree | 04d1a8cafb024c5e77dc1fdfef18c6226ac2d2e7 | |
parent | Fix bugs in lzma_index_read() and lzma_index_cat(). (diff) | |
download | xz-919fbaff860acdaa4bcd216500a0b1c960a6db92.tar.xz |
Add missing error check to coder.c.
With bad luck this could cause a segfault due to
reading (but not writing) past the end of the buffer.
-rw-r--r-- | src/xz/coder.c | 20 |
1 files changed, 11 insertions, 9 deletions
diff --git a/src/xz/coder.c b/src/xz/coder.c index d58e7e39..0ab8e467 100644 --- a/src/xz/coder.c +++ b/src/xz/coder.c @@ -617,17 +617,19 @@ coder_run(const char *filename) strm.next_in = in_buf.u8; strm.avail_in = io_read(pair, &in_buf, IO_BUFFER_SIZE); - switch (coder_init(pair)) { - case CODER_INIT_NORMAL: - success = coder_normal(pair); - break; + if (strm.avail_in != SIZE_MAX) { + switch (coder_init(pair)) { + case CODER_INIT_NORMAL: + success = coder_normal(pair); + break; - case CODER_INIT_PASSTHRU: - success = coder_passthru(pair); - break; + case CODER_INIT_PASSTHRU: + success = coder_passthru(pair); + break; - case CODER_INIT_ERROR: - break; + case CODER_INIT_ERROR: + break; + } } message_progress_end(success); |