Skip to content

Commit 1685c27

Browse files
committed
controller: Harden zwave_controller_transport by checking invalid params
This check is theorical because no z-wave frame is expected to be empty ncp should filter this to some extends. The zapi dispatcher is testing frames pointer, so the risk of exploitation is prevented at higher level. Origin: SiliconLabsSoftware#124 Bug-SiliconLabs: UIC-3668 Relate-to: SLVDBBP-3169975 Relate-to: SiliconLabsSoftware/z-wave-engine-application-layer#42 Signed-off-by: Philippe Coval <[email protected]>
1 parent 96af010 commit 1685c27

File tree

3 files changed

+15
-4
lines changed

3 files changed

+15
-4
lines changed

applications/zpc/components/zwave/zwave_controller/src/zwave_controller_callbacks.c

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -318,8 +318,11 @@ void zwave_controller_on_frame_received(
318318
rx_options,
319319
frame_data,
320320
frame_length);
321+
} else if (status == SL_STATUS_INVALID_PARAMETER) {
322+
sl_log_warning(LOG_TAG,
323+
"zwave_controller_on_frame_received: Invalid params");
321324
}
322-
}
325+
}
323326

324327
void zwave_controller_on_protocol_cc_encryption_request_received(
325328
const zwave_node_id_t destination_node_id,

applications/zpc/components/zwave/zwave_controller/src/zwave_controller_transport.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include "zwave_controller_transport_internal.h"
1616

1717
// Generic includes
18+
#include <assert.h>
1819
#include <string.h>
1920

2021
// ZPC includes
@@ -105,6 +106,11 @@ sl_status_t zwave_controller_transport_on_frame_received(
105106
uint16_t frame_length)
106107
{
107108
const zwave_controller_transport_t *t;
109+
assert(frame_data);
110+
assert(frame_length >= 1);
111+
if (!frame_data || frame_length < 1) {
112+
return (SL_STATUS_INVALID_PARAMETER);
113+
}
108114
t = get_transport_by_class(frame_data[0]);
109115

110116
// Do we support this, we decode this only based of the command class
@@ -165,4 +171,4 @@ sl_status_t
165171
}
166172
}
167173
return SL_STATUS_NOT_FOUND;
168-
}
174+
}

applications/zpc/components/zwave/zwave_controller/src/zwave_controller_transport_internal.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,10 @@ extern "C" {
3737
* @param rx_options Receive specific information
3838
* @param frame_data Pointer to de-encapsulated data
3939
* @param frame_length Length of data
40-
* @return SL_STATUS_NOT_FOUND if no handler was found. Otherwise the status if
41-
* the executed hander list returned
40+
* @return
41+
* SL_STATUS_NOT_FOUND if no handler was found.
42+
* SL_STATUS_INVALID_PARAMETER on invalid frames
43+
* Otherwise the status if the executed hander list returned
4244
*/
4345
sl_status_t zwave_controller_transport_on_frame_received(
4446
const zwave_controller_connection_info_t *connection_info,

0 commit comments

Comments
 (0)