mesh: Fix overflow of ivu_duration value

Bluetooth Mesh require minimum limit time to enter iv update
state or return to iv nornal state.

For Zephyr bluetooth mesh implementation, use`ivu_duration`
type `uint8_t` to represent current time, but if the time is
more than 255 hours, there will be problems due to the
overflow of 8-bit unassigned variables.

This is port of f105455ebe6930c5004d46ffdc996aafa18fc593
This commit is contained in:
Krzysztof Kopyściński
2021-01-12 14:05:19 +01:00
committed by Łukasz Rymanowski
parent 6681f63b32
commit bf6c4196fd
+2 -1
View File
@@ -815,7 +815,8 @@ done:
static void ivu_refresh(struct ble_npl_event *work)
{
bt_mesh.ivu_duration += BT_MESH_IVU_HOURS;
bt_mesh.ivu_duration = MIN(UINT8_MAX,
bt_mesh.ivu_duration + BT_MESH_IVU_HOURS);
BT_DBG("%s for %u hour%s",
atomic_test_bit(bt_mesh.flags, BT_MESH_IVU_IN_PROGRESS) ?