From: H. Peter Anvin Date: Mon, 1 Jun 2009 05:23:11 +0000 (-0700) Subject: prepcore: actually do a full binary comparison on the output end X-Git-Tag: syslinux-4.00-pre1~57 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=bd64b523111fd75861e1856a459d39de0ecddc48;p=profile%2Fivi%2Fsyslinux.git prepcore: actually do a full binary comparison on the output end Do a full binary comparison between the decompressed output and what we started with. Signed-off-by: H. Peter Anvin --- diff --git a/lzo/prepcore.c b/lzo/prepcore.c index bbf0154..cb6b483 100644 --- a/lzo/prepcore.c +++ b/lzo/prepcore.c @@ -144,6 +144,8 @@ int __lzo_cdecl_main main(int argc, char *argv[]) lzo_uint out_len = 0; lzo_uint outfile_len; + lzo_bytep test; + lzo_byte wrkmem[LZO1X_999_MEM_COMPRESS]; lzo_uint best_len; @@ -330,16 +332,16 @@ int __lzo_cdecl_main main(int argc, char *argv[]) * Step 12: verify decompression */ #ifdef PARANOID - memset(in, 0, in_len); /* paranoia - clear output buffer */ - orig_len = in_len; - r = lzo1x_decompress_safe(out, out_len, in, &orig_len, NULL); + test = calloc(in_len,2); + orig_len = in_len*2; + r = lzo1x_decompress_safe(out, out_len, test, &orig_len, NULL); + if (r != LZO_E_OK || orig_len != in_len) { /* this should NEVER happen */ printf("internal error - decompression failed: %d\n", r); exit(1); } - if (uncompressed_checksum != - lzo_adler32(lzo_adler32(0, NULL, 0), in, in_len)) { + if (memcmp(test, in, in_len)) { /* this should NEVER happen */ printf("internal error - decompression data error\n"); exit(1); @@ -347,6 +349,8 @@ int __lzo_cdecl_main main(int argc, char *argv[]) /* Now you could also verify decompression under similar conditions as in * your application, e.g. overlapping assembler decompression etc. */ + + free(test); #endif free(infile);