Skip to content

Commit 7458a11

Browse files
committed
Conduct fabric-filtered read on CurrentSessions attribute
1 parent 82f2b49 commit 7458a11

File tree

2 files changed

+23
-10
lines changed

2 files changed

+23
-10
lines changed

src/app/clusters/webrtc-transport-provider-server/webrtc-transport-provider-server.cpp

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -91,11 +91,16 @@ CHIP_ERROR WebRTCTransportProviderServer::Read(const ConcreteReadAttributePath &
9191
// which is a list[WebRTCSessionStruct].
9292
if (aPath.mClusterId == Id && aPath.mAttributeId == Attributes::CurrentSessions::Id)
9393
{
94-
// We encode mCurrentSessions as a list of WebRTCSessionStruct
95-
return aEncoder.EncodeList([this](const auto & encoder) -> CHIP_ERROR {
94+
// CurrentSessions is a fabric-scoped attribute that must only return sessions belonging to the accessing fabric.
95+
FabricIndex accessingFabricIndex = aEncoder.AccessingFabricIndex();
96+
return aEncoder.EncodeList([this, accessingFabricIndex](const auto & encoder) -> CHIP_ERROR {
9697
for (auto & session : mCurrentSessions)
9798
{
98-
ReturnErrorOnFailure(encoder.Encode(session));
99+
// Only encode sessions that belong to the accessing fabric
100+
if (session.GetFabricIndex() == accessingFabricIndex)
101+
{
102+
ReturnErrorOnFailure(encoder.Encode(session));
103+
}
99104
}
100105
return CHIP_NO_ERROR;
101106
});

src/app/clusters/webrtc-transport-requestor-server/webrtc-transport-requestor-cluster.cpp

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -67,13 +67,21 @@ DataModel::ActionReturnStatus WebRTCTransportRequestorServer::ReadAttribute(cons
6767
switch (request.path.mAttributeId)
6868
{
6969
case CurrentSessions::Id:
70-
return encoder.EncodeList([this](const auto & listEncoder) -> CHIP_ERROR {
71-
for (auto & session : mCurrentSessions)
72-
{
73-
ReturnErrorOnFailure(listEncoder.Encode(session));
74-
}
75-
return CHIP_NO_ERROR;
76-
});
70+
// CurrentSessions is a fabric-scoped attribute that must only return sessions belonging to the accessing fabric.
71+
{
72+
FabricIndex accessingFabricIndex = encoder.AccessingFabricIndex();
73+
return encoder.EncodeList([this, accessingFabricIndex](const auto & listEncoder) -> CHIP_ERROR {
74+
for (auto & session : mCurrentSessions)
75+
{
76+
// Only encode sessions that belong to the accessing fabric
77+
if (session.GetFabricIndex() == accessingFabricIndex)
78+
{
79+
ReturnErrorOnFailure(listEncoder.Encode(session));
80+
}
81+
}
82+
return CHIP_NO_ERROR;
83+
});
84+
}
7785
case ClusterRevision::Id:
7886
return encoder.Encode(kRevision);
7987
case FeatureMap::Id:

0 commit comments

Comments
 (0)