From: Lasse Collin Date: Wed, 25 Nov 2009 12:22:19 +0000 (+0200) Subject: Add missing error check to coder.c. X-Git-Tag: upstream/5.1.3~384 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=919fbaff860acdaa4bcd216500a0b1c960a6db92;p=platform%2Fupstream%2Fxz.git 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. --- diff --git a/src/xz/coder.c b/src/xz/coder.c index d58e7e3..0ab8e46 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);