RESOLVED FIXED 222401
WKRemoteObjectCoder should be able to handle NSErrors from TLS failures
https://bugs.webkit.org/show_bug.cgi?id=222401
Summary WKRemoteObjectCoder should be able to handle NSErrors from TLS failures
Alex Christensen
Reported 2021-02-24 20:15:03 PST
WKRemoteObjectCoder should be able to handle NSErrors from TLS failures
Attachments
Patch (14.36 KB, patch)
2021-02-24 20:20 PST, Alex Christensen
no flags
Patch (14.21 KB, patch)
2021-03-02 21:26 PST, Alex Christensen
no flags
Patch (14.23 KB, patch)
2021-03-02 21:29 PST, Alex Christensen
no flags
Patch (14.16 KB, patch)
2021-03-03 22:31 PST, Alex Christensen
no flags
Alex Christensen
Comment 1 2021-02-24 20:20:41 PST
Alex Christensen
Comment 2 2021-02-24 20:20:44 PST
Chris Dumez
Comment 3 2021-03-02 14:44:00 PST
Comment on attachment 421496 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=421496&action=review > Source/WebKit/Shared/API/Cocoa/WKRemoteObjectCoder.mm:317 > + return [result autorelease]; I spent a lot of time getting rid of all the explicit [objc autorelease] in our internal code. Please use RetainPtr<>. > Source/WebKit/Shared/API/Cocoa/WKRemoteObjectCoder.mm:343 > + return (NSData *)data.autorelease(); I cc'd Darin because I seem to remember that this sort of things (casting from CF to NS and autoreleasing) makes ARC transition complicated. Overall, we should be using RetainPtr<>.
Darin Adler
Comment 4 2021-03-02 17:14:02 PST
Comment on attachment 421496 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=421496&action=review I suggest using a lot more RetainPtr. > Source/WebKit/Shared/API/Cocoa/WKRemoteObjectCoder.mm:303 > +static id decodeObjCObject(WKRemoteObjectDecoder *decoder, Class objectClass) This should return a RetainPtr<id>. > Source/WebKit/Shared/API/Cocoa/WKRemoteObjectCoder.mm:322 > +NSString *peerCertificateKey = @"NSErrorPeerCertificateChainKey"; > +NSString *peerTrustKey = @"NSURLErrorFailingURLPeerTrustErrorKey"; > +NSString *clientCertificateKey = @"NSErrorClientCertificateChainKey"; Should these have static constexpr in front of them? > Source/WebKit/Shared/API/Cocoa/WKRemoteObjectCoder.mm:324 > +static NSArray *transformCertificatesToData(NSArray *input) This should return a RetainPtr<NSArray>. > Source/WebKit/Shared/API/Cocoa/WKRemoteObjectCoder.mm:335 > +static NSData *transformTrustToData(SecTrustRef trust) This should return a RetainPtr<CFDataRef>. >> Source/WebKit/Shared/API/Cocoa/WKRemoteObjectCoder.mm:343 >> + return (NSData *)data.autorelease(); > > I cc'd Darin because I seem to remember that this sort of things (casting from CF to NS and autoreleasing) makes ARC transition complicated. > > Overall, we should be using RetainPtr<>. For our own functions we should use RetainPtr for return values, not autoreleased objects. However, I don’t know exactly how to change a RetainPtr<CFDataRef> into a RetainPtr<NSData>. I suggest we sidestep that issue by having this function return RetainPtr<CFDataRef>. > Source/WebKit/Shared/API/Cocoa/WKRemoteObjectCoder.mm:348 > + NSMutableDictionary *copy = nil; This should be a RetainPtr. > Source/WebKit/Shared/API/Cocoa/WKRemoteObjectCoder.mm:374 > +static NSArray *transformDataToCertificates(NSArray *input) This should return a RetainPtr<NSArray>. > Source/WebKit/Shared/API/Cocoa/WKRemoteObjectCoder.mm:388 > +static id transformDataToTrust(NSData *data) This should probably return a RetainPtr<CFTypeRef>. > Source/WebKit/Shared/API/Cocoa/WKRemoteObjectCoder.mm:399 > +static NSError *decodeError(WKRemoteObjectDecoder *decoder) This should return a RetainPtr<NSError>.
Alex Christensen
Comment 5 2021-03-02 21:26:52 PST
Alex Christensen
Comment 6 2021-03-02 21:29:14 PST
Alex Christensen
Comment 7 2021-03-02 21:30:54 PST
(In reply to Darin Adler from comment #4) > > Source/WebKit/Shared/API/Cocoa/WKRemoteObjectCoder.mm:322 > > +NSString *peerCertificateKey = @"NSErrorPeerCertificateChainKey"; > > +NSString *peerTrustKey = @"NSURLErrorFailingURLPeerTrustErrorKey"; > > +NSString *clientCertificateKey = @"NSErrorClientCertificateChainKey"; > > Should these have static constexpr in front of them? This blew my mind a little bit. Static I get, but I definitely need to do more thinking about exactly what a constexpr NSString* is.
Darin Adler
Comment 8 2021-03-03 09:37:39 PST
(In reply to Alex Christensen from comment #7) > This blew my mind a little bit. Static I get, but I definitely need to do > more thinking about exactly what a constexpr NSString* is. Roughly speaking, it's an NSString * with a value known at compile time and that never changes.
Chris Dumez
Comment 9 2021-03-03 09:56:33 PST
Comment on attachment 422042 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=422042&action=review r=me with a couple of changes. > Tools/TestWebKitAPI/Tests/WebKitCocoa/RemoteObjectRegistry.mm:237 > + auto webView = [[[WKWebView alloc] initWithFrame:CGRectZero configuration:[WKWebViewConfiguration _test_configurationWithTestPlugInClassName:@"RemoteObjectRegistryPlugIn"]] autorelease]; no autorelease] please. Just use adoptNS(). > Tools/TestWebKitAPI/Tests/WebKitCocoa/RemoteObjectRegistry.mm:238 > + auto delegate = [[TestNavigationDelegate new] autorelease]; ditto.
Alex Christensen
Comment 10 2021-03-03 22:31:39 PST
EWS
Comment 11 2021-03-03 23:22:37 PST
Committed r273875: <https://commits.webkit.org/r273875> All reviewed patches have been landed. Closing bug and clearing flags on attachment 422183 [details].
Note You need to log in before you can comment on or make changes to this bug.