8000 RFC 1952 support added (v2) by robang74 · Pull Request #405 · richgel999/miniz · GitHub
[go: up one dir, main page]

Skip to content

RFC 1952 support added (v2) - #405

Open
robang74 wants to merge 15 commits into
richgel999:masterfrom
robang74:rfc1952.pr2
Open

robang74 wants to merge 15 commits into
richgel999:masterfrom
robang74:rfc1952.pr2

Conversation

@robang74
@robang74 robang74 commented Nov 23, 2026 •
Copy link
Copy Markdown
Contributor

RFC 1952 support added (v2)

RFC 1952 support added, it does not include the filename and the date/time of the archive creation. Apart from these two details, which is "gzip legit" to skip, it seems to be working. The v2 is better organised and based on the last HEAD (at the time of updating the patchset into the second version).

The git commit of the part n.4 shows which are the open topic about adding RFC 1952 to miniz. Therefore this PR couldn't be considered completed but in a good shape for another round of testing and refinement. The TODO n.1 is on me, and I hope someone in the meantime would suggest how to deal with that nasty warning. Which happens in a specific case, therefore is less straightforward to face.

    RFC-1952: implementation, part #4 (v2)
    
    - miniz.c,.h,miniz_zip.c: fixing amalgamation.sh not-blocking bugs
    - miniz_tinfl.c: lazy initialisation to explict zero
    
    DONE #1: miniz_zip.c, read zip64 extended information field into comp_size
    
    -------------------------------------------------------------------------------
    Zip reader zip64 local header offset out of bounds
    -------------------------------------------------------------------------------
    /home/roberto/robang74/miniz/tests/main.cpp:415
    ...................................................
8000
............................
    
    /home/roberto/robang74/miniz/tests/main.cpp:439: FAILED:
      REQUIRE( mz_zip_reader_init_mem(&zip, archive, sizeof(archive), 0) )
    with expansion:
      0
    
    ===============================================================================
    test cases:     10 |      9 passed | 1 failed
    assertions: 134735 | 134734 passed | 1 failed
    
    TODO #1: repeat the tests with 'pgunzip' that created the event for this patch.
    
    TODO #2: not investigated, yet
    
    [ 13%] Building C object CMakeFiles/miniz.dir/miniz_tinfl.c.o
    /usr/bin/cc -D_GNU_SOURCE -I/home/roberto/robang74/miniz
    -I/home/roberto/robang74/miniz/build -Wshadow -Wformat=2
    -Wall -Wno-overlength-strings -pedantic -O3 -DNDEBUG
    -std=gnu90 -MD -MT CMakeFiles/miniz.dir/miniz_tinfl.c.o
    -MF CMakeFiles/miniz.dir/miniz_tinfl.c.o.d
    -o CMakeFiles/miniz.dir/miniz_tinfl.c.o
    -c /home/roberto/robang74/miniz/miniz_tinfl.c
    /home/roberto/robang74/miniz/miniz_tinfl.c: In function ‘tinfl_decompress’:
    /home/roberto/robang74/miniz/miniz_tinfl.c:705:28: warning: ‘crc32’
          may be used uninitialized in this function [-Wmaybe-uninitialized]
      705 |             r->m_z_adler32 = crc32;
          |             ~~~~~~~~~~~~~~~^~~~~~~
    /home/roberto/robang74/miniz/miniz_tinfl.c:235:22: warning: ‘flg’
          may be used uninitialized in this function [-Wmaybe-uninitialized]
      235 |             mz_uint8 flg = 0;
          |                      ^~~
    /home/roberto/robang74/miniz/miniz_tinfl.c:273:28: warning: ‘xlen’
          may be used uninitialized in this function [-Wmaybe-uninitialized]
      273 |                 while (xlen--)
          |

Signed-off-by: Roberto A. Foglietta <roberto.foglietta@gmail.com>
Signed-off-by: Roberto A. Foglietta <roberto.foglietta@gmail.com>
Required functions are definited into miniz_zip.c but only within:

The isse emerges when appling the "RFC-1952 implementation" patchset.

Signed-off-by: Roberto A. Foglietta <roberto.foglietta@gmail.com>
Patchset revision v2, 2026-11-23

This implementation of RFC-1952 for miniz has been made after two
unsuccessful Kimi coding sections. The task is particularly suitable
for an artificial intelligence because the RFC-1952 is a standard
precisely documented, therefore its integration in miniz should have
been reasonable to achieve, in principle. The third attempt achieved
the goal after Kimi had been instructed to not fit-in the RFC-1952
into the RFC-1950's dedicated fields. I keep this part separate
for a matter of log, the others will follow as fixing patches.

Signed-off-by: Roberto A. Foglietta <roberto.foglietta@gmail.com>
Signed-off-by: Roberto A. Foglietta <roberto.foglietta@gmail.com>
Patchset revision v2, 2026-11-23

The RFC-1952 support is not self-sufficient yet. It requires that
each GZIP stream is provided one after another. This little change
helps but it doesn't allow miniz to autonomously inflate the
whole stream as-is.

Signed-off-by: Roberto A. Foglietta <roberto.foglietta@gmail.com>
Signed-off-by: Roberto A. Foglietta <roberto.foglietta@gmail.com>
Patchset revision v2, 2026-11-23

miniz: drain dictionary before reporting GZIP stream end

When inflating concatenated RFC-1952 GZIP streams, a stream ending or
error condition can occur while decompressed bytes are still sitting in
the dictionary buffer (m_dict_avail). Return MZ_BUF_ERROR so the caller
can flush remaining output first, and allow re-entering inflate to drain
those leftover bytes before moving on to the next stream (e.g., via
inflateEnd + inflateInit2 with window_bits = 15 + 16).

This addresses multi-stream GZIP decompression in callers like ptgzip
without mixing in ZIP64 extra-field (0x0001) handling; RFC-1952
support remains under active testing across split/concatenated buffers.

Sources: related update of the 'readme.md' and this commit:

- robang74/pgunzip@2be87f79fa9ade14dbab17474

Signed-off-by: Roberto A. Foglietta <roberto.foglietta@gmail.com>
The RFC-1952 support has been recently added but is not deeply tested,
yet. An example of use can be found starting from this commit here:

- robang74/pgunzip@2be87f79fa9ade14dbab17474

Signed-off-by: Roberto A. Foglietta <roberto.foglietta@gmail.com>
@robang74 robang74 mentioned this pull request Nov 23, 2026
@robang74
robang74 commented Nov 23, 2026 •
Copy link
Copy Markdown
Contributor Author

These two commits are for triggering the actions, and not supposed to be integrated

  • dced68f - 2026-09-12 - Change trigger from pull_request to workflow_dispatch
  • 37007a7 - 2026-09-12 - Update C/C++ CI workflow triggers

While these two are proposed changes, to evaluate, not neccesarly to integrate upstream:

  • ee09be2 - 2026-11-23 - amalgamate.sh: main(void) a harmless annoying warning
  • 7b43389 - 2026-11-23 - Guard zip64 local header reads against out-of-bounds mem offsets, fix

Instead, these are two commits which are *suggested to be upstreamed (warnings):

  • 47e946b - 2026-11-23 - examples/example2.c: C++ style comments are not allowed in ISO C90
  • 9db8f97 - 2026-11-23 - examples/example1.c: C++ style comments are not allowed in ISO C90

There others files in examples/ that require the same kind of janitoring.

@robang74
robang74 force-pushed the rfc1952.pr2 branch 2 times, most recently from ee09be2 to 7ba8d37 Compare November 24, 2026 09:52
@robang74
robang74 commented Nov 24, 2026 •
Copy link
Copy Markdown
Contributor Author

DONE: repeat the tests with 'pgunzip' that created the event for this patch.

  • clone pgunzip repo, commit #b7c44ee (tag:tzcmdok)
  • make pmgzip && make testcmd TZCMD=./pmgzip (OK)

or

make pmgzip
list=$(find /bin/ -type f | sort); for i in $list
do { ./pmgzip $i -c -1 | ./pmgzip -dc >/dev/null; } || 
  echo $i >&2; done # expected output: none, no errors

- miniz.c,.h,miniz_zip.c: fixing amalgamation.sh not-blocking bugs
- miniz_tinfl.c: lazy initialisation to explict zero

1. DONE: miniz_zip.c, read zip64 extended information field into comp_size

-------------------------------------------------------------------------------
Zip reader zip64 local header offset out of bounds
-------------------------------------------------------------------------------
/home/roberto/robang74/miniz/tests/main.cpp:415
...............................................................................

/home/roberto/robang74/miniz/tests/main.cpp:439: FAILED:
  REQUIRE( mz_zip_reader_init_mem(&zip, archive, sizeof(archive), 0) )
with expansion:
  0

===============================================================================
test cases:     10 |      9 passed | 1 failed
assertions: 134735 | 134734 passed | 1 failed

2. DONE: repeat the tests with 'pgunzip' that created the event for this patch.

- https://github.com/robang74/pgunzip commit #`b7c44ee` (tag:`tzcmdok`)
- `make pmgzip && make testcmd TZCMD=./pmgzip` (OK)

or
    make pmgzip
    list=$(find /bin/ -type f | sort); for i in $list
    do { ./pmgzip $i -c -1 | ./pmgzip -dc >/dev/null; } ||
      echo $i >&2; done # expected output: none, no errors

3. TODO: not investigated, yet

[ 13%] Building C object CMakeFiles/miniz.dir/miniz_tinfl.c.o
/usr/bin/cc -D_GNU_SOURCE -I/home/roberto/robang74/miniz
-I/home/roberto/robang74/miniz/build -Wshadow -Wformat=2
-Wall -Wno-overlength-strings -pedantic -O3 -DNDEBUG
-std=gnu90 -MD -MT CMakeFiles/miniz.dir/miniz_tinfl.c.o
-MF CMakeFiles/miniz.dir/miniz_tinfl.c.o.d
-o CMakeFiles/miniz.dir/miniz_tinfl.c.o
-c /home/roberto/robang74/miniz/miniz_tinfl.c
/home/roberto/robang74/miniz/miniz_tinfl.c: In function ‘tinfl_decompress’:
/home/roberto/robang74/miniz/miniz_tinfl.c:705:28: warning: ‘crc32’
      may be used uninitialized in this function [-Wmaybe-uninitialized]
  705 |             r->m_z_adler32 = crc32;
      |             ~~~~~~~~~~~~~~~^~~~~~~
/home/roberto/robang74/miniz/miniz_tinfl.c:235:22: warning: ‘flg’
      may be used uninitialized in this function [-Wmaybe-uninitialized]
  235 |             mz_uint8 flg = 0;
      |                      ^~~
/home/roberto/robang74/miniz/miniz_tinfl.c:273:28: warning: ‘xlen’
      may be used uninitialized in this function [-Wmaybe-uninitialized]
  273 |                 while (xlen--)
      |

Signed-off-by: Roberto A. Foglietta <roberto.foglietta@gmail.com>
Signed-off-by: Roberto A. Foglietta <roberto.foglietta@gmail.com>
Signed-off-by: Roberto A. Foglietta <roberto.foglietta@gmail.com>
Signed-off-by: Roberto A. Foglietta <roberto.foglietta@gmail.com>
Signed-off-by: Roberto A. Foglietta <roberto.foglietta@gmail.com>
Signed-off-by: Roberto A. Foglietta <roberto.foglietta@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

0