Skip to content

Commit 26498f7

Browse files
committed
fix(zwave_rx): Harden zwave_rx_zwapi_callbacks.c
Add extra check to prevent small buffers attacks. Bug-SiliconLabs: UIC-3672 Relate-to: SLVDBBP-3169959 Signed-off-by: Philippe Coval <philippe.coval@silabs.com>
1 parent 3c27ce8 commit 26498f7

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

applications/zpc/components/zwave/zwave_rx/src/zwave_rx_zwapi_callbacks.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -206,8 +206,11 @@ static void
206206
uint8_t zwapi_zwave_nif_length,
207207
zwave_node_info_t *destination_node_info)
208208
{
209+
static const int header_offset = 3;
209210
if (zwapi_zwave_nif == NULL || destination_node_info == NULL
210-
|| zwapi_zwave_nif_length == 0) {
211+
|| zwapi_zwave_nif_length == 0
212+
|| zwapi_zwave_nif_length <= header_offset // For zwave_command_class_list_unpack
213+
) {
211214
return;
212215
}
213216

@@ -239,7 +242,7 @@ static void
239242

240243
zwave_command_class_list_unpack(destination_node_info,
241244
&zwapi_zwave_nif[index],
242-
zwapi_zwave_nif_length - 3);
245+
zwapi_zwave_nif_length - header_offset);
243246
}
244247

245248
void zwave_rx_poll_request()

0 commit comments

Comments
 (0)