mirror of
https://github.com/ProxymanApp/atlantis.git
synced 2026-04-26 08:26:04 +03:00
[GH-ISSUE #132] Crash When Intercepting URLSessionUploadTask #82
Labels
No labels
Done
Done
Windows
bug
bug
bug
enhancement
enhancement
enhancement
good first issue
hacktoberfest
pull-request
wontfix
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/atlantis#82
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @VaslD on GitHub (Jul 20, 2023).
Original GitHub issue: https://github.com/ProxymanApp/atlantis/issues/132
We recently encountered an Atlantis-related crash at:
github.com/ProxymanApp/atlantis@f6f7be1330/Sources/NetworkInjector+URLSession.swift (L294-L298)I've found the cause but since I'm too familiar with method swizzling and calling conventions, I think you might want to take a look and verify this.
The problem is that
uploadTaskWithRequest:fromData:completionHandler:, and its Swift counterpartuploadTask(with:from:completionHandler:), has an optionalData?parameter. Atlantis swizzled this method with a C function@convention(c) (AnyObject, Selector, AnyObject, AnyObject, AnyObject) -> AnyObjectthat marks all parameters non-null.A third-party library actually passes
nilto theData?parameter, which causes Atlantis to crash when readingdata. Although the code usesif let,datais always implicitly unwrapped to non-optional first because the C function signature declaresAnyObject(instead ofAnyObject?).The fix seems to work when declaring parameters for
dataandcompletionHandleras optionals, and taking non-nulldataout of assertions. As a precaution, you should review other swizzledURLSessionTaskfactory methods to avoid implicit unwraps.@NghiaTranUIT commented on GitHub (Jul 20, 2023):
@VaslD can you verify what iOS version you're using?
@VaslD commented on GitHub (Jul 20, 2023):
I have confirmed crash reports from iOS 15.7.2 and 15.1, with IPAs generated from Xcode 14.2 and 14.3.1. Suspicious crashes do happen on other iOS versions during QA but I have not received crash reports to corroborate those claims.
But seeing the latest API documentation (I referenced in the original post) does declare the
dataparameter as nullable, it would be safe to not assume that it isn't.