safety
The security cookbook opens its random numbers chapter with a blunt point: deterministic machines are bad at unpredictability That idea is still current even though its example APIs are old
Format strings
printf("%s", user_input);
Not printf(user_input)
A user controlled format string can read or write memory
That is not a theoretical bug
Bounds
Pass the destination size to every formatting and copy operation Check the result A truncation is not a success
Integer overflow
Check before adding lengths
A wrapped length turns a bounded copy into an unbounded one
C23 adds <stdckdint.h> for checked arithmetic where the compiler supports it
Randomness
Use the operating system’s random source for keys and tokens Do not seed a small PRNG with the time The cookbook’s lesson survives its API choices
Deprecated in C23
asctime and ctime are deprecated
_Noreturn is deprecated in favour of the [[noreturn]] attribute
Old code uses them, new code should not
Next
What changed in 12 current
Posted