Store a copy of the control struct to be reused on subsequent files to prevent variables being modified in the control struct on the first file that

corrupt compression/decompression of the 2nd file.
This commit is contained in:
Con Kolivas 2012-03-07 22:19:14 +11:00
parent 086265c83f
commit dbc71eceb1

13
main.c
View file

@ -57,12 +57,12 @@
/* needed for CRC routines */ /* needed for CRC routines */
#include "lzma/C/7zCrc.h" #include "lzma/C/7zCrc.h"
static rzip_control controlstaticvariablehaha, *control; static rzip_control base_control, local_control, *control;
static void usage(void) static void usage(void)
{ {
print_output("lrzip version %s\n", PACKAGE_VERSION); print_output("lrzip version %s\n", PACKAGE_VERSION);
print_output("Copyright (C) Con Kolivas 2006-2011\n"); print_output("Copyright (C) Con Kolivas 2006-2012\n");
print_output("Based on rzip "); print_output("Based on rzip ");
print_output("Copyright (C) Andrew Tridgell 1998-2003\n\n"); print_output("Copyright (C) Andrew Tridgell 1998-2003\n\n");
print_output("Usage: lrzip [options] <file...>\n"); print_output("Usage: lrzip [options] <file...>\n");
@ -194,7 +194,7 @@ int main(int argc, char *argv[])
extern int optind; extern int optind;
char *eptr; /* for environment */ char *eptr; /* for environment */
control = &controlstaticvariablehaha; control = &base_control;
initialize_control(control); initialize_control(control);
@ -466,12 +466,13 @@ int main(int argc, char *argv[])
if (unlikely(STDIN && ENCRYPT)) if (unlikely(STDIN && ENCRYPT))
failure("Unable to work from STDIN while reading password\n"); failure("Unable to work from STDIN while reading password\n");
memcpy(&local_control, &base_control, sizeof(rzip_control));
if (DECOMPRESS || TEST_ONLY) if (DECOMPRESS || TEST_ONLY)
decompress_file(control); decompress_file(&local_control);
else if (INFO) else if (INFO)
get_fileinfo(control); get_fileinfo(&local_control);
else else
compress_file(control); compress_file(&local_control);
/* compute total time */ /* compute total time */
gettimeofday(&end_time, NULL); gettimeofday(&end_time, NULL);