This commit is contained in:
Con Kolivas 2016-06-09 18:18:14 +10:00
parent 2021d5e862
commit 32c7fa82a2

24
lrzip.c
View file

@ -788,9 +788,10 @@ bool decompress_file(rzip_control *control)
if (unlikely(!open_tmpoutbuf(control))) if (unlikely(!open_tmpoutbuf(control)))
return false; return false;
if (!STDIN) if (!STDIN) {
if (unlikely(!read_magic(control, fd_in, &expected_size))) if (unlikely(!read_magic(control, fd_in, &expected_size)))
return false; return false;
}
if (!STDOUT && !TEST_ONLY) { if (!STDOUT && !TEST_ONLY) {
/* Check if there's enough free space on the device chosen to fit the /* Check if there's enough free space on the device chosen to fit the
@ -960,7 +961,8 @@ bool get_fileinfo(rzip_control *control)
infile_size = st.st_size; infile_size = st.st_size;
/* Get decompressed size */ /* Get decompressed size */
if (unlikely(!read_magic(control, fd_in, &expected_size))) goto error; if (unlikely(!read_magic(control, fd_in, &expected_size)))
goto error;
if (ENCRYPT) { if (ENCRYPT) {
print_output("Encrypted lrzip archive. No further information available\n"); print_output("Encrypted lrzip archive. No further information available\n");
@ -1220,10 +1222,14 @@ bool compress_file(rzip_control *control)
fatal_goto(("Failed to create %s\n", control->outfile), error); fatal_goto(("Failed to create %s\n", control->outfile), error);
} }
control->fd_out = fd_out; control->fd_out = fd_out;
if (!STDIN) if (!STDIN) {
if (unlikely(!preserve_perms(control, fd_in, fd_out))) goto error; if (unlikely(!preserve_perms(control, fd_in, fd_out)))
} else goto error;
if (unlikely(!open_tmpoutbuf(control))) goto error; }
} else {
if (unlikely(!open_tmpoutbuf(control)))
goto error;
}
/* Write zeroes to header at beginning of file */ /* Write zeroes to header at beginning of file */
if (unlikely(!STDOUT && write(fd_out, header, sizeof(header)) != sizeof(header))) if (unlikely(!STDOUT && write(fd_out, header, sizeof(header)) != sizeof(header)))
@ -1232,8 +1238,10 @@ bool compress_file(rzip_control *control)
rzip_fd(control, fd_in, fd_out); rzip_fd(control, fd_in, fd_out);
/* Wwrite magic at end b/c lzma does not tell us properties until it is done */ /* Wwrite magic at end b/c lzma does not tell us properties until it is done */
if (!STDOUT) if (!STDOUT) {
if (unlikely(!write_magic(control))) goto error; if (unlikely(!write_magic(control)))
goto error;
}
if (ENCRYPT) if (ENCRYPT)
release_hashes(control); release_hashes(control);