mirror of
https://github.com/ckolivas/lrzip.git
synced 2025-12-06 07:12:00 +01:00
Update magic header info.
Move offset check to after reading chunk width. Realloc instead of free and malloc.
This commit is contained in:
parent
1ed2ce423f
commit
49336a5e87
|
|
@ -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
|
lrzip-0.40+ file header format
|
||||||
November 2009
|
November 2009
|
||||||
Con Kolivas
|
Con Kolivas
|
||||||
|
|
|
||||||
18
runzip.c
18
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];
|
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
|
/* 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
|
* bytes for all offsets, version 0.4 used 8 bytes. Versions 0.5+ use
|
||||||
* a variable number of bytes depending on chunk size.*/
|
* 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)
|
if (read(fd_in, &chunk_bytes, 1) != 1)
|
||||||
fatal("Failed to read chunk_bytes size in runzip_chunk\n");
|
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);
|
ss = open_stream_in(fd_in, NUM_STREAMS);
|
||||||
if (!ss)
|
if (!ss)
|
||||||
|
|
|
||||||
2
rzip.c
2
rzip.c
|
|
@ -629,7 +629,7 @@ void rzip_fd(int fd_in, int fd_out)
|
||||||
chunk = len;
|
chunk = len;
|
||||||
limit = chunk;
|
limit = chunk;
|
||||||
st->chunk_size = 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
|
/* Determine the chunk byte width and write it to the file
|
||||||
* This allows archives of different chunk sizes to have
|
* This allows archives of different chunk sizes to have
|
||||||
|
|
|
||||||
5
stream.c
5
stream.c
|
|
@ -796,10 +796,9 @@ static int flush_buffer(struct stream_info *sinfo, int stream)
|
||||||
|
|
||||||
sinfo->s[stream].buflen = 0;
|
sinfo->s[stream].buflen = 0;
|
||||||
|
|
||||||
free(sinfo->s[stream].buf);
|
sinfo->s[stream].buf = realloc(sinfo->s[stream].buf, sinfo->bufsize);
|
||||||
sinfo->s[stream].buf = malloc(sinfo->bufsize);
|
|
||||||
if (!sinfo->s[stream].buf)
|
if (!sinfo->s[stream].buf)
|
||||||
fatal("Failed to malloc in flush_buffer\n");
|
fatal("Failed to realloc in flush_buffer\n");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue