From e92c9dbbb5a9ed4e9ab57e89c6e15bc988d6509c Mon Sep 17 00:00:00 2001 From: cpfeiffer Date: Tue, 4 Aug 2015 23:08:40 +0200 Subject: [PATCH] Better check for fw version major (#30) --- .../gadgetbridge/devices/miband/MiBandFWHelper.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/miband/MiBandFWHelper.java b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/miband/MiBandFWHelper.java index 6195a29c..cf9c148b 100644 --- a/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/miband/MiBandFWHelper.java +++ b/app/src/main/java/nodomain/freeyourgadget/gadgetbridge/devices/miband/MiBandFWHelper.java @@ -38,7 +38,7 @@ public class MiBandFWHelper { try (InputStream in = new BufferedInputStream(cr.openInputStream(uri))){ this.fw = FileUtils.readAll(in, 1024 * 1024); // 1 MB - if (fw.length > firmwareVersionMajor && fw[firmwareVersionMajor] != 1) { + if (fw.length <= firmwareVersionMajor || fw[firmwareVersionMajor] != 1) { throw new IOException("Firmware major version should be 1, probably this isn't a MiBand firmware."); } } catch (Exception e) {