2 ms·
>You already did a possible security exploit on your example, as you need to guarantee 100% of the time that bla and blaa sizes are always less or equal than bu
by gens 10y ago
>You already did a possible security exploit on your example, as you need to guarantee 100% of the time that bla and blaa sizes are always less or equal than buffer_size.
bla and blaa buffer sizes, yes. I mostly string file names/paths, that have NAME_MAX and PATH_MAX. So my excuse here is that all my buffers have the same size (not the best excuse, i know). PS I always sanitize on input if the input can be anything (network/ipc sockets, for example).
>True, but Valgrind doesn't exist in every OS that one might need to work with, specially embedded ones, and according to Herb's talk at CppCon 2015, only 1% of the audience was using any form of static analyisis tooling.
Quick google shows some tools for windows. I don't know how good they are. Clangs static analyzer seems to work on windows, for static analysis. But if it compiles on linux/bsd/osx then people should check before shipping the code.
This just reminded me of the latest Linus rant[0].
Then there is fuzzing and formal verification, that are too much for "normal" programs (these are not C specific).
>The world of C and C++ programming, in typical 9-5 enterprise jobs is quite different from HN ideals about code quality.
As is in the world of hobby C and C++ programming. And python, and ruby, and haskell, and... It just shows more in C. But C is still the king when it comes to portable and efficient programs, and that won't change soon (although there is less need for such programs, as "embedded" today equals "has only 512MB RAM").
[0] http://lkml.iu.edu/hypermail/linux/kernel/1702.2/05171.html http://lkml.iu.edu/hypermail/linux/kernel/1702.2/05171.html