Fix undefined behavior in bootloader SHA256 hex conversion

Change char to unsigned char to avoid undefined behavior during right-shift operation.
This commit is contained in:
Frank Möhle
2026-03-21 15:43:06 +01:00
committed by GitHub
parent 1f92ac1c8b
commit afb383d0a2

View File

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