fix: Prevent invalid map bounds #123

This commit is contained in:
Janez T
2026-03-16 22:16:36 +01:00
parent cfd233d38e
commit 993563f059
11 changed files with 129 additions and 25 deletions

View File

@@ -23,10 +23,13 @@ class RouteHashPreferences {
static int normalizeSync(int value) => _normalize(value);
/// Valid hash sizes per the MeshCore protocol.
/// The path encoding uses 2 bits: 00=1B, 01=2B, 10=3B, 11=4B.
/// The official app offers 1, 2, 4 (skipping 3).
static const List<int> supportedSizes = [1, 2, 4];
static int _normalize(int value) {
if (value < 1 || value > 3) {
return defaultHashSize;
}
return value;
if (supportedSizes.contains(value)) return value;
return defaultHashSize;
}
}