Skip to content

Commit 75e1ade

Browse files
willmmilessofthack007
authored andcommitted
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.
1 parent 7a0f093 commit 75e1ade

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

wled00/ota_update.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -453,9 +453,9 @@ String getBootloaderSHA256Hex() {
453453
String result;
454454
result.reserve(65);
455455
for (int i = 0; i < 32; i++) {
456-
unsigned char b1 = bootloaderSHA256Cache[i];
457-
unsigned char b2 = b1 >> 4; // bugfix: right-shift on signed char is undefined behaviour
458-
b1 &= 0x0F;
456+
char b1 = bootloaderSHA256Cache[i];
457+
char b2 = b1 >> 4;
458+
b1 &= 0x0F; b2 &= 0x0F; // drop unneeded bits, including possible junk from arithmetic right shift
459459
b1 += '0'; b2 += '0';
460460
if (b1 > '9') b1 += 39;
461461
if (b2 > '9') b2 += 39;

0 commit comments

Comments
 (0)