diff --git a/doc/magic.header.txt b/doc/magic.header.txt index 4f3d6f4..40c1949 100644 --- a/doc/magic.header.txt +++ b/doc/magic.header.txt @@ -1,3 +1,29 @@ +lrzip-0.50+ file header format +November 2010 +Con Kolivas + +Byte Content +0-3 LRZI +4 LRZIP Major Version Number +5 LRZIP Minor Version Number +6-14 Source File Size +16-20 LZMA Properties Encoded (lc,lp,pb,fb, and dictionary size) +21-22 not used +23-48 Stream 1 header data +49-74 Stream 2 header data + +Block Data: +Byte: +0 Compressed data type +1-8 Compressed data length +9-16 Uncompressed data length +17-24 Next block head +25 Data offsets byte width +26+ Data + +End: +0-1 crc data + lrzip-0.40+ file header format November 2009 Con Kolivas diff --git a/runzip.c b/runzip.c index d3a8703..d12c319 100644 --- a/runzip.c +++ b/runzip.c @@ -159,13 +159,6 @@ static i64 runzip_chunk(int fd_in, int fd_out, int fd_hist, i64 expected_size, i prog_tsize = (long double)expected_size / (long double)divisor[divisor_index]; - ofs = lseek(fd_in, 0, SEEK_CUR); - if (ofs == -1) - fatal("Failed to seek input file in runzip_fd\n"); - - if (fstat(fd_in, &st) != 0 || st.st_size-ofs == 0) - return 0; - /* Determine the chunk_byte width size. Versions < 0.4 used 4 * bytes for all offsets, version 0.4 used 8 bytes. Versions 0.5+ use * a variable number of bytes depending on chunk size.*/ @@ -178,7 +171,16 @@ static i64 runzip_chunk(int fd_in, int fd_out, int fd_hist, i64 expected_size, i if (read(fd_in, &chunk_bytes, 1) != 1) fatal("Failed to read chunk_bytes size in runzip_chunk\n"); } - print_maxverbose("\nExpected size: %lld\nChunk byte width: %d\n", expected_size, chunk_bytes); + if (!tally) + print_maxverbose("\nExpected size: %lld", expected_size); + print_maxverbose("\nChunk byte width: %d\n", chunk_bytes); + + ofs = lseek(fd_in, 0, SEEK_CUR); + if (ofs == -1) + fatal("Failed to seek input file in runzip_fd\n"); + + if (fstat(fd_in, &st) != 0 || st.st_size-ofs == 0) + return 0; ss = open_stream_in(fd_in, NUM_STREAMS); if (!ss) diff --git a/rzip.c b/rzip.c index da39f62..ceaa289 100644 --- a/rzip.c +++ b/rzip.c @@ -629,7 +629,7 @@ void rzip_fd(int fd_in, int fd_out) chunk = len; limit = chunk; st->chunk_size = chunk; - print_maxverbose("Chunk size: %lld\n\n", chunk); + print_maxverbose("Chunk size: %lld\n", chunk); /* Determine the chunk byte width and write it to the file * This allows archives of different chunk sizes to have diff --git a/stream.c b/stream.c index 6580412..b97362f 100644 --- a/stream.c +++ b/stream.c @@ -796,10 +796,9 @@ static int flush_buffer(struct stream_info *sinfo, int stream) sinfo->s[stream].buflen = 0; - free(sinfo->s[stream].buf); - sinfo->s[stream].buf = malloc(sinfo->bufsize); + sinfo->s[stream].buf = realloc(sinfo->s[stream].buf, sinfo->bufsize); if (!sinfo->s[stream].buf) - fatal("Failed to malloc in flush_buffer\n"); + fatal("Failed to realloc in flush_buffer\n"); return 0; }