Skip to content

Commit 49e7343

Browse files
committed
zapi: Harden more dispatch to prevent invalid data and fix MLK
The previous change (85e13a7) introduced a MLK, and it passed reviews :) That said the risk to leak is low because it is not supposed to happend Origin: SiliconLabsSoftware#132 Bug-SiliconLabs: UIC-3668 Relate-to: SLVDBBP-3169975 Relate-to: SiliconLabsSoftware/z-wave-engine-application-layer#42 Relate-to: SiliconLabsSoftware#124 Signed-off-by: Philippe Coval <[email protected]>
1 parent 575a894 commit 49e7343

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

applications/zpc/components/zwave_api/src/zwapi_init.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,8 +136,10 @@ bool zwapi_poll()
136136
zwapi_session_enqueue_rx_frames();
137137
bool more_frames = zwapi_session_dequeue_frame(&frame, &len);
138138

139-
if (frame && len >=1) {
140-
zwave_api_protocol_rx_dispatch(frame, len);
139+
if (frame) {
140+
if (len >= 1) {
141+
zwave_api_protocol_rx_dispatch(frame, len);
142+
}
141143
free(frame);
142144
}
143145

applications/zpc/components/zwave_command_handler/src/zwave_command_handler.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,6 +87,9 @@ sl_status_t zwave_command_handler_dispatch(
8787
const uint8_t *frame_data,
8888
uint16_t frame_length)
8989
{
90+
assert(connection);
91+
assert(frame_data);
92+
assert(frame_length);
9093
zwave_command_handler_t handler_to_invoke = {};
9194
handler_to_invoke.command_class = frame_data[0];
9295
sl_status_t rc = SL_STATUS_NOT_SUPPORTED;
@@ -313,4 +316,4 @@ void zwave_command_handler_print_info(int fd)
313316
} else {
314317
dprintf(fd, "%s", ss.str().c_str());
315318
}
316-
}
319+
}

0 commit comments

Comments
 (0)