[coreboot-gerrit] New patch to review for coreboot: da6a694 cbfstool: completely initialize input and output streams

Stefan Reinauer (stefan.reinauer@coreboot.org) gerrit at coreboot.org
Mon Apr 8 20:24:46 CEST 2013

Stefan Reinauer (stefan.reinauer at coreboot.org) just uploaded a new patch set to gerrit, which you can find at http://review.coreboot.org/3040


commit da6a69416014e34d1d8ed799841ac8727d592487
Author: Stefan Reinauer <reinauer at chromium.org>
Date:   Mon Apr 8 11:20:55 2013 -0700

    cbfstool: completely initialize input and output streams
    The LZMA glue code in cbfstool was recently rewritten from C++
    to plain C code in:
            commit aa3f7ba36ebe3a933aa664f826382f60b31e86f1
            Author: Stefan Reinauer <reinauer at chromium.org>
            Date:   Thu Mar 28 16:51:45 2013 -0700
                cbfstool: Replace C++ code with C code
                Reviewed-on: http://review.coreboot.org/3010
    In the progress of doing so, the stream position for the
    input stream and output stream was not reset properly. This
    would cause LZMA producing corrupt data when running the
    compression function multiple times.
    Change-Id: I096e08f263aaa1931517885be4610bbd1de8331e
    Signed-off-by: Stefan Reinauer <reinauer at google.com>
 util/cbfstool/lzma/lzma.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/util/cbfstool/lzma/lzma.c b/util/cbfstool/lzma/lzma.c
index 914d8b7..579784e 100644
--- a/util/cbfstool/lzma/lzma.c
+++ b/util/cbfstool/lzma/lzma.c
@@ -61,7 +61,7 @@ static ISzAlloc LZMAalloc = { SzAlloc, SzFree };
 /* Streaming API */
-typedef struct vector {
+typedef struct {
 	char *p;
 	size_t pos;
 	size_t size;
@@ -147,9 +147,11 @@ void do_lzma_compress(char *in, int in_len, char *out, int *out_len)
 	instream.p = in;
+	instream.pos = 0;
 	instream.size = in_len;
 	outstream.p = out;
+	outstream.pos = 0;
 	outstream.size = in_len;
 	put_64(propsEncoded + LZMA_PROPS_SIZE, in_len);

More information about the coreboot-gerrit mailing list