From 7f9ca7c4d29183ad1cdb99080095e1354c7946fe Mon Sep 17 00:00:00 2001 From: "mark@chromium.org" Date: Tue, 22 Jun 2010 22:31:38 +0000 Subject: Emergency goobsdiff patch: don't use LZMA_RUN after LZMA_FINISH. In testing, cases were discovered where fread would read until EOF, but lzma_code would not be able to decompress that entire block in one call because not enough space was available in the output buffer. Calling lzma_code with LZMA_FINISH followed by LZMA_RUN is incorrect. Once LZMA_FINISH is used once, subsequent calls to lzma_code must also use LZMA_FINISH. From : * After the first use of LZMA_SYNC_FLUSH, LZMA_FULL_FLUSH, or LZMA_FINISH, * the same `action' must is used until lzma_code() returns LZMA_STREAM_END. * Also, the amount of input (that is, strm->avail_in) must not be modified * by the application until lzma_code() returns LZMA_STREAM_END. Changing the * `action' or modifying the amount of input will make lzma_code() return * LZMA_PROG_ERROR. This bug caused goobspatch to exit prematurely with a message like goobspatch: xzread(extra, 216): 11 11 is LZMA_PROG_ERROR. BUG=47199 TEST=none Review URL: http://codereview.chromium.org/2875008 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@50537 0039d316-1c4b-4281-b951-d872f2087c98 --- chrome/installer/mac/third_party/bsdiff/goobspatch.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'chrome/installer/mac') diff --git a/chrome/installer/mac/third_party/bsdiff/goobspatch.c b/chrome/installer/mac/third_party/bsdiff/goobspatch.c index 385b081..5287825 100644 --- a/chrome/installer/mac/third_party/bsdiff/goobspatch.c +++ b/chrome/installer/mac/third_party/bsdiff/goobspatch.c @@ -194,9 +194,6 @@ static size_t xzread(xzfile *xzf, u_char *buf, size_t len, lzma_ret *err) return 0; } else if (feof(xzf->f)) { xzf->eof = 1; - /* LZMA_FINISH is not critical because - * LZMA_CONCATENATED is not in use. */ - action = LZMA_FINISH; } } @@ -211,6 +208,11 @@ static size_t xzread(xzfile *xzf, u_char *buf, size_t len, lzma_ret *err) return 0; } + /* LZMA_FINISH is not critical because + * LZMA_CONCATENATED is not in use. */ + if (xzf->eof) + action = LZMA_FINISH; + /* Run the decoder. */ xzf->err = lzma_code(&xzf->ls, action); if (xzf->err == LZMA_STREAM_END) { -- cgit v1.1