1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-10-02 11:17:00 +02:00

Fix body_length overflow for long notifications.

The body_length field in the header is only one byte (byte 8). If it it is set to 256 it overflows to 0 wich results in a corrupt notification. So the maximum body length is 255.
This commit is contained in:
chklump 2021-08-27 14:04:06 +02:00
parent 86ccd408cd
commit 3b6f3b11bb

View File

@ -731,8 +731,8 @@ public class ZeTimeDeviceSupport extends AbstractBTLEDeviceSupport {
int subject_length = 0;
int body_length = notificationSpec.body.getBytes(StandardCharsets.UTF_8).length;
if (body_length > 256) {
body_length = 256;
if (body_length > 255) {
body_length = 255;
}
int notification_length = body_length;
byte[] subject = null;