Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error in the example of using the LimitOutput parameter #21

Closed
true-alex opened this issue Apr 27, 2023 · 2 comments
Closed

Error in the example of using the LimitOutput parameter #21

true-alex opened this issue Apr 27, 2023 · 2 comments
Assignees

Comments

@true-alex
Copy link

The inner loop must be repeated as long as the Z_BUF_ERROR status is set.
The Z_BUF_ERROR status means that Zlib has more data to output, but the size of the output variable has already reached the maximum allowed size. In this case, you need to re-call inflate without adding anything to the input.

The example says this:
} while ($status == Z_OK && length $input);
but that's not true it should be
} while ($status == Z_BUF_ERROR && length $input);
изображение

@pmqs pmqs self-assigned this May 21, 2023
@pmqs
Copy link
Owner

pmqs commented May 21, 2023

Hey @true-alex - - sorry for the delay in responding.

Good catch! Looking at this I initially didn't think there was an error at all, but I crafted some code that triggered an error with the code in the example

Thinking about this some more, rather than using

while ($status == Z_BUF_ERROR && length $input);

I will use this for the loop condition

while length $input;

Below are quotes from the inflate section of the of the zlib manual

inflate() returns Z_OK if some progress has been made (more input processed or more output produced)
...
Z_BUF_ERROR if no progress was possible

The two return code Z_OK and Z_BUF_ERROR look like they are possible in that inner while loop, and are already tested for.

pmqs added a commit that referenced this issue May 21, 2023
@pmqs
Copy link
Owner

pmqs commented Jul 16, 2023

Fixed in version 2.205 which is now uploaded to CPAN .

@pmqs pmqs closed this as completed Jul 16, 2023
jkeenan added a commit to Perl/perl5 that referenced this issue Jul 19, 2023
  2.205 16 July 2023

      * 2.205
        Sun, 16 Jul 2023 16:11:31 +0100
        3effdb9dbaa9bedfff3cad44902e515409ffae78

      * Test::More::isn't warns in perl 5.38
        Sun, 9 Jul 2023 21:38:15 +0100
        928bbc6ddc5178621fb477b38a1b4b4de38866cf

      * add zlib-ng 2.1.3
        Thu, 29 Jun 2023 19:51:58 +0100
        b1aa2583b4c114c2194890a0e015fdc439928c31

      * add zlib-ng 2.1.2
        Fri, 9 Jun 2023 14:51:17 +0100
        0d505d9156ca7e9cac15e2d6e574099300f91a14

      * Change storage of ZLIBNG_VER_STATUS from IV to PV pmqs/Compress-Raw-Zlib#24
        Fri, 9 Jun 2023 14:30:36 +0100
        0a8fb7141a43b8e49609fb06f05fad5150a97c2a

      * Fix to allow building with C++17 register keyword not allowed in C++17 pmqs/Compress-Raw-Zlib#23
        Mon, 22 May 2023 12:42:51 +0100
        a7c12acdd4ce7fdc070f50ac78e68e04c8699c81

      * Change while loop for `LimitOutput`  example pmqs/Compress-Raw-Zlib#21
        Sun, 21 May 2023 21:32:19 +0100
        972f03b5b0bf06d44991bbee2d2c9216e4175154

      * [doc] zlib.h: Remove duplicate "the" (#22)
        Mon, 1 May 2023 22:46:39 +0200
        89b43e6978d8e9b16801f48881cadf822585be0d

      * Add zlib compat version for 2.0.7
        Sat, 18 Mar 2023 08:42:59 +0000
        e7d79cbd5924fbdcd3515fb3b0ad171c7720105c
kraj pushed a commit to YoeDistro/meta-openembedded that referenced this issue Aug 1, 2023
Changelog:
===========
* drop rt.cpan from SUPPORT section
* Test::More::isn't warns in perl 5.38
* add zlib-ng 2.1.3
* add zlib-ng 2.1.2
* Change storage of ZLIBNG_VER_STATUS from IV to PV pmqs/Compress-Raw-Zlib#24
* Fix to allow building with C++17 register keyword not allowed in C++17 pmqs/Compress-Raw-Zlib#23
* Change while loop for `LimitOutput`  example pmqs/Compress-Raw-Zlib#21
* [doc] zlib.h: Remove duplicate "the" (openembedded#22)
* Add zlib compat version for 2.0.7

Signed-off-by: Wang Mingyu <wangmy@fujitsu.com>
Signed-off-by: Khem Raj <raj.khem@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

No branches or pull requests

2 participants