Skip to content

Commit

Permalink
[Darwin] XPC interface for invoke needs to take into account the repl…
Browse files Browse the repository at this point in the history
…y may contain non-property-list objects (#35131)
  • Loading branch information
jtung-apple authored and pull[bot] committed Nov 25, 2024
1 parent aec05ac commit 2860905
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions src/darwin/Framework/CHIP/MTRDeviceController_XPC.mm
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,21 @@ @implementation MTRDeviceController_XPC

@synthesize uniqueIdentifier = _uniqueIdentifier;

- (NSXPCInterface *)_interfaceForServerProtocol
{
NSXPCInterface * interface = [NSXPCInterface interfaceWithProtocol:@protocol(MTRXPCServerProtocol)];

NSSet * allowedClasses = [NSSet setWithArray:@[
[NSString class], [NSNumber class], [NSData class], [NSArray class], [NSDictionary class], [NSError class], [MTRCommandPath class], [MTRAttributePath class]
]];

[interface setClasses:allowedClasses
forSelector:@selector(deviceController:nodeID:invokeCommandWithEndpointID:clusterID:commandID:commandFields:expectedValues:expectedValueInterval:timedInvokeTimeout:completion:)
argumentIndex:0
ofReply:YES];
return interface;
}

- (NSXPCInterface *)_interfaceForClientProtocol
{
NSXPCInterface * interface = [NSXPCInterface interfaceWithProtocol:@protocol(MTRXPCClientProtocol)];
Expand Down Expand Up @@ -84,7 +99,7 @@ - (id)initWithUniqueIdentifier:(NSUUID *)UUID xpConnectionBlock:(NSXPCConnection

MTR_LOG("Set up XPC Connection: %@", self.xpcConnection);
if (self.xpcConnection) {
self.xpcConnection.remoteObjectInterface = [NSXPCInterface interfaceWithProtocol:@protocol(MTRXPCServerProtocol)];
self.xpcConnection.remoteObjectInterface = [self _interfaceForServerProtocol];

self.xpcConnection.exportedInterface = [self _interfaceForClientProtocol];
self.xpcConnection.exportedObject = self;
Expand Down Expand Up @@ -118,9 +133,9 @@ - (id)initWithUniqueIdentifier:(NSUUID *)UUID machServiceName:(NSString *)machSe

MTR_LOG("Set up XPC Connection: %@", self.xpcConnection);
if (self.xpcConnection) {
self.xpcConnection.remoteObjectInterface = [NSXPCInterface interfaceWithProtocol:@protocol(MTRXPCServerProtocol)];
self.xpcConnection.remoteObjectInterface = [self _interfaceForServerProtocol];

self.xpcConnection.exportedInterface = [NSXPCInterface interfaceWithProtocol:@protocol(MTRXPCClientProtocol)];
self.xpcConnection.exportedInterface = [self _interfaceForClientProtocol];
self.xpcConnection.exportedObject = self;

MTR_LOG("%s: resuming new XPC connection");
Expand Down

0 comments on commit 2860905

Please sign in to comment.