by kbeckmann · 9y ago · 0 comments
[1] https://github.com/LoupVaillant/Monocypher/commit/347189c50c...
To see the difference, you need to first modify the makefile to use UBSan instead of just GCC (just comment the active CC line, and uncomment the right one). You may want to tone down the optimisations for faster compilation as well. Then you can run `make clean` and `./test.sh`. You should have a warning on commits prior to this patch.
#include <stddef.h>
#include <inttypes.h>
int main(int argc, char **argv)
{
uint8_t msg[] = { 255 };
size_t i = 0;
size_t c_index = 255;
return msg[i] << ((c_index % 4) * 8);
}
You get: runtime error: left shift of 255 by 24 places cannot be represented in type 'int'[1]: https://github.com/LoupVaillant/Monocypher/blob/master/src/m...