From 3b6f3b11bba79c713e11b497e0180ab106b11555 Mon Sep 17 00:00:00 2001 From: chklump Date: Fri, 27 Aug 2021 14:04:06 +0200 Subject: [PATCH] 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. --- .../service/devices/zetime/ZeTimeDeviceSupport.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/zetime/ZeTimeDeviceSupport.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/zetime/ZeTimeDeviceSupport.java index 783bfb5875..be9b373732 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/zetime/ZeTimeDeviceSupport.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/service/devices/zetime/ZeTimeDeviceSupport.java @@ -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;