6 ms·
I believe this[1] is the patch that fixes this bug. I tried to reproduce the behavior but couldn't succeed. Maybe I was doing something wrong. Would really appr
by kbeckmann 9y ago
I believe this[1] is the patch that fixes this bug. I tried to reproduce the behavior but couldn't succeed. Maybe I was doing something wrong. Would really appreciate it if someone here could show a test case where this matters.
[1] https://github.com/LoupVaillant/Monocypher/commit/347189c50c053cf13ce1310818c2913f4904c1eb https://github.com/LoupVaillant/Monocypher/commit/347189c50c...
- baby 9y ago`ctx->c` is a u32[1] and msg is u8. So yeah there is integer promotion here. [1]: https://github.com/LoupVaillant/Monocypher/blob/master/src/monocypher.h#L58 https://github.com/LoupVaillant/Monocypher/blob/master/src/m...
- loup-vaillant 9y agoYour failure to reproduce the behaviour is normal: on the compilers I have tested, this doesn't affect the generated binary. 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.
- deleted 9y ago[deleted]
- jwilk 9y agoCompile this program with -fsanitize=undefined: #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'