diff options
| author | Mark Adler <madler@alumni.caltech.edu> | 2025-03-21 17:19:45 -0700 |
|---|---|---|
| committer | Mark Adler <madler@alumni.caltech.edu> | 2025-05-13 18:00:03 -0700 |
| commit | 473f78532aed8f5a8d55cd6e7b305160db9cf742 (patch) | |
| tree | 300c72bc9ee482317d206c0864e4a770559d215d /zlib.h | |
| parent | 783886350b775fbf852947bfff103992856075f6 (diff) | |
| download | zlib-473f78532aed8f5a8d55cd6e7b305160db9cf742.tar.gz zlib-473f78532aed8f5a8d55cd6e7b305160db9cf742.tar.bz2 zlib-473f78532aed8f5a8d55cd6e7b305160db9cf742.zip | |
Fix bug in inflatePrime() for 16-bit ints.
Also elaborate on the inflatePrime() error return in zlib.h, and
assure that data_type is correct after initialization and a
Z_NEED_DICT return.
Diffstat (limited to 'zlib.h')
| -rw-r--r-- | zlib.h | 28 |
1 files changed, 19 insertions, 9 deletions
| @@ -445,7 +445,7 @@ ZEXTERN int ZEXPORT inflate(z_streamp strm, int flush); | |||
| 445 | 445 | ||
| 446 | The Z_BLOCK option assists in appending to or combining deflate streams. | 446 | The Z_BLOCK option assists in appending to or combining deflate streams. |
| 447 | To assist in this, on return inflate() always sets strm->data_type to the | 447 | To assist in this, on return inflate() always sets strm->data_type to the |
| 448 | number of unused bits in the last byte taken from strm->next_in, plus 64 if | 448 | number of unused bits in the input taken from strm->next_in, plus 64 if |
| 449 | inflate() is currently decoding the last block in the deflate stream, plus | 449 | inflate() is currently decoding the last block in the deflate stream, plus |
| 450 | 128 if inflate() returned immediately after decoding an end-of-block code or | 450 | 128 if inflate() returned immediately after decoding an end-of-block code or |
| 451 | decoding the complete header up to just before the first byte of the deflate | 451 | decoding the complete header up to just before the first byte of the deflate |
| @@ -1006,13 +1006,15 @@ ZEXTERN int ZEXPORT inflatePrime(z_streamp strm, | |||
| 1006 | int bits, | 1006 | int bits, |
| 1007 | int value); | 1007 | int value); |
| 1008 | /* | 1008 | /* |
| 1009 | This function inserts bits in the inflate input stream. The intent is | 1009 | This function inserts bits in the inflate input stream. The intent is to |
| 1010 | that this function is used to start inflating at a bit position in the | 1010 | use inflatePrime() to start inflating at a bit position in the middle of a |
| 1011 | middle of a byte. The provided bits will be used before any bytes are used | 1011 | byte. The provided bits will be used before any bytes are used from |
| 1012 | from next_in. This function should only be used with raw inflate, and | 1012 | next_in. This function should be used with raw inflate, before the first |
| 1013 | should be used before the first inflate() call after inflateInit2() or | 1013 | inflate() call, after inflateInit2() or inflateReset(). It can also be used |
| 1014 | inflateReset(). bits must be less than or equal to 16, and that many of the | 1014 | after an inflate() return indicates the end of a deflate block or header |
| 1015 | least significant bits of value will be inserted in the input. | 1015 | when using Z_BLOCK. bits must be less than or equal to 16, and that many of |
| 1016 | the least significant bits of value will be inserted in the input. The | ||
| 1017 | other bits in value can be non-zero, and will be ignored. | ||
| 1016 | 1018 | ||
| 1017 | If bits is negative, then the input stream bit buffer is emptied. Then | 1019 | If bits is negative, then the input stream bit buffer is emptied. Then |
| 1018 | inflatePrime() can be called again to put bits in the buffer. This is used | 1020 | inflatePrime() can be called again to put bits in the buffer. This is used |
| @@ -1020,7 +1022,15 @@ ZEXTERN int ZEXPORT inflatePrime(z_streamp strm, | |||
| 1020 | to feeding inflate codes. | 1022 | to feeding inflate codes. |
| 1021 | 1023 | ||
| 1022 | inflatePrime returns Z_OK if success, or Z_STREAM_ERROR if the source | 1024 | inflatePrime returns Z_OK if success, or Z_STREAM_ERROR if the source |
| 1023 | stream state was inconsistent. | 1025 | stream state was inconsistent, or if bits is out of range. If inflate was |
| 1026 | in the middle of processing a header, trailer, or stored block lengths, then | ||
| 1027 | it is possible for there to be only eight bits available in the bit buffer. | ||
| 1028 | In that case, bits > 8 is considered out of range. However, when used as | ||
| 1029 | outlined above, there will always be 16 bits available in the buffer for | ||
| 1030 | insertion. As noted in its documentation above, inflate records the number | ||
| 1031 | of bits in the bit buffer on return in data_type. 32 minus that is the | ||
| 1032 | number of bits available for insertion. inflatePrime does not update | ||
| 1033 | data_type with the new number of bits in buffer. | ||
| 1024 | */ | 1034 | */ |
| 1025 | 1035 | ||
| 1026 | ZEXTERN long ZEXPORT inflateMark(z_streamp strm); | 1036 | ZEXTERN long ZEXPORT inflateMark(z_streamp strm); |
