From afb383d0a224a373c3d998c7663a42383292cce4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Frank=20M=C3=B6hle?= <91616163+softhack007@users.noreply.github.com> Date: Sat, 21 Mar 2026 15:43:06 +0100 Subject: [PATCH] Fix undefined behavior in bootloader SHA256 hex conversion Change char to unsigned char to avoid undefined behavior during right-shift operation. --- wled00/ota_update.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/wled00/ota_update.cpp b/wled00/ota_update.cpp index a0bf31d3..904a242b 100644 --- a/wled00/ota_update.cpp +++ b/wled00/ota_update.cpp @@ -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; @@ -780,4 +780,4 @@ void handleBootloaderOTAData(AsyncWebServerRequest *request, size_t index, uint8 // ------------------------------------- -#endif \ No newline at end of file +#endif