Use correct fix for SHA256 hash string

@coderabbitai caught the problem, but its fix suggestion was out to
lunch on this one.  Passing an unsigned char to String.concat() appends
it as a number instead of appending the character.

Instead, mask the unneceeded bits.
This commit is contained in:
Will Miles
2026-03-22 08:36:06 -04:00
committed by Frank
parent 7a0f093ab1
commit 75e1ade22f

View File

@@ -453,9 +453,9 @@ String getBootloaderSHA256Hex() {
String result;
result.reserve(65);
for (int i = 0; i < 32; i++) {
unsigned char b1 = bootloaderSHA256Cache[i];
unsigned char b2 = b1 >> 4; // bugfix: right-shift on signed char is undefined behaviour
b1 &= 0x0F;
char b1 = bootloaderSHA256Cache[i];
char b2 = b1 >> 4;
b1 &= 0x0F; b2 &= 0x0F; // drop unneeded bits, including possible junk from arithmetic right shift
b1 += '0'; b2 += '0';
if (b1 > '9') b1 += 39;
if (b2 > '9') b2 += 39;