Skip to content

Commit 7c2c373

Browse files
jtung-appleArekBalysNordic
authored andcommitted
[Darwin] XPC interface for invoke needs to take into account the reply may contain non-property-list objects (#35131)
1 parent 32e662b commit 7c2c373

File tree

1 file changed

+18
-3
lines changed

1 file changed

+18
-3
lines changed

src/darwin/Framework/CHIP/MTRDeviceController_XPC.mm

+18-3
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,21 @@ @implementation MTRDeviceController_XPC
4343

4444
@synthesize uniqueIdentifier = _uniqueIdentifier;
4545

46+
- (NSXPCInterface *)_interfaceForServerProtocol
47+
{
48+
NSXPCInterface * interface = [NSXPCInterface interfaceWithProtocol:@protocol(MTRXPCServerProtocol)];
49+
50+
NSSet * allowedClasses = [NSSet setWithArray:@[
51+
[NSString class], [NSNumber class], [NSData class], [NSArray class], [NSDictionary class], [NSError class], [MTRCommandPath class], [MTRAttributePath class]
52+
]];
53+
54+
[interface setClasses:allowedClasses
55+
forSelector:@selector(deviceController:nodeID:invokeCommandWithEndpointID:clusterID:commandID:commandFields:expectedValues:expectedValueInterval:timedInvokeTimeout:completion:)
56+
argumentIndex:0
57+
ofReply:YES];
58+
return interface;
59+
}
60+
4661
- (NSXPCInterface *)_interfaceForClientProtocol
4762
{
4863
NSXPCInterface * interface = [NSXPCInterface interfaceWithProtocol:@protocol(MTRXPCClientProtocol)];
@@ -84,7 +99,7 @@ - (id)initWithUniqueIdentifier:(NSUUID *)UUID xpConnectionBlock:(NSXPCConnection
8499

85100
MTR_LOG("Set up XPC Connection: %@", self.xpcConnection);
86101
if (self.xpcConnection) {
87-
self.xpcConnection.remoteObjectInterface = [NSXPCInterface interfaceWithProtocol:@protocol(MTRXPCServerProtocol)];
102+
self.xpcConnection.remoteObjectInterface = [self _interfaceForServerProtocol];
88103

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

119134
MTR_LOG("Set up XPC Connection: %@", self.xpcConnection);
120135
if (self.xpcConnection) {
121-
self.xpcConnection.remoteObjectInterface = [NSXPCInterface interfaceWithProtocol:@protocol(MTRXPCServerProtocol)];
136+
self.xpcConnection.remoteObjectInterface = [self _interfaceForServerProtocol];
122137

123-
self.xpcConnection.exportedInterface = [NSXPCInterface interfaceWithProtocol:@protocol(MTRXPCClientProtocol)];
138+
self.xpcConnection.exportedInterface = [self _interfaceForClientProtocol];
124139
self.xpcConnection.exportedObject = self;
125140

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

0 commit comments

Comments
 (0)