Skip to content

Commit 6501048

Browse files
committedApr 5, 2024
- improved time zone name changing check
- improved time zone name copying buffer size comparison
1 parent 8ae2293 commit 6501048

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed
 

‎src/app/clusters/time-synchronization-server/time-synchronization-server.cpp

+5-4
Original file line numberDiff line numberDiff line change
@@ -551,9 +551,9 @@ CHIP_ERROR TimeSynchronizationServer::SetTimeZone(const DataModel::DecodableList
551551

552552
if (lastTzState != TimeState::kInvalid)
553553
{
554-
const auto & tzStore = GetTimeZone()[0];
555-
lastTz.offset = tzStore.timeZone.offset;
556-
if (tzStore.timeZone.name.HasValue())
554+
const TimeSyncDataProvider::TimeZoneStore & tzStore = GetTimeZone()[0];
555+
lastTz.offset = tzStore.timeZone.offset;
556+
if (tzStore.timeZone.name.HasValue() && sizeof(name) >= sizeof(tzStore.name))
557557
{
558558
lastTz.name.SetValue(CharSpan(name));
559559
memcpy(name, tzStore.name, sizeof(tzStore.name));
@@ -623,7 +623,8 @@ CHIP_ERROR TimeSynchronizationServer::SetTimeZone(const DataModel::DecodableList
623623
{
624624
emit = true;
625625
}
626-
if ((tz.name.HasValue() && lastTz.name.HasValue()) && !(tz.name.Value().data_equal(lastTz.name.Value())))
626+
if (tz.name.HasValue() != lastTz.name.HasValue() ||
627+
((tz.name.HasValue() && lastTz.name.HasValue()) && !(tz.name.Value().data_equal(lastTz.name.Value()))))
627628
{
628629
emit = true;
629630
}

0 commit comments

Comments
 (0)