4 ms·
I may be young and dumb, but C programming seems very simple and straightforward to me. With abstraction comes lack of knowledge of implementation in favor of e
by kizer 8y ago
I may be young and dumb, but C programming seems very simple and straightforward to me. With abstraction comes lack of knowledge of implementation in favor of ease of use; but in C you can build your own abstractions quickly and reach a level close to even JS (opaque types, function pointers). At least in C you know exactly what is going on.
Can someone briefly summarize the security issues in C? If you manage memory properly and take a conservative approach to handling input, where is the risk?
Like I said, I'm young and have only be programming in C for ~3 years.
- petee 8y agoC's biggest issue is well-warned (lazy?) programmers repeating the same mistakes that have been documented ages ago. In the analogy of shooting yourself in the foot, why is anyone using a gun without the safety training first?? If you're serious about writing safer C code, certainly check up the following two resources from Robert Seacord: - SEI CERT C Coding Standard: https://wiki.sei.cmu.edu/confluence/display/c/SEI+CERT+C+Coding+Standard https://wiki.sei.cmu.edu/confluence/display/c/SEI+CERT+C+Cod... - Secure Coding in C and C++: https://resources.sei.cmu.edu/library/asset-view.cfm?assetid=30581 https://resources.sei.cmu.edu/library/asset-view.cfm?assetid...
- pjmlp 8y agoIn C you think you know what is going on, specially bad when developers mix the compiler specific behavior with the standard and then try to write portable code. - Decays of arrays into pointers. - Decays of enumeration into numeric types - Default signess is implementation defined - Implicit conversions - Currently ISO C11 lists about 200 UB cases, C2X plans to list even more - Strings are a pointer to somewhere in memory that you hope the caller actually terminated them. - While the pre-processor seems basic, compared with real macros, you can still be very creative with it - No way to validate security issues in binary libraries The LLVM and PVS Studio blogs have quite a few examples of C gotchas.
- earenndil 8y ago> While the pre-processor seems basic, compared with real macros, you can still be very creative with it That sounds like a benefit, not a downside. See, for instance, http://libcello.org/ http://libcello.org/
- pjmlp 8y agoTry to be do maintenance work on a foreign code base and you quickly will change your mind regarding it being a benefit. Doing code fixes on a server code which was using clever tricks to convert between memory handles and the real memory addresses teached me that.
- chx 8y agohttp://www.cl.cam.ac.uk/~pes20/cerberus/notes50-survey-discussion.html http://www.cl.cam.ac.uk/~pes20/cerberus/notes50-survey-discu... Not only does this survey some interesting C behaviors in practice but asks "Do you know of real code that relies on it?" and there's always a number of "yes" / "yes, but it shouldn't" and also "no, that would be crazy" answers to each :D