-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Enforce valid spec-conformant string encoding in TLV #30393
Conversation
PR #30393: Size comparison from b0f5983 to e0672dc Increases (3 builds for cc32xx, mbed)
Full report (3 builds for cc32xx, mbed)
|
PR #30393: Size comparison from b0f5983 to 20101ae Increases (72 builds for bl602, bl702, bl702l, cc13x4_26x4, cc32xx, cyw30739, efr32, esp32, k32w, linux, mbed, nrfconnect, psoc6, qpg, telink)
Decreases (2 builds for linux)
Full report (73 builds for bl602, bl702, bl702l, cc13x4_26x4, cc32xx, cyw30739, efr32, esp32, k32w, linux, mbed, nrfconnect, psoc6, qpg, telink)
|
src/app/clusters/time-synchronization-server/time-synchronization-server.cpp
Show resolved
Hide resolved
PR #30393: Size comparison from 08bcb56 to 207c7a7 Increases (72 builds for bl602, bl702, bl702l, cc13x4_26x4, cc32xx, cyw30739, efr32, esp32, k32w, linux, mbed, nrfconnect, psoc6, qpg, telink)
Decreases (3 builds for bl702l, linux)
Full report (73 builds for bl602, bl702, bl702l, cc13x4_26x4, cc32xx, cyw30739, efr32, esp32, k32w, linux, mbed, nrfconnect, psoc6, qpg, telink)
|
@@ -27,8 +27,9 @@ using namespace chip::app::Clusters::TemperatureControl; | |||
using chip::Protocols::InteractionModel::Status; | |||
|
|||
// TODO: Configure your options for each endpoint | |||
CharSpan AppSupportedTemperatureLevelsDelegate::temperatureLevelOptions[] = { CharSpan("Hot", 3), CharSpan("Warm", 4), | |||
CharSpan("Cold", 4) }; | |||
CharSpan AppSupportedTemperatureLevelsDelegate::temperatureLevelOptions[] = { CharSpan::fromCharString("Hot"), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use "Hot"_span
next time @andreilitvin
@@ -209,6 +209,7 @@ struct SceneTableData : public SceneTableEntry, PersistentData<kPersistentSceneB | |||
|
|||
CHIP_ERROR Serialize(TLV::TLVWriter & writer) const override | |||
{ | |||
// TODO: if we have mNameLength, should this bin ByteSpan instead? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't understand this comment.
@@ -551,7 +551,7 @@ void TimeSynchronizationServer::InitTimeZone() | |||
for (auto & tzStore : mTimeZoneObj.timeZoneList) | |||
{ | |||
memset(tzStore.name, 0, sizeof(tzStore.name)); | |||
tzStore.timeZone = { .offset = 0, .validAt = 0, .name = MakeOptional(CharSpan(tzStore.name, sizeof(tzStore.name))) }; | |||
tzStore.timeZone = { .offset = 0, .validAt = 0, .name = MakeOptional(CharSpan(tzStore.name, 0)) }; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks wrong to me. The right thing to set .name
to here is NullOptional
, not empty string.
* Invalid UTF8 string (contains some characters that are invalid) | ||
* | ||
*/ | ||
#define CHIP_ERROR_INVALID_UTF8 CHIP_CORE_ERROR(0x12) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please align the indentation with the other errors.
Changes:
CharSpan::fromCharString
instead ofCharSpan("foo")
because the latter is off-by-one-1
for sizes in a few unit tests because they also used sizeof instead of strlenEnabled check on write, but not on read (since I imagine controllers have to be lenient).
However chip-tool enables this on read too, so that certification/validation catches invalid devices.