1
0
mirror of https://codeberg.org/Freeyourgadget/Gadgetbridge synced 2024-06-20 12:00:51 +02:00

Fossil/Skagen Hybrids: Fix crash on multi-byte unicode characters in menu

The FosslAppWriter was writing string length instead of the bytes length
into the wapp file, causing a crash when reading the file.

Fixes #3577
This commit is contained in:
Arjan Schrijver 2024-02-17 21:25:25 +01:00
parent ad256fade0
commit 122ff5f7f4

View File

@ -146,7 +146,7 @@ public class FossilAppWriter {
for (String filename : stringsMap.keySet()) {
output.write((byte)filename.length() + 1);
output.write(StringUtils.terminateNull(filename).getBytes(StandardCharsets.UTF_8));
output.write(shortToLEBytes((short)(stringsMap.get(filename).length() + 1)));
output.write(shortToLEBytes((short)(stringsMap.get(filename).getBytes(StandardCharsets.UTF_8).length + 1)));
output.write(StringUtils.terminateNull(stringsMap.get(filename)).getBytes(StandardCharsets.UTF_8));
}
return output.toByteArray();