[riot-notifications] [RIOT-OS/RIOT] sys/crypto/aes: avoid UB by explicit unsigned integer promotion (#10785)

Kaspar Schleiser notifications at github.com
Thu Jan 17 12:10:14 CET 2019


kaspar030 commented on this pull request.



> @@ -471,7 +471,12 @@ static const u32 Td0[256] = {
     #define Td1(n)  ((Td0[n] >>  8) | (Td0[n] << 24))
     #define Td2(n)  ((Td0[n] >> 16) | (Td0[n] << 16))
     #define Td3(n)  ((Td0[n] >> 24) | (Td0[n] <<  8))
-    #define Td4(n)  (Td4[n] | (Td4[n] << 8) | (Td4[n] << 16) | (Td4[n] << 24))
+
+    /* helper to prevent the u8 to be promoted to signed int, which would turn
+     * left shift by 24 into undefined behaviour */
+    #define Td4u(n) (u32)Td4[n]

Yes. Fixed.

-- 
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub:
https://github.com/RIOT-OS/RIOT/pull/10785#discussion_r248628561
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.riot-os.org/pipermail/notifications/attachments/20190117/b200fc07/attachment.html>


More information about the notifications mailing list