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