From 47acfd27753851e7af405423583f969a4af7a090 Mon Sep 17 00:00:00 2001 From: MrYoranimo Date: Mon, 23 Sep 2024 09:32:22 +0200 Subject: [PATCH] Xiaomi: fix watchface ID check The identifier for a watch face is stored as a decimal number in ASCII. Since there are 64 bytes available to store the identifier, the highest value to be expected is 10^(64*10), which exceeds the limit of a 32-bit integer. --- .../gadgetbridge/devices/xiaomi/XiaomiFWHelper.java | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/xiaomi/XiaomiFWHelper.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/xiaomi/XiaomiFWHelper.java index e46b1f862..b72cdd0d4 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/xiaomi/XiaomiFWHelper.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/xiaomi/XiaomiFWHelper.java @@ -25,6 +25,7 @@ import org.slf4j.LoggerFactory; import java.io.BufferedInputStream; import java.io.IOException; import java.io.InputStream; +import java.util.regex.Pattern; import nodomain.freeyourgadget.gadgetbridge.util.FileUtils; import nodomain.freeyourgadget.gadgetbridge.util.StringUtils; @@ -140,9 +141,7 @@ public class XiaomiFWHelper { return false; } - try { - Integer.parseInt(id); - } catch (final Exception e) { + if (!Pattern.matches("^\\d+$", id)) { LOG.warn("Id {} not a number", id); return false; }