Skip to content

Guard XML-RPC remote construction on missing credentials - #26159

Closed
feather2222 wants to merge 1 commit into
wordpress-mobile:trunkfrom
feather2222:issue/26158-xmlrpc-remote-guard
Closed

feather2222 wants to merge 1 commit into
wordpress-mobile:trunkfrom
feather2222:issue/26158-xmlrpc-remote-guard

Conversation

@feather2222

Copy link
Copy Markdown
Contributor

Fixes #26158

What

Guard the XML-RPC remote construction in -[BlogService remoteForBlog:] so it is only created when the blog actually has XML-RPC credentials:

if (blog.xmlrpcApi && blog.username.length > 0 && blog.password.length > 0) {

Why

When a wpcom blog's auth token is unreadable from the keychain (observed as repeated Error while retrieving WordPressComOAuthKeychainServiceName token log entries), blog.wordPressComRestApi is nil and remoteForBlog: falls through to the XML-RPC path. A wpcom blog has no username/password, so -[ServiceRemoteWordPressXMLRPC initWithApi:username:password:] hits NSParameterAssert(password != nil) and crashes every debug launch until the app data is wiped. Release builds survive because the assert is compiled out, but the resulting remote is useless anyway.

Returning nil degrades the broken blog to "doesn't sync" instead of crashing; all callers tolerate a nil remote via Objective-C nil messaging.

Testing

A wpcom blog whose auth token is unreadable falls through to the
XML-RPC remote with no username/password, hitting the
NSParameterAssert in ServiceRemoteWordPressXMLRPC and crashing
debug builds at launch. Return nil instead; callers already
tolerate a nil remote.

Fixes wordpress-mobile#26158
@crazytonyli

Copy link
Copy Markdown
Contributor

Thanks for the PR. The issue has been fixed in #26132. I'm going to close this one. But feel free to let me know if you think otherwise.

@feather2222

Copy link
Copy Markdown
Contributor Author

No worries at all — #26132 is a much more thorough fix. Glad the report was useful!

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.

Debug crash: wpcom blog without a readable auth token falls through to the XML-RPC remote and hits NSParameterAssert

2 participants