From c3a52c596924f104db77c610598970a738cc107c Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Tue, 26 Oct 2021 14:03:54 +0200 Subject: [PATCH] MDT: prevent ArrayIndexOutOfBoundsException --- .../plugins/pump/medtronic/comm/MedtronicConverter.kt | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/comm/MedtronicConverter.kt b/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/comm/MedtronicConverter.kt index 86c04e3e90..1c64e92ec8 100644 --- a/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/comm/MedtronicConverter.kt +++ b/medtronic/src/main/java/info/nightscout/androidaps/plugins/pump/medtronic/comm/MedtronicConverter.kt @@ -94,6 +94,10 @@ class MedtronicConverter @Inject constructor( } fun decodeTime(rawContent: ByteArray): LocalDateTime? { + if (rawContent.size < 7) { + aapsLogger.error(LTag.PUMPCOMM, "decodeTime: Byte array too short") + return null + } val hours = ByteUtil.asUINT8(rawContent[0]) val minutes = ByteUtil.asUINT8(rawContent[1]) val seconds = ByteUtil.asUINT8(rawContent[2])