Skip to content

Commit

Permalink
Patched grave error at build_index() when EXTRACT_FROM_BYTE:
Browse files Browse the repository at this point in the history
WRONG DATA (with correct size) WAS EXTRACTED!
  • Loading branch information
circulosmeos committed Aug 18, 2019
1 parent 6cc95bd commit e1e73b5
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ Copy gztool.c to the directory where you compiled zlib, and do:
Usage
=====

gztool (v0.4)
gztool (v0.4.1)
GZIP files indexer and data retriever.
Create small indexes for gzipped files and use them
for quick and random positioned data extraction.
Expand Down Expand Up @@ -244,7 +244,7 @@ Other tools which try to provide random access to gzipped files
Version
=======

This version is **v0.4**.
This version is **v0.4.1**.

Please, read the *Disclaimer*. This is still a beta release. In case of any errors, please open an *Issue*.

Expand Down
8 changes: 4 additions & 4 deletions gztool.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
//
// LICENSE:
//
// v0.1, v0.2, v0.3.*, v0.4 by Roberto S. Galende, 2019
// v0.1, v0.2, v0.3.*, v0.4.* by Roberto S. Galende, 2019
// //github.com/circulosmeos/gztool
// A work by Roberto S. Galende
// distributed under the same License terms covering
Expand Down Expand Up @@ -1298,7 +1298,6 @@ local struct returned_output build_index(
// EXTRACT_FROM_BYTE: extract all:
if ( indx_n_extraction_opts == EXTRACT_FROM_BYTE ) {
unsigned have = avail_out_0 - strm.avail_out;
avail_out_0 = strm.avail_out;
printToStderr( VERBOSITY_MANIAC, ">1> %ld, %d, %d ", offset, have, strm.avail_out );
if ( offset > have ) {
offset -= have;
Expand All @@ -1308,7 +1307,7 @@ local struct returned_output build_index(
// print offset - have bytes
// If offset==0 (from offset byte on) this prints always all bytes:
output_data_counter += have - offset;
if (fwrite(window + offset, 1, have - offset, stdout) != (have - offset) ||
if (fwrite(window + offset + (WINSIZE - avail_out_0), 1, have - offset, stdout) != (have - offset) ||
ferror(stdout)) {
(void)inflateEnd(&strm);
ret.error = Z_ERRNO;
Expand All @@ -1318,6 +1317,7 @@ local struct returned_output build_index(
fflush(stdout);
}
}
avail_out_0 = strm.avail_out;
} else {
// continue_extraction in practice marks the use of "offset_in"
if ( continue_extraction == 1 ) {
Expand Down Expand Up @@ -2189,7 +2189,7 @@ uint64_t giveMeAnInteger( const unsigned char *original_input ) {
local void print_help() {

fprintf( stderr, "\n" );
fprintf( stderr, " gztool (v0.4)\n");
fprintf( stderr, " gztool (v0.4.1)\n");
fprintf( stderr, " GZIP files indexer and data retriever.\n" );
fprintf( stderr, " Create small indexes for gzipped files and use them\n" );
fprintf( stderr, " for quick and random positioned data extraction.\n" );
Expand Down

0 comments on commit e1e73b5

Please sign in to comment.