Skip to content

Commit 063f413

Browse files
committed
fix(cc): Fix class_configuration_control check with frame without cmd
Test has been hardened as well, without the fix it will fail Origin: SiliconLabsSoftware#116 Relate-to: SiliconLabsSoftware#110 (comment) Relate-to: SiliconLabsSoftware#111 (comment) Thanks-to: Laudin Molina Troconis <[email protected]> Relate-to: SiliconLabsSoftware/z-wave-engine-application-layer#10 Signed-off-by: Philippe Coval <[email protected]>
1 parent b025c53 commit 063f413

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

applications/zpc/components/zwave_command_classes/src/zwave_command_class_configuration_control.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -915,7 +915,7 @@ static sl_status_t zwave_command_class_configuration_control_handler(
915915
const uint8_t *frame,
916916
uint16_t frame_length)
917917
{
918-
if (frame_length < COMMAND_INDEX) {
918+
if (frame_length <= COMMAND_INDEX) {
919919
return SL_STATUS_NOT_SUPPORTED;
920920
}
921921

applications/zpc/components/zwave_command_classes/test/zwave_command_class_configuration_control_test.c

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1626,14 +1626,18 @@ void test_zwave_command_class_configuration_unknown_command()
16261626

16271627
void test_zwave_command_class_configuration_no_command()
16281628
{
1629-
const uint8_t incoming_frame[] = {COMMAND_CLASS_CONFIGURATION_V4};
1629+
const uint8_t incoming_frame[] = {
1630+
COMMAND_CLASS_CONFIGURATION_V4,
1631+
CONFIGURATION_REPORT_V4 // Add deterministic valid value for overflow check
1632+
};
16301633

16311634
TEST_ASSERT_NOT_NULL(configuration_handler.control_handler);
1632-
TEST_ASSERT_EQUAL(
1633-
SL_STATUS_NOT_SUPPORTED,
1634-
configuration_handler.control_handler(&connection_info,
1635-
incoming_frame,
1636-
sizeof(incoming_frame)));
1635+
TEST_ASSERT_EQUAL(SL_STATUS_NOT_SUPPORTED,
1636+
configuration_handler.control_handler(
1637+
&connection_info,
1638+
incoming_frame,
1639+
sizeof(incoming_frame) - 1 // Remove padding
1640+
));
16371641
}
16381642

16391643
void test_zwave_command_class_configuration_non_existing_parameter()
@@ -1968,4 +1972,4 @@ void test_give_up_on_configuration_get_v3_node()
19681972
on_configuration_get_failure(test_node);
19691973
TEST_ASSERT_TRUE(attribute_store_node_exists(parameter_id_node));
19701974
TEST_ASSERT_TRUE(attribute_store_node_exists(test_node));
1971-
}
1975+
}

0 commit comments

Comments
 (0)