4 ms·
This sort of thing would be exactly what should go into the "Friendly C" dialect being chatted about the other day--for things like zeroing memory, it's very un
by angersock 12y ago
This sort of thing would be exactly what should go into the "Friendly C" dialect being chatted about the other day--for things like zeroing memory, it's very unexpected that a compiler would be like "nah, not feeling it...nobody will notice anyways".
- cperciva 12y agoIf you're not worried about writing in a language which is widely supported, just use memset_s and tell people to find a C11 compiler.
- JoshTriplett 12y agoOr have your build system add memset_s.c to their compile on systems that don't have it.
- deleted 12y ago[deleted]
- tedunangst 12y agoA C11-unaware compiler will not be guaranteed to provide the always zero semantics, any more than your own secure_memzero could be optimized away.
- deleted 12y ago[deleted]
- stephencanon 12y agomemset_s is an optional feature of C11. Implementations are not required to provide it unless they define __STDC_LIB_EXT1__.
- deleted 12y ago[deleted]
- ars 12y agoNo, you are looking at it backward. The compiler tries to optimize the program so that it will run fast. If you force it to execute this code it only benefits the very rare security program, yet every single program will run slower. That's a bad tradeoff. Better to make the security program jump through hoops and let everyone else run fast.
- CJefferson 12y agoIf your compiler wrote every variable into memory, every time you changed it, your code would run at least 3 times slower. Compilers generally do not worry about making sure the value of unallocated blocks of memory are what you expect, as there is no way to observe them within your program.