Skip to content

[HVAC] Added Enhanced Scheduling feature for TRV app #38839

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

kliffwong
Copy link

  • Add MSCH feature to TRV cluster

Testing

  • Manual

Copy link

PR #38839: Size comparison from 8167c5f to 0560f34

Increases above 0.2%:

platform target config section 8167c5f 0560f34 change % change
cc32xx air-purifier CC3235SF_LAUNCHXL FLASH 549002 554162 5160 0.9
Full report (3 builds for cc32xx, stm32)
platform target config section 8167c5f 0560f34 change % change
cc32xx air-purifier CC3235SF_LAUNCHXL FLASH 549002 554162 5160 0.9
RAM 205192 205192 0 0.0
lock CC3235SF_LAUNCHXL FLASH 581050 581050 0 0.0
RAM 205440 205440 0 0.0
stm32 light STM32WB5MM-DK FLASH 466052 466052 0 0.0
RAM 141504 141504 0 0.0

Copy link
Contributor

@andy31415 andy31415 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Manual is insufficient detail about what was tested.

please provide detailed description: what did you test, why, what were the observed results, justify why automated testing is impossible in this case.

Cluster functionality seems like it should be automatable. Please try to automate this.

@kliffwong kliffwong marked this pull request as draft May 13, 2025 08:08
@kliffwong kliffwong changed the title [MATTER] Added Enhanced Scheduling feature for TRV app [HVAC] Added Enhanced Scheduling feature for TRV app May 13, 2025
if (!newScheduleHandle.IsNull())
{
size_t newScheduleHandleSize = newScheduleHandle.Value().size();
if (newScheduleHandleSize > kScheduleHandleSize)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (newScheduleHandleSize > kScheduleHandleSize)
if (newScheduleHandleSize > sizeof(scheduleHandleData))

and same in the logging would be clearer.

if (newName.HasValue())
{
size_t newNameSize = newName.Value().size();
if (newNameSize > kScheduleNameSize)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as for the handle.

if (newPresetHandle.HasValue())
{
size_t newPresetHandleSize = newPresetHandle.Value().size();
if (newPresetHandleSize > kSchedulePresetHandleSize)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above.


for (size_t i = 0; i < scheduleTransitionSize; i++)
{
scheduleTransitionData[i] = newTransitions[i];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This does not seem to be keeping a copy of the PresetHandle in the ScheduleTransitionStruct, so this looks like a likely use-after-free.

builtIn = newBuiltIn;
}

Structs::ScheduleTransitionStruct::Type * ScheduleStructWithOwnedMembers::GetTransitionData() const
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How would an API consumer use this?

And in fact, this seems to be unused....

while (iter.Next())
{
ScheduleStruct::DecodableType decodeSchedule = iter.GetValue();
ScheduleTransitionStruct::Type transitions[5];
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where is this 5 coming from?


while (iter2.Next())
{
transitions[i] = iter2.GetValue();
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is a security bug.

{
transitions[i] = iter2.GetValue();
i++;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Where's the iterator status check?


transitions[i] = iter.GetValue();
i++;
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing validity check.

schedule.scheduleHandle = decodeSchedule.scheduleHandle;
schedule.name = decodeSchedule.name;
schedule.presetHandle = decodeSchedule.presetHandle;
schedule.transitions = DataModel::List<const Structs::ScheduleTransitionStruct::Type>(transitions.get(), i);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So why did we heap-allocate the transitions? Couldn't we have just put them on the stack?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants