diff options
| author | Jim Mussared <jim.mussared@gmail.com> | 2021-07-21 17:02:01 +1000 |
|---|---|---|
| committer | Damien George <damien@micropython.org> | 2021-07-23 21:57:58 +1000 |
| commit | 53dfb279da4c2502c5040227329b06e3ea79fd63 (patch) | |
| tree | cc5ae426445b6f4591920f5097ac5a7582969d5e | |
| parent | 92464f11b0db59456a7cf3f1181f38c200a29210 (diff) | |
extmod/modbluetooth: Clamp MTU values to 32->UINT16_MAX.
| -rw-r--r-- | extmod/modbluetooth.c | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/extmod/modbluetooth.c b/extmod/modbluetooth.c index e379a8c6a..bf8d071a9 100644 --- a/extmod/modbluetooth.c +++ b/extmod/modbluetooth.c @@ -842,7 +842,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_2(bluetooth_ble_gattc_exchange_mtu_obj, bluetooth STATIC mp_obj_t bluetooth_ble_l2cap_listen(mp_obj_t self_in, mp_obj_t psm_in, mp_obj_t mtu_in) { (void)self_in; mp_int_t psm = mp_obj_get_int(psm_in); - mp_int_t mtu = mp_obj_get_int(mtu_in); + mp_int_t mtu = MAX(32, MIN(UINT16_MAX, mp_obj_get_int(mtu_in))); return bluetooth_handle_errno(mp_bluetooth_l2cap_listen(psm, mtu)); } STATIC MP_DEFINE_CONST_FUN_OBJ_3(bluetooth_ble_l2cap_listen_obj, bluetooth_ble_l2cap_listen); @@ -850,7 +850,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_3(bluetooth_ble_l2cap_listen_obj, bluetooth_ble_l STATIC mp_obj_t bluetooth_ble_l2cap_connect(size_t n_args, const mp_obj_t *args) { mp_int_t conn_handle = mp_obj_get_int(args[1]); mp_int_t psm = mp_obj_get_int(args[2]); - mp_int_t mtu = mp_obj_get_int(args[3]); + mp_int_t mtu = MAX(32, MIN(UINT16_MAX, mp_obj_get_int(args[3]))); return bluetooth_handle_errno(mp_bluetooth_l2cap_connect(conn_handle, psm, mtu)); } STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(bluetooth_ble_l2cap_connect_obj, 4, 4, bluetooth_ble_l2cap_connect); |
