refactor: Fix signed/unsigned comparison in lz4Decompress - #7687
refactor: Fix signed/unsigned comparison in lz4Decompress#7687BraedonKlock wants to merge 1 commit into
Conversation
|
If only the most recent commit is unsigned, you can run:
If multiple commits are unsigned, you can run:
If you're new to commit signing, there are different ways to set it up: Sign commits with
|
e65de33 to
e7a216e
Compare
|
Hi @BraedonKlock. Thank you for your contributions! We really appreciate them. At this point, we ask that you hold off on submitting any more until we've had a chance to review the current batch. There is a not insignificant engineer overhead for each review, and it may take some time to get caught up. Too many PRs can make that harder. When we've gotten down to 3 open or fewer, feel free to create more! In the meantime, you can open "Draft" PRs so that changes will be ready to go once we're ready for more. At that time, you'll be able to decide which ones are the best, and convert them to "Ready to review". Keep in mind that you will be responsible for keeping your PRs up to date with |
|
Thank you @ximinez for the clarification! I really appreciate the feedback. I completely understand. I'll hold off on opening additional ready for review PRs until my open count is down to three or fewer. In the meantime, I'll continue working locally and use draft PRs if appropriate. Thanks again! |
High Level Overview of Change
Fixes a signed/unsigned comparison in the stream-based
lz4Decompressoverload.The stream returns
chunkSizeas anint, while the expected input size is represented asstd::size_t. This change validateschunkSizebefore converting it tostd::size_t, usesstd::size_tfor copied byte tracking, and simplifies the final insufficient-input check.Fixes #7521
Context of Change
The previous implementation compared
chunkSizedirectly againstinSize. SincechunkSizeis signed andinSizeis unsigned, a negativechunkSizecould be converted to a large unsigned value during comparison.This change checks for a negative
chunkSizebefore conversion, then uses a validatedstd::size_tvalue for size comparisons and copy calculations. It also changescopiedInSizetostd::size_tand simplifies the final insufficient-input check tocopiedInSize != inSize, so the final validation is based on whether the requested number of compressed input bytes was actually accounted for.