Huami: Prevent setting an MTU of < 23, which is either a special value or a parsing error of Gadgetbridge

This fixes a problem where writeToChunked algorithm results in out of bounds writes or an endless loop.

Closes #1936
This commit is contained in:
Andreas Shimokawa 2020-08-02 13:11:41 +02:00
parent f9dc625c5c
commit a619fdb168
1 changed files with 4 additions and 0 deletions

View File

@ -1279,6 +1279,10 @@ public class HuamiSupport extends AbstractBTLEDeviceSupport {
if (!prefs.getBoolean(PREF_ALLOW_HIGH_MTU, false)) {
break;
}
if (mtu < 23) {
LOG.error("Device announced unreasonable low MTU of " + mtu + ", ignoring");
break;
}
mMTU = mtu;
/*
* not really sure if this would make sense, is this event already a proof of a successful MTU