From f3ca4ab2e78f529530c2bfcf51b3aa464b1c7e79 Mon Sep 17 00:00:00 2001 From: Misa Date: Wed, 4 Aug 2021 21:00:50 -0700 Subject: [PATCH] Fix generateBase36 generating more than base 36 Two problems: the fRandom() range was from 0..36, but that's 37 characters, not 36. And the check to sort the lower 26 values into the Latin alphabet used a 'lesser-than-or-equal-to 26' check, even though that checks for the range of values of 0..26, which is 27 letters, even though the alphabet only has 26 letters. So just drop the equals sign from that check. --- desktop_version/src/FileSystemUtils.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/desktop_version/src/FileSystemUtils.cpp b/desktop_version/src/FileSystemUtils.cpp index 5c0dc034..ecad6a08 100644 --- a/desktop_version/src/FileSystemUtils.cpp +++ b/desktop_version/src/FileSystemUtils.cpp @@ -251,8 +251,8 @@ static void generateBase36(char* string, const size_t string_size) for (i = 0; i < string_size - 1; ++i) { /* a-z0-9 */ - char randchar = fRandom() * 36; - if (randchar <= 26) + char randchar = fRandom() * 35; + if (randchar < 26) { randchar += 'a'; }