iOS: add CodePushBinaryDiffPatcher to apply bsdiff patches - #59
Draft
ofalvai wants to merge 2 commits into
Draft
Conversation
ofalvai
added this pull request to stack #57
September 9, 2026 06:46
ofalvai
force-pushed
the
ios-binary-diff-patcher
branch
from
September 9, 2026 15:37
7912ae8 to
ca765df
Compare
There was a problem hiding this comment.
🟡 Changes recommended
The new patcher currently emits misleading hash-mismatch errors when hashing fails (e.g., unreadable/missing files), obscuring the real I/O failure cause.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
Adds an iOS-native binary diff patcher to apply bsdiff patches described by CodePushDiffManifest, aligning iOS with the existing Android diff/patch flow and hardening path handling via resolvePath(_:withinFolder:).
Changes:
- Introduces
CodePushBinaryDiffPatcher(Obj-C) to validate hashes, resolve manifest-supplied paths safely, and applybsdiffpatches viabspatch_bridge. - Adds Swift XCTest coverage for happy-path patching, hash mismatches, unsupported algorithms, path traversal, and symlink-escape attempts.
- Wires the new source + tests into the Xcode project and test bridging header.
File summaries
| File | Description |
|---|---|
| ios/CodePushTests/CodePushTests-Bridging-Header.h | Exposes the new Obj-C patcher to Swift tests. |
| ios/CodePushTests/CodePushBinaryDiffPatcherTests.swift | Adds test coverage for binary patch application and path/symlink safety. |
| ios/CodePush/CodePushBinaryDiffPatcher.m | Implements patch application, path resolution, and hash verification. |
| ios/CodePush/CodePushBinaryDiffPatcher.h | Declares the patcher API and Swift import name. |
| ios/CodePush.xcodeproj/project.pbxproj | Registers new sources/headers and the new test file in build phases. |
Review details
Suppressed comments (1)
ios/CodePush/CodePushBinaryDiffPatcher.m:98
- If hashing the newly patched file fails,
newFileHashcan be nil and the code reports a confusing "targetHash mismatch ... got (null)" instead of the actual hashing/read error. Handling the nil case separately provides a clearer failure reason.
NSString *newFileHash = CodePushSha256HexForFile(newFile, &hashError);
if (!newFileHash || ![newFileHash isEqualToString:entry.targetHash]) {
if (error) *error = patchApplyError(relativePath, [NSString stringWithFormat:@"targetHash mismatch: expected %@, got %@", entry.targetHash, newFileHash]);
return NO;
- Files reviewed: 5/5 changed files
- Comments generated: 1
- Review effort level: Lite
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+64
to
+69
| NSError *hashError = nil; | ||
| NSString *oldFileHash = CodePushSha256HexForFile(oldFile, &hashError); | ||
| if (!oldFileHash || ![oldFileHash isEqualToString:entry.baseHash]) { | ||
| if (error) *error = patchApplyError(relativePath, [NSString stringWithFormat:@"baseHash mismatch: expected %@, got %@", entry.baseHash, oldFileHash]); | ||
| return NO; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stack created with GitHub Stacks CLI • Give Feedback 💬