Repository navigation
bound nbit decompression reads to the stored chunk length - #6614
naruto-lgtm wants to merge 2 commits into
Conversation
|
there is one gap in the same file it doesn't cover: n = total_size / p.size; // also: total_size / base_size |
|
Good catch. All three divisions in H5Z__nbit_decompress_one_array take their divisor from the pipeline message, and the precision/offset check passes when both are zero, so a zero size did reach the division. Pushed a zero-check before each one; the nbit tests in dsets and direct_chunk still pass. |
|
|
||
| ### Bound nbit decompression reads to the stored chunk length | ||
|
|
||
| The reverse nbit filter walked its bit reader through the chunk buffer using only the element count and precision from the filter pipeline message, never the number of bytes actually stored for the chunk. The chunk buffer the filter is handed is sized to hold the larger unfiltered chunk, so a truncated or corrupted chunk decompressed out of the uninitialized remainder of that allocation and returned it as dataset data. The decompression path now carries the stored length and rejects any read past it. |
There was a problem hiding this comment.
nbit -> n-bit
Fix grammar:
The reverse n-bit filter walked its bit reader through the chunk buffer using only the element count and precision from the filter pipeline message, never checking the number of bytes actually stored for the chunk. Because the chunk buffer provided to the filter is sized to hold the larger unfiltered chunk, a truncated or corrupted chunk would decompress out of the uninitialized remainder of that allocation and return it as dataset data. The decompression path now tracks the stored length and rejects any read past it.
There was a problem hiding this comment.
Done, took your wording and switched the heading to n-bit as well.
|
This pull request has had no activity for 30 days and has been marked stale. Push a commit or comment to keep it open, or it will be flagged for maintainer review. |
|
any update? |
|
This may have been fixed by this commit last week: a3cf1ea |
7e36e91 to
c7f48dc
Compare
|
Yes, a3cf1ea covers it, and it's a superset of what I had here: it also validates cd_values up front and bounds the walk through the parameter list, neither of which my version did. My test passes on current develop with no changes under src, so I've rebased onto develop and dropped my H5Znbit.c bound changes. The test is its own commit now, so it can go in on its own. One item from the earlier review on this PR is still open on develop though. The three divisions in dsets (including test_filter_bad_params) and direct_chunk both pass with it. I have the generator for that crafted file if you want the zero-size case added to gen_bad_filters.c alongside the other three. |
Describe your changes
Originally this bounded the reverse n-bit decompression walk to the stored chunk length. That part has since landed on develop in a3cf1ea (#6497), which is a superset of what was here, so it has been dropped and the branch rebased onto develop. Two things are left:
The regression test for the over-read. It passes against develop as it stands, with no changes under
src, so it only pins the behaviour a3cf1ea introduced. It stores an 8-byte chunk for a 4000-byte unfiltered chunk viaH5Dwrite_chunk()and requires the read to fail rather than decompress out of the uninitialised tail of the chunk buffer.A zero-divisor check in
H5Z__nbit_decompress_one_array(). The three divisions there take their divisor from the filter's client-data parameters, and a zero base size still isn't rejected on develop. A zero atomic size also passes the existing precision/offset check when the precision and offset are zero as well, so it isn't caught there either. Confirmed with-fsanitize=integer-divide-by-zeroagainst a crafted file whose stored base size is zeroed: division by zero atH5Znbit.c:1217. On x86-64 that is a SIGFPE; on arm64UDIVyields 0 instead, so the read quietly returns zeroed data.The two are separate commits so the test can be taken on its own.
dsets(includingtest_filter_bad_params) anddirect_chunkboth pass.Issue ticket number (GitHub or JIRA)
Follow-up to #6585; the over-read it describes is now fixed by #6497.
Checklist before requesting a review