Skip to content

Conversation

@phobos665
Copy link
Contributor

@phobos665 phobos665 commented Feb 3, 2026

Overview:

This fixes the parsing issue of a small number of games not downloading correctly.

Technical Details:

There are two versions of the header: V2 and v3.

V2 uses 62 bytes and V3 uses 66 Bytes.

We were only considering the 66 byte-length headers and it was failing.

Now appropriately checks the version and checks the header as expected.

Summary by CodeRabbit

Release Notes

  • Bug Fixes
    • Improved download compatibility to support multiple header format versions.
    • Added validation and buffer protection to prevent data corruption from invalid headers.
    • Enhanced diagnostic logging to better track and troubleshoot download operations.

…chunks. Two different specs, 62 bytes and 66 byte headers.
Copy link
Contributor

@cubic-dev-ai cubic-dev-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issue found across 1 file

Prompt for AI agents (all issues)

Check if these issues are valid — if so, understand the root cause of each and fix them.


<file name="app/src/main/java/app/gamenative/service/epic/EpicDownloadManager.kt">

<violation number="1" location="app/src/main/java/app/gamenative/service/epic/EpicDownloadManager.kt:686">
P2: `headerSize` is read from the chunk file and only checked for a minimum. A large/corrupt value will lead to `ByteArray(remainingSize)` allocating an unbounded amount of memory, which can crash the app. Add an upper bound on the header size before allocating.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

…ger.kt

Co-authored-by: cubic-dev-ai[bot] <191113872+cubic-dev-ai[bot]@users.noreply.github.com>
@coderabbitai
Copy link

coderabbitai bot commented Feb 3, 2026

📝 Walkthrough

Walkthrough

Modifies header parsing in EpicDownloadManager.kt to support two header formats (62-byte and 66-byte) by adding validation, version-based conditional logic, buffer underflow guards, and expanded diagnostic logging.

Changes

Cohort / File(s) Summary
Header Format Handling
app/src/main/java/app/gamenative/service/epic/EpicDownloadManager.kt
Adds headerSize validation (62-66 bytes), conditional parsing based on headerVersion to handle legacy 62-byte and newer 66-byte formats, buffer underflow guard, and enhanced logging for version and computed uncompressedSize.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 Two headers dance, one old, one new,
Version checks determine what's true,
Buffers protected from underflow's bite,
Each format handled with parsing might! ✨

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title directly reflects the main change: fixing a parsing issue for Epic Games downloads by implementing header version detection to handle both 62-byte and 66-byte header formats.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment

Important

Action Needed: IP Allowlist Update

If your organization protects your Git platform with IP whitelisting, please add the new CodeRabbit IP address to your allowlist:

  • 136.113.208.247/32 (new)
  • 34.170.211.100/32
  • 35.222.179.152/32

Failure to add the new IP will result in interrupted reviews.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@app/src/main/java/app/gamenative/service/epic/EpicDownloadManager.kt`:
- Around line 684-688: The header size validation in EpicDownloadManager
(variable headerSize) currently allows any value between 62 and 66, but only
exact sizes 62 or 66 are valid; update the check to enforce (headerSize == 62 ||
headerSize == 66) and throw an Exception when not one of those exact values, and
adjust the exception message to state "Invalid header size: X (expected 62 or 66
bytes)" to make the constraint explicit; locate and modify the validation block
around headerSize in EpicDownloadManager.kt.

Comment on lines +684 to +688
// Epic chunks can have different header sizes (62 or 66 bytes)
// Minimum viable header is 62 bytes
if (headerSize < 62 || headerSize > 66) {
throw Exception("Invalid header size: $headerSize (expected 62-66 bytes)")
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Tighten header size validation to exact 62/66 bytes.

The comment says only 62 or 66 are valid, but the current check allows 63–65 which can mask corrupted headers. Consider enforcing exact values.

🔧 Proposed fix
-            if (headerSize < 62 || headerSize > 66) {
-                throw Exception("Invalid header size: $headerSize (expected 62-66 bytes)")
-            }
+            if (headerSize != 62 && headerSize != 66) {
+                throw Exception("Invalid header size: $headerSize (expected 62 or 66 bytes)")
+            }
🤖 Prompt for AI Agents
In `@app/src/main/java/app/gamenative/service/epic/EpicDownloadManager.kt` around
lines 684 - 688, The header size validation in EpicDownloadManager (variable
headerSize) currently allows any value between 62 and 66, but only exact sizes
62 or 66 are valid; update the check to enforce (headerSize == 62 || headerSize
== 66) and throw an Exception when not one of those exact values, and adjust the
exception message to state "Invalid header size: X (expected 62 or 66 bytes)" to
make the constraint explicit; locate and modify the validation block around
headerSize in EpicDownloadManager.kt.

@utkarshdalal utkarshdalal merged commit 24d81e6 into utkarshdalal:master Feb 4, 2026
3 checks passed
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

Successfully merging this pull request may close these issues.

2 participants