From 6a08317dde8713595d8697850cc7e2c5616dac95 Mon Sep 17 00:00:00 2001 From: Raphael Coeffic Date: Sat, 8 May 2021 00:22:58 +0200 Subject: [PATCH] Filter out invalid chars to avoid out-of-bounds memory access --- radio/src/gui/colorlcd/lcd.cpp | 4 ++-- radio/src/thirdparty/libopenui | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/radio/src/gui/colorlcd/lcd.cpp b/radio/src/gui/colorlcd/lcd.cpp index 445db8ff8..7b6017697 100644 --- a/radio/src/gui/colorlcd/lcd.cpp +++ b/radio/src/gui/colorlcd/lcd.cpp @@ -58,7 +58,7 @@ int getTextWidth(const char * s, int len, LcdFlags flags) if (!c) { break; } - else if (c >= 0xFE) { + else if (c >= 0xFE) { // CJK marker s++; c = uint8_t(*s) + ((c & 0x01) << 8) - 1; if (c >= 0x101) @@ -66,7 +66,7 @@ int getTextWidth(const char * s, int len, LcdFlags flags) c += CJK_FIRST_LETTER_INDEX; result += getFontPatternWidth(specs, c) + 1; } - else if (c >= 0x20) { + else if ((c >= 0x20) && (c < CJK_FIRST_LETTER_INDEX + 0x20)) { // debug result += getCharWidth(c, specs); } diff --git a/radio/src/thirdparty/libopenui b/radio/src/thirdparty/libopenui index 48c83e701..7c2c8512b 160000 --- a/radio/src/thirdparty/libopenui +++ b/radio/src/thirdparty/libopenui @@ -1 +1 @@ -Subproject commit 48c83e701d2fe7562e2e320d1e210d71e09cdc7c +Subproject commit 7c2c8512b3499f7968629a3021c2d308f34d79e2