Skip to content

Commit

Permalink
Ensure that read attribute paths are valid paths. (#17664)
Browse files Browse the repository at this point in the history
Disallow out-of-range attribute ids and wildcard cluster with
non-wildcard non-global attribute.

Fixes #14026
  • Loading branch information
bzbarsky-apple authored and pull[bot] committed Nov 6, 2023
1 parent ec749d2 commit 1966722
Show file tree
Hide file tree
Showing 20 changed files with 738 additions and 687 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3109,39 +3109,39 @@ server cluster TestCluster = 1295 {
attribute boolean timedWriteBoolean = 48;
attribute boolean generalErrorBoolean = 49;
attribute boolean clusterErrorBoolean = 50;
attribute nullable boolean nullableBoolean = 32768;
attribute nullable Bitmap8MaskMap nullableBitmap8 = 32769;
attribute nullable Bitmap16MaskMap nullableBitmap16 = 32770;
attribute nullable Bitmap32MaskMap nullableBitmap32 = 32771;
attribute nullable Bitmap64MaskMap nullableBitmap64 = 32772;
attribute nullable int8u nullableInt8u = 32773;
attribute nullable int16u nullableInt16u = 32774;
attribute nullable int24u nullableInt24u = 32775;
attribute nullable int32u nullableInt32u = 32776;
attribute nullable int40u nullableInt40u = 32777;
attribute nullable int48u nullableInt48u = 32778;
attribute nullable int56u nullableInt56u = 32779;
attribute nullable int64u nullableInt64u = 32780;
attribute nullable int8s nullableInt8s = 32781;
attribute nullable int16s nullableInt16s = 32782;
attribute nullable int24s nullableInt24s = 32783;
attribute nullable int32s nullableInt32s = 32784;
attribute nullable int40s nullableInt40s = 32785;
attribute nullable int48s nullableInt48s = 32786;
attribute nullable int56s nullableInt56s = 32787;
attribute nullable int64s nullableInt64s = 32788;
attribute nullable enum8 nullableEnum8 = 32789;
attribute nullable enum16 nullableEnum16 = 32790;
attribute nullable single nullableFloatSingle = 32791;
attribute nullable double nullableFloatDouble = 32792;
attribute nullable octet_string<10> nullableOctetString = 32793;
attribute nullable char_string<10> nullableCharString = 32798;
attribute nullable SimpleEnum nullableEnumAttr = 32804;
attribute nullable SimpleStruct nullableStruct = 32805;
attribute nullable int8u nullableRangeRestrictedInt8u = 32806;
attribute nullable int8s nullableRangeRestrictedInt8s = 32807;
attribute nullable int16u nullableRangeRestrictedInt16u = 32808;
attribute nullable int16s nullableRangeRestrictedInt16s = 32809;
attribute nullable boolean nullableBoolean = 16384;
attribute nullable Bitmap8MaskMap nullableBitmap8 = 16385;
attribute nullable Bitmap16MaskMap nullableBitmap16 = 16386;
attribute nullable Bitmap32MaskMap nullableBitmap32 = 16387;
attribute nullable Bitmap64MaskMap nullableBitmap64 = 16388;
attribute nullable int8u nullableInt8u = 16389;
attribute nullable int16u nullableInt16u = 16390;
attribute nullable int24u nullableInt24u = 16391;
attribute nullable int32u nullableInt32u = 16392;
attribute nullable int40u nullableInt40u = 16393;
attribute nullable int48u nullableInt48u = 16394;
attribute nullable int56u nullableInt56u = 16395;
attribute nullable int64u nullableInt64u = 16396;
attribute nullable int8s nullableInt8s = 16397;
attribute nullable int16s nullableInt16s = 16398;
attribute nullable int24s nullableInt24s = 16399;
attribute nullable int32s nullableInt32s = 16400;
attribute nullable int40s nullableInt40s = 16401;
attribute nullable int48s nullableInt48s = 16402;
attribute nullable int56s nullableInt56s = 16403;
attribute nullable int64s nullableInt64s = 16404;
attribute nullable enum8 nullableEnum8 = 16405;
attribute nullable enum16 nullableEnum16 = 16406;
attribute nullable single nullableFloatSingle = 16407;
attribute nullable double nullableFloatDouble = 16408;
attribute nullable octet_string<10> nullableOctetString = 16409;
attribute nullable char_string<10> nullableCharString = 16414;
attribute nullable SimpleEnum nullableEnumAttr = 16420;
attribute nullable SimpleStruct nullableStruct = 16421;
attribute nullable int8u nullableRangeRestrictedInt8u = 16422;
attribute nullable int8s nullableRangeRestrictedInt8s = 16423;
attribute nullable int16u nullableRangeRestrictedInt16u = 16424;
attribute nullable int16s nullableRangeRestrictedInt16s = 16425;
readonly attribute int16u clusterRevision = 65533;

request struct TestAddArgumentsRequest {
Expand Down
66 changes: 33 additions & 33 deletions examples/all-clusters-app/all-clusters-common/all-clusters-app.zap
Original file line number Diff line number Diff line change
Expand Up @@ -17613,7 +17613,7 @@
},
{
"name": "nullable_boolean",
"code": 32768,
"code": 16384,
"mfgCode": null,
"side": "server",
"included": 1,
Expand All @@ -17628,7 +17628,7 @@
},
{
"name": "nullable_bitmap8",
"code": 32769,
"code": 16385,
"mfgCode": null,
"side": "server",
"included": 1,
Expand All @@ -17643,7 +17643,7 @@
},
{
"name": "nullable_bitmap16",
"code": 32770,
"code": 16386,
"mfgCode": null,
"side": "server",
"included": 1,
Expand All @@ -17658,7 +17658,7 @@
},
{
"name": "nullable_bitmap32",
"code": 32771,
"code": 16387,
"mfgCode": null,
"side": "server",
"included": 1,
Expand All @@ -17673,7 +17673,7 @@
},
{
"name": "nullable_bitmap64",
"code": 32772,
"code": 16388,
"mfgCode": null,
"side": "server",
"included": 1,
Expand All @@ -17688,7 +17688,7 @@
},
{
"name": "nullable_int8u",
"code": 32773,
"code": 16389,
"mfgCode": null,
"side": "server",
"included": 1,
Expand All @@ -17703,7 +17703,7 @@
},
{
"name": "nullable_int16u",
"code": 32774,
"code": 16390,
"mfgCode": null,
"side": "server",
"included": 1,
Expand All @@ -17718,7 +17718,7 @@
},
{
"name": "nullable_int24u",
"code": 32775,
"code": 16391,
"mfgCode": null,
"side": "server",
"included": 1,
Expand All @@ -17733,7 +17733,7 @@
},
{
"name": "nullable_int32u",
"code": 32776,
"code": 16392,
"mfgCode": null,
"side": "server",
"included": 1,
Expand All @@ -17748,7 +17748,7 @@
},
{
"name": "nullable_int40u",
"code": 32777,
"code": 16393,
"mfgCode": null,
"side": "server",
"included": 1,
Expand All @@ -17763,7 +17763,7 @@
},
{
"name": "nullable_int48u",
"code": 32778,
"code": 16394,
"mfgCode": null,
"side": "server",
"included": 1,
Expand All @@ -17778,7 +17778,7 @@
},
{
"name": "nullable_int56u",
"code": 32779,
"code": 16395,
"mfgCode": null,
"side": "server",
"included": 1,
Expand All @@ -17793,7 +17793,7 @@
},
{
"name": "nullable_int64u",
"code": 32780,
"code": 16396,
"mfgCode": null,
"side": "server",
"included": 1,
Expand All @@ -17808,7 +17808,7 @@
},
{
"name": "nullable_int8s",
"code": 32781,
"code": 16397,
"mfgCode": null,
"side": "server",
"included": 1,
Expand All @@ -17823,7 +17823,7 @@
},
{
"name": "nullable_int16s",
"code": 32782,
"code": 16398,
"mfgCode": null,
"side": "server",
"included": 1,
Expand All @@ -17838,7 +17838,7 @@
},
{
"name": "nullable_int24s",
"code": 32783,
"code": 16399,
"mfgCode": null,
"side": "server",
"included": 1,
Expand All @@ -17853,7 +17853,7 @@
},
{
"name": "nullable_int32s",
"code": 32784,
"code": 16400,
"mfgCode": null,
"side": "server",
"included": 1,
Expand All @@ -17868,7 +17868,7 @@
},
{
"name": "nullable_int40s",
"code": 32785,
"code": 16401,
"mfgCode": null,
"side": "server",
"included": 1,
Expand All @@ -17883,7 +17883,7 @@
},
{
"name": "nullable_int48s",
"code": 32786,
"code": 16402,
"mfgCode": null,
"side": "server",
"included": 1,
Expand All @@ -17898,7 +17898,7 @@
},
{
"name": "nullable_int56s",
"code": 32787,
"code": 16403,
"mfgCode": null,
"side": "server",
"included": 1,
Expand All @@ -17913,7 +17913,7 @@
},
{
"name": "nullable_int64s",
"code": 32788,
"code": 16404,
"mfgCode": null,
"side": "server",
"included": 1,
Expand All @@ -17928,7 +17928,7 @@
},
{
"name": "nullable_enum8",
"code": 32789,
"code": 16405,
"mfgCode": null,
"side": "server",
"included": 1,
Expand All @@ -17943,7 +17943,7 @@
},
{
"name": "nullable_enum16",
"code": 32790,
"code": 16406,
"mfgCode": null,
"side": "server",
"included": 1,
Expand All @@ -17958,7 +17958,7 @@
},
{
"name": "nullable_float_single",
"code": 32791,
"code": 16407,
"mfgCode": null,
"side": "server",
"included": 1,
Expand All @@ -17973,7 +17973,7 @@
},
{
"name": "nullable_float_double",
"code": 32792,
"code": 16408,
"mfgCode": null,
"side": "server",
"included": 1,
Expand All @@ -17988,7 +17988,7 @@
},
{
"name": "nullable_octet_string",
"code": 32793,
"code": 16409,
"mfgCode": null,
"side": "server",
"included": 1,
Expand All @@ -18003,7 +18003,7 @@
},
{
"name": "nullable_char_string",
"code": 32798,
"code": 16414,
"mfgCode": null,
"side": "server",
"included": 1,
Expand All @@ -18018,7 +18018,7 @@
},
{
"name": "nullable_enum_attr",
"code": 32804,
"code": 16420,
"mfgCode": null,
"side": "server",
"included": 1,
Expand All @@ -18033,7 +18033,7 @@
},
{
"name": "nullable_struct",
"code": 32805,
"code": 16421,
"mfgCode": null,
"side": "server",
"included": 1,
Expand All @@ -18048,7 +18048,7 @@
},
{
"name": "nullable_range_restricted_int8u",
"code": 32806,
"code": 16422,
"mfgCode": null,
"side": "server",
"included": 1,
Expand All @@ -18063,7 +18063,7 @@
},
{
"name": "nullable_range_restricted_int8s",
"code": 32807,
"code": 16423,
"mfgCode": null,
"side": "server",
"included": 1,
Expand All @@ -18078,7 +18078,7 @@
},
{
"name": "nullable_range_restricted_int16u",
"code": 32808,
"code": 16424,
"mfgCode": null,
"side": "server",
"included": 1,
Expand All @@ -18093,7 +18093,7 @@
},
{
"name": "nullable_range_restricted_int16s",
"code": 32809,
"code": 16425,
"mfgCode": null,
"side": "server",
"included": 1,
Expand Down
7 changes: 2 additions & 5 deletions src/app/InteractionModelEngine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -389,14 +389,11 @@ CHIP_ERROR InteractionModelEngine::OnReadInitialRequest(Messaging::ExchangeConte
{
aStatus = Protocols::InteractionModel::Status::ResourceExhausted;
}
else if (err.IsIMStatus())
else
{
aStatus = StatusIB(err).mStatus;
}
ReturnErrorOnFailure(err);

aStatus = Protocols::InteractionModel::Status::Success;
return CHIP_NO_ERROR;
return err;
}

ChipLogProgress(InteractionModel, "no resource for %s interaction",
Expand Down
2 changes: 1 addition & 1 deletion src/app/MessageDef/StatusIB.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ CHIP_ERROR StatusIB::Parser::CheckSchemaValidity() const

#if CHIP_DETAIL_LOGGING
{
uint16_t status;
uint8_t status;
ReturnErrorOnFailure(reader.Get(status));
PRETTY_PRINT("\tstatus = " ChipLogFormatIMStatus ",", ChipLogValueIMStatus(static_cast<Status>(status)));
}
Expand Down
Loading

0 comments on commit 1966722

Please sign in to comment.