-
Notifications
You must be signed in to change notification settings - Fork 8.9k
optimize: zstd decompression is changed from jni to ZstdInputStream #7578
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
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## 2.x #7578 +/- ##
============================================
- Coverage 60.83% 60.78% -0.06%
+ Complexity 658 656 -2
============================================
Files 1308 1308
Lines 49432 49437 +5
Branches 5810 5811 +1
============================================
- Hits 30072 30049 -23
- Misses 16697 16724 +27
- Partials 2663 2664 +1
🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR optimizes zstd decompression by switching from JNI-based approach to using ZstdInputStream for safer memory handling. The change prevents potential OOM attacks when decompressing maliciously crafted zstd data with fake frame content sizes.
- Replaced direct JNI decompression with streaming-based ZstdInputStream approach
- Updated exception handling to throw IllegalArgumentException instead of ZstdException
- Added comprehensive test coverage for OOM attack scenarios with fake frame content sizes
Reviewed Changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| ZstdUtil.java | Refactored decompress method to use ZstdInputStream instead of direct JNI calls |
| ZstdUtilTest.java | Updated exception expectations and added new test for OOM attack prevention |
| changes/zh-cn/2.x.md | Added Chinese changelog entry for the optimization |
| changes/en-us/2.x.md | Added English changelog entry for the optimization |
Comments suppressed due to low confidence (1)
...essor/seata-compressor-zstd/src/test/java/org/apache/seata/compressor/zstd/ZstdUtilTest.java
Outdated
Show resolved
Hide resolved
…a/compressor/zstd/ZstdUtilTest.java Co-authored-by: Copilot <[email protected]>
slievrly
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Ⅰ. Describe what this PR did
Ⅱ. Does this pull request fix one issue?
Ⅲ. Why don't you add test cases (unit test/integration test)?
Ⅳ. Describe how to verify it
Ⅴ. Special notes for reviews